<s> import unittest <EOL> import random <EOL> import logging <EOL> import multiprocessing <EOL> import inspyred <EOL> class DummyEC ( object ) : <EOL> pass <EOL> def test_generator ( random , args ) : <EOL> return [ random . random ( ) for _ in range ( <NUM_LIT:6> ) ] <EOL> def test_evaluator ( candidates , args ) : <EOL> fitness = [ ] <EOL> for c in candidates : <EOL> fitness . append ( sum ( c ) ) <EOL> return fitness <EOL> def test_evaluator_mo ( candidates , args ) : <EOL> fitness = [ ] <EOL> for c in candidates : <EOL> fitness . append ( inspyred . ec . emo . Pareto ( [ sum ( c ) , sum ( c ) ] ) ) <EOL> return fitness <EOL> def test_set_up ( generator , evaluator ) : <EOL> pop_size = <NUM_LIT:12> <EOL> prng = random . Random ( ) <EOL> prng . seed ( <NUM_LIT> ) <EOL> candidates = [ generator ( prng , { } ) for _ in range ( pop_size ) ] <EOL> fitnesses = evaluator ( candidates , { } ) <EOL> population = [ inspyred . ec . Individual ( candidate = c ) for c in candidates ] <EOL> for i , f in zip ( population , fitnesses ) : <EOL> i . fitness = f <EOL> parents = population [ : pop_size // <NUM_LIT:2> ] <EOL> offspring = population [ pop_size // <NUM_LIT:2> : ] <EOL> return ( prng , candidates , fitnesses , population , parents , offspring ) <EOL> class EvaluatorTests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . prng , self . candidates , self . fitnesses , self . population , self . parents , self . offspring = test_set_up ( test_generator , test_evaluator ) <EOL> self . evaluator = test_evaluator <EOL> self . ec = inspyred . ec . EvolutionaryComputation ( None ) <EOL> def test_parallel_evaluation_pp ( self ) : <EOL> fitnesses = inspyred . ec . evaluators . parallel_evaluation_pp ( self . candidates , { '<STR_LIT>' : self . ec , '<STR_LIT>' : self . evaluator } ) <EOL> assert fitnesses == self . fitnesses <EOL> def test_parallel_evaluation_mp ( self ) : <EOL> fitnesses = inspyred . ec . evaluators . parallel_evaluation_mp ( self . candidates , { '<STR_LIT>' : self . ec , '<STR_LIT>' : self . evaluator } ) <EOL> assert fitnesses == self . fitnesses <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
