def mutEphemeral(individual, mode):
 if (mode not in ['one', 'all']):
  raise ValueError('Mode must be one of "one" or "all"')
 ephemerals_idx = [index for (index, node) in enumerate(individual) if isinstance(node, Ephemeral)]
 if (len(ephemerals_idx) > 0):
  if (mode == 'one'):
   ephemerals_idx = (random.choice(ephemerals_idx),)
  for i in ephemerals_idx:
   individual[i] = type(individual[i])()
 return (individual,)

def mutEphemeral ( individual , mode ) : if ( mode not in [ 'one' , 'all' ] ) : raise ValueError ( 'Mode must be one of "one" or "all"' ) ephemerals_idx = [ index for ( index , node ) in enumerate ( individual ) if isinstance ( node , Ephemeral ) ] if ( len ( ephemerals_idx ) > 0 ) : if ( mode == 'one' ) : ephemerals_idx = ( random . choice ( ephemerals_idx ) , ) for i in ephemerals_idx : individual [ i ] = type ( individual [ i ] ) ( ) return ( individual , )
this operator works on the constants of the tree *individual* .