def testNormalInversion(self): x = Computation.generate(2, 1).next() y = x.invert() # Heads should be switched, tails unaffected self.assertEqual(x.genes[0][2:], y.genes[0][2:]) self.assertEqual(x.genes[0][0], y.genes[0][1]) self.assertEqual(x.genes[0][1], y.genes[0][0])
def testShortInversion(self): # 5: Makes sure inversion works with head length=1 i = Computation.generate(1, 1).next() self.assertEqual(i, i.invert())
def setUp(self): gen = Computation.generate(5, 3) self.chromosome1 = gen.next() self.chromosome2 = gen.next()
def setUp(self): self.chromosome = Computation.generate(self.head, self.genes).next()
def testShortIS(self): # 5: IS transposition should do nothing if head length=1 i = Computation.generate(1, 1).next() self.assertEqual(i, i.transpose_is(1))