Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
A :class:`.Selection` instance which has all of the
selection related data held in the input file.
"""
gen = FunctionData(self.generational_select_func['NAME'],
**{key: val for key, val in
self.generational_select_func.items() if
key != 'NAME'})
crossover = FunctionData(self.crossover_select_func['NAME'],
**{key: val for key, val in
self.crossover_select_func.items()
if key != 'NAME'})
mutation = FunctionData(self.mutation_select_func['NAME'],
**{key: val for key, val in
self.mutation_select_func.items() if
key != 'NAME'})
return Selection(gen, crossover, mutation)
if 'self' in bound.keys():
bound.pop('self')
# Replace the energy function to be used with the key of the
# energy function to be used.
efuncdata = bound['func']
efunc = getattr(Energy, efuncdata.name)
bound['func'] = func_key(efunc, None, efuncdata.params)
# Don't want this paramter in the key as it doenst affect the
# result.
bound.pop('force_e_calc')
# Return an FunctionData object representing the function and
# chosen parameters.
return FunctionData('pseudoformation', **bound)
dict(fsig.parameters).items() if
key not in bound.keys()}
# Combine the two sets of parameters and get rid of the `self`
# parameter, if present.
bound.update(default)
if 'self' in bound.keys():
bound.pop('self')
# Remove any parameters that should not form key, listed in the
# `exclude` attribute.
if hasattr(func, 'exclude'):
for key in func.exclude:
bound.pop(key)
# Return an FunctionData object representing the function and
# chosen parameters.
return FunctionData(func.__name__, **bound)
def selector(self):
"""
Use input file data to build :class:`.Selection` instance.
Returns
-------
:class:`.Selection`
A :class:`.Selection` instance which has all of the
selection related data held in the input file.
"""
gen = FunctionData(self.generational_select_func['NAME'],
**{key: val for key, val in
self.generational_select_func.items() if
key != 'NAME'})
crossover = FunctionData(self.crossover_select_func['NAME'],
**{key: val for key, val in
self.crossover_select_func.items()
if key != 'NAME'})
mutation = FunctionData(self.mutation_select_func['NAME'],
**{key: val for key, val in
self.mutation_select_func.items() if
key != 'NAME'})
return Selection(gen, crossover, mutation)
Use input file data to build :class:`.Selection` instance.
Returns
-------
:class:`.Selection`
A :class:`.Selection` instance which has all of the
selection related data held in the input file.
"""
gen = FunctionData(self.generational_select_func['NAME'],
**{key: val for key, val in
self.generational_select_func.items() if
key != 'NAME'})
crossover = FunctionData(self.crossover_select_func['NAME'],
**{key: val for key, val in
self.crossover_select_func.items()
if key != 'NAME'})
mutation = FunctionData(self.mutation_select_func['NAME'],
**{key: val for key, val in
self.mutation_select_func.items() if
key != 'NAME'})
return Selection(gen, crossover, mutation)
def mutator(self):
"""
Use input file data to build :class:`.Mutation` instance.
Returns
-------
:class:`.Mutation`
A :class:`.Mutation` instance which has all of the
mutation related data held in the input file.
"""
funcs = [FunctionData(x['NAME'],
**{k: v for k, v in x.items() if k != 'NAME'})
for x in self.mutation_funcs]
return Mutation(funcs,
self.num_mutations,
self.mutation_weights)
"""
Use input file data to extract fitness function information.
Returns
-------
:class:`.FunctionData`
A :class:`.FunctionData` object which represents the
fitness function.
"""
# Check if a function was defined in the input file.
if hasattr(self.fitness_func, '__call__'):
return self.fitness_func
return FunctionData(self.fitness_func['NAME'],
**{key: val for key, val in
self.fitness_func.items() if
key != 'NAME'})
if 'self' in bound.keys():
bound.pop('self')
# Replace the energy function to be used with the key of the
# energy function to be used.
efuncdata = bound['func']
efunc = getattr(Energy, efuncdata.name)
bound['func'] = func_key(efunc, None, efuncdata.params)
# Don't want this paramter in the key as it doenst affect the
# result.
bound.pop('force_e_calc')
# Return an FunctionData object representing the function and
# chosen parameters.
return FunctionData('formation', **bound)