예제 #1
0
파일: test_first.py 프로젝트: GitBruno/foox
 def test_mutate_bounded_by_arg_values(self):
     """
     A rather contrived test but it proves that both the mutation_range and
     mutation_rate are used correctly given the context given by a cantus
     firmus.
     """
     cantus_firmus = [1, 1, 1, 1, 1]
     mutation_rate = 1 # mutate every time.
     mutation_range = 2 # will always mutate to thirds above the cf note.
     genome = Genome([5, 6, 7, 8, 9])
     genome.mutate(mutation_range, mutation_rate, cantus_firmus)
     self.assertEqual([3, 3, 3, 3, 3], genome.chromosome)
예제 #2
0
 def test_mutate_bounded_by_arg_values(self):
     """
     A rather contrived test but it proves that both the mutation_range and
     mutation_rate are used correctly given the context given by a cantus
     firmus.
     """
     cantus_firmus = [1, 1, 1, 1, 1]
     mutation_rate = 1  # mutate every time.
     mutation_range = 2  # will always mutate to thirds above the cf note.
     genome = Genome([5, 6, 7, 8, 9])
     genome.mutate(mutation_range, mutation_rate, cantus_firmus)
     self.assertEqual([3, 3, 3, 3, 3], genome.chromosome)
예제 #3
0
파일: test_first.py 프로젝트: GitBruno/foox
 def test_mutate_is_implemented(self):
     """
     Ensures that we have a mutate method implemented.
     """
     genome = Genome([1, 2, 3])
     self.assertNotEqual(NotImplemented, genome.mutate(2, 0.2, [1, 2, 3]))
예제 #4
0
 def test_mutate_is_implemented(self):
     """
     Ensures that we have a mutate method implemented.
     """
     genome = Genome([1, 2, 3])
     self.assertNotEqual(NotImplemented, genome.mutate(2, 0.2, [1, 2, 3]))