Ejemplo 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, CANTUS_FIRMUS)
     self.assertTrue(callable(result))
Ejemplo 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, CANTUS_FIRMUS)
     self.assertTrue(callable(result))
Ejemplo 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, CANTUS_FIRMUS)
     g1 = Genome([1, 2, 3])
     g1.fitness = 1
     g2 = Genome([1, 2, 3])
     g2.fitness = 2
     seed_population = [g1, g2]
     result = generate_function(seed_population)
     self.assertTrue(list, type(result))
Ejemplo 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, CANTUS_FIRMUS)
     g1 = Genome([1, 2, 3])
     g1.fitness = 1
     g2 = Genome([1, 2, 3])
     g2.fitness = 2
     seed_population = [g1, g2]
     result = generate_function(seed_population)
     self.assertTrue(list, type(result))
Ejemplo 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, CANTUS_FIRMUS)
     g1 = Genome([1, 2, 3])
     g1.fitness = 1
     g2 = Genome([1, 2, 3])
     g2.fitness = 2
     g3 = Genome([1, 2, 3])
     g3.fitness = 3
     seed_population = [g1, g2, g3]
     result = generate_function(seed_population)
     self.assertTrue(3, len(result))
Ejemplo 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, CANTUS_FIRMUS)
     g1 = Genome([1, 2, 3])
     g1.fitness = 1
     g2 = Genome([1, 2, 3])
     g2.fitness = 2
     g3 = Genome([1, 2, 3])
     g3.fitness = 3
     seed_population = [g1, g2, g3]
     result = generate_function(seed_population)
     self.assertTrue(3, len(result))