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] # mutate every time. mutation_rate = 1 # will always mutate to thirds above the cf note. mutation_range = 2 genome = Genome([5, 6, 7, 8, 9]) genome.mutate(mutation_range, mutation_rate, cantus_firmus) self.assertEqual([3, 3, 3, 3, 3], genome.chromosome)
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]))