Example #1
0
    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])
Example #2
0
 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])
Example #3
0
 def testShortInversion(self):
     # 5: Makes sure inversion works with head length=1
     i = Computation.generate(1, 1).next()
     self.assertEqual(i, i.invert())
Example #4
0
 def setUp(self):
     gen = Computation.generate(5, 3)
     self.chromosome1 = gen.next()
     self.chromosome2 = gen.next()
Example #5
0
 def setUp(self):
     self.chromosome = Computation.generate(self.head, self.genes).next()
Example #6
0
 def setUp(self):
     self.chromosome = Computation.generate(self.head, self.genes).next()
Example #7
0
 def testShortInversion(self):
     # 5: Makes sure inversion works with head length=1
     i = Computation.generate(1, 1).next()
     self.assertEqual(i, i.invert())
Example #8
0
 def setUp(self):
     gen = Computation.generate(5, 3)
     self.chromosome1 = gen.next()
     self.chromosome2 = gen.next()
Example #9
0
 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))