Exemplo n.º 1
0
 def test_make_generate_function_returns_callable(self):
     """
     Ensures the make_generate_function returns a callable (the generate
     function to use in the GA).
     """
     result = make_generate_function(7, 0.2, TARGET_WORD)
     self.assertTrue(callable(result))
Exemplo n.º 2
0
 def test_make_generate_function_returns_callable(self):
     """
     Ensures the make_generate_function returns a callable (the generate
     function to use in the GA).
     """
     result = make_generate_function(7, 0.2, TARGET_WORD)
     self.assertTrue(callable(result))
Exemplo n.º 3
0
 def test_generate_function_returns_list(self):
     """
     Ensures the new population is a list.
     """
     generate_function = make_generate_function(7, 0.2, TARGET_WORD)
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     seed_population = [g1, g2]
     result = generate_function(seed_population)
     self.assertTrue(list, type(result))
Exemplo n.º 4
0
 def test_generate_function_returns_list(self):
     """
     Ensures the new population is a list.
     """
     generate_function = make_generate_function(7, 0.2, TARGET_WORD)
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     seed_population = [g1, g2]
     result = generate_function(seed_population)
     self.assertTrue(list, type(result))
Exemplo n.º 5
0
 def test_generate_function_returns_list_of_correct_length(self):
     """
     Ensure the new population is the correct length.
     """
     generate_function = make_generate_function(7, 0.2, TARGET_WORD)
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     seed_population = [g1, g2, g3]
     result = generate_function(seed_population)
     self.assertTrue(3, len(result))
Exemplo n.º 6
0
 def test_generate_function_returns_list_of_correct_length(self):
     """
     Ensure the new population is the correct length.
     """
     generate_function = make_generate_function(7, 0.2, TARGET_WORD)
     g1 = Genome(['c', 'a', 't'])
     g1.fitness = 1
     g2 = Genome(['d', 'o', 'g'])
     g2.fitness = 2
     g3 = Genome(['f', 'o', 'o'])
     g3.fitness = 3
     seed_population = [g1, g2, g3]
     result = generate_function(seed_population)
     self.assertTrue(3, len(result))