def test_dealloc(self): U, V = Transformation([1, 0, 1, 2]), Transformation([1, 1, 3, 2, 4, 3]) del U, V with self.assertRaises(NameError): V with self.assertRaises(NameError): U
def test_richcmp(self): # FIXME should be self.assertEqual and self.assertNotEqual assert PartialPerm([1, 2, 3], [2, 1, 0], 5) == \ PartialPerm([1, 2, 3], [2, 1, 0], 5) assert not PartialPerm([1, 2, 3], [2, 1, 0], 5) != \ PartialPerm([1, 2, 3], [2, 1, 0], 5) assert not PartialPerm([1, 2, 4], [2, 1, 0], 5) == \ PartialPerm([1, 2, 3], [2, 3, 0], 5) assert PartialPerm([1, 2, 4], [2, 1, 0], 5) != \ PartialPerm([1, 2, 3], [2, 3, 0], 5) assert not PartialPerm([1, 2, 4], [2, 1, 0], 5) < \ PartialPerm([1, 2, 3], [2, 3, 0], 5) assert PartialPerm([1, 2], [0, 1], 3) < \ PartialPerm([2, 0], [0, 1], 3) assert not PartialPerm([1, 2], [0, 1], 3) > \ PartialPerm([2, 0], [0, 1], 3) assert PartialPerm([1, 2], [1, 2], 3) > \ PartialPerm([1, 2], [0, 1], 3) assert PartialPerm([1, 2], [1, 2], 3) >= \ PartialPerm([1, 2], [0, 1], 3) assert PartialPerm([1, 2, 3], [2, 1, 0], 5) <= \ PartialPerm([1, 2, 3], [2, 1, 0], 5) with self.assertRaises(TypeError): PartialPerm([1, 2], [2, 1], 3) == \ Bipartition([1, -1], [2, 3, -2], [-3]) with self.assertRaises(TypeError): PartialPerm([0, 1], [0, 1], 2) < Transformation([0, 1]) with self.assertRaises(TypeError): PartialPerm([0, 1], [0, 1], 2) != Transformation([0, 1])
def test_init_fail(self): with self.assertRaises(ValueError): Transformation([1, 5, 26]) with self.assertRaises(ValueError): Transformation([1]) with self.assertRaises(TypeError): Transformation(26) with self.assertRaises(TypeError): Transformation(['a', 'b']) with self.assertRaises(TypeError): Transformation([0.1, 1.0])
def test_mul(self): self.assertEqual( PBR([[1, -1]], [[1]]) * PBR([[1, -1]], [[1]]), PBR([[1, -1]], [[1]])) self.assertEqual( PBR([[1, -1], [-2, -1]], [[1], [-2, -1]]) * PBR([[-1, 1, 2], [2]], [[-1, 1], [-2, 2]]), PBR([[1, -1], [1, -1]], [[1, -1], [1, -1, -2]])) self.assertEqual( PBR([[-1, 1, 2], [2]], [[-1, 1], [-2, 2]]) * PBR([[1, -1], [-2, -1]], [[1], [-2, -1]]), PBR([[-1, 1, 2], [2]], [[-1, 1], [-2, -1]])) self.assertEqual( PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) * PBR([[1, -1, 3], [-2, -1, 2], [3, -3, -2]], [[1, 2], [-2, 3, -3], [1, -1]]), PBR([[-1, 1, 2, 3], [-2, -1, 1, 2], [-2, -1, 3]], [[-2, -1, 2], [-3, -2, -1, 1, 2], [-1, 2]])) with self.assertRaises(TypeError): Transformation([0, 2, 1]) * \ PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) with self.assertRaises(TypeError): PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) * \ Bipartition([1, -1], [2, 3, -3], [-2]) with self.assertRaises(TypeError): PBR([[1, -1]], [[1]]) * 0.142857 with self.assertRaises(ValueError): PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) * PBR([[1, -1]], [[1]])
def test_richcmp(self): self.assertEqual(PBR([[1, -1], [-2, -1, 2]], [[2], [-2]]), PBR([[1, -1], [-2, -1, 2]], [[2], [-2]])) self.assertEqual(PBR([[1, -1], [-2, -1, 2]], [[2], [-2]]), PBR([[1, -1], [-2, -1, 2]], [[2], [-2]])) self.assertNotEqual( PBR([[1, -1], [-2, -1, 2]], [[2], [-2]]), PBR([[1, 2], [-2, 1, 2], [3, -3]], [[2, 1], [-2, 2, 1], [1, -1]])) self.assertTrue( PBR([[1], [1, 2, -1]], [[1], [2, -1, 1]]) < PBR([[1], [2]], [[-1], [-2]])) self.assertTrue( PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) > PBR([[1, -1], [-2, -1, 2]], [[2], [-2]])) self.assertTrue( PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) >= PBR([[1, -1], [-2, -1, 2]], [[2], [-2]])) self.assertTrue( PBR([[1, -1], [-2, -1, 2]], [[2], [-2]]) <= PBR( [[1, -1], [-2, -1, 2]], [[2], [-2]])) with self.assertRaises(TypeError): (PBR([[1, -1, 3], [-2, -1, 2], [3, -2]], [[2], [-2], [1, -1, 2]]) == Bipartition([1, -1], [2, 3, -2], [-3])) with self.assertRaises(TypeError): PBR([[1, -1], [-2, -1]], [[1], [-2, -1]]) < Transformation([0, 1]) with self.assertRaises(TypeError): PBR([[1, -1], [-2, -1]], [[1], [-2, -1]]) != \ PartialPerm([0, 1], [1, 0], 2) with self.assertRaises(TypeError): PBR([[1, -1]], [[1]]) < 3
def test_mul(self): self.assertEqual(BooleanMat([True, False], [False, True]) * \ BooleanMat([False, False], [False, True]), BooleanMat([False, False], [False, True])) self.assertEqual( BooleanMat([False]) * BooleanMat([True]), BooleanMat([False])) self.assertEqual(BooleanMat([False, True, True], [True, True, False], [False, False, False]) * \ BooleanMat([False, True, False], [True, False, False], [False, False, True]), BooleanMat([True, False, True], [True, True, False], [False, False, False])) with self.assertRaises(TypeError): BooleanMat([True, True], [False, False]) * Transformation([1, 1]) with self.assertRaises(TypeError): BooleanMat([False, True, True], [True, True, False], [False, False, False]) * PartialPerm([0, 1], [1, 2], 3) with self.assertRaises(TypeError): BooleanMat([True]) * [True] with self.assertRaises(TypeError): BooleanMat([True, False], [False, True]) * Bipartition([1, 2], [-1], [-2]) with self.assertRaises(ValueError): BooleanMat([False, True, True], [True, True, False], [False, False, False]) * \ BooleanMat([True, False], [False, True])
def test_richcmp(self): # FIXME should be self.assertEqual and self.assertNotEqual assert BooleanMat([True, False], [False, True]) == \ BooleanMat([True, False], [False, True]) assert not BooleanMat([True, False], [False, True]) != \ BooleanMat([True, False], [False, True]) assert not BooleanMat([True, False], [False, True]) == \ BooleanMat([False, False], [False, True]) assert BooleanMat([False]) < BooleanMat([True]) assert not BooleanMat([False, True, True], [True, True, False], [False, False, False]) < \ BooleanMat([False, True, False], [True, False, False], [False, False, True]) assert BooleanMat([False]) <= BooleanMat([False]) assert BooleanMat([True, False], [False, True]) > \ BooleanMat([True, False], [False, False]) assert not BooleanMat([True, False], [False, True]) > \ BooleanMat([True, False], [False, True]) assert BooleanMat([False]) >= BooleanMat([False]) with self.assertRaises(TypeError): Bipartition([1, -2], [-1, 2]) >= \ BooleanMat([False, False], [True, False]) with self.assertRaises(TypeError): BooleanMat([False, False], [True, False]) < Transformation([0, 1]) with self.assertRaises(TypeError): BooleanMat([True, False], [False, True]) == \ PartialPerm([0], [1], 2)
def test_richcmp(self): # FIXME should be self.assertEqual and self.assertNotEqual assert Bipartition([3, -4, -1], [2, -3], [4, -2], [1]) == \ Bipartition([4, -2], [3, -4, -1], [1], [2, -3]) assert not Bipartition([3, -4, -1], [2, -3], [4, -2], [1]) != \ Bipartition([4, -2], [3, -4, -1], [1], [2, -3]) assert Bipartition([1, -1, 3], [-3, 2, -2]) <= \ Bipartition([1, -1], [2, 3, -2], [-3]) assert Bipartition([1, -1], [2, -2]) < Bipartition([1, -2], [2, -1]) assert Bipartition([1, -1], [2, -2]) <= Bipartition([1, -2], [2, -1]) assert Bipartition([1, -1, 3], [-3, 2, -2]) >= \ Bipartition([1, -2], [2, -1]) assert not Bipartition([1, -1, 3], [-3, 2, -2]) > \ Bipartition([1, -1], [2, 3, -2], [-3]) with self.assertRaises(TypeError): PartialPerm([1, 2], [2, 1], 3) == \ Bipartition([1, -1], [2, 3, -2], [-3]) with self.assertRaises(TypeError): Bipartition([1, -1], [2, -2]) < Transformation([0, 1]) with self.assertRaises(TypeError): Bipartition([1, -1], [2, -2]) != Transformation([0, 1])
def test_repr(self): self.assertEqual( eval(Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5]).__repr__()), Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5])) self.assertEqual(eval(Transformation([2, 2, 2]).__repr__()), Transformation([2, 2, 2])) self.assertEqual(eval(Transformation([1, 2, 3, 3]).__repr__()), Transformation([1, 2, 3, 3]))
def test_identity(self): self.assertEqual( Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5]).identity(), Transformation([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])) self.assertEqual( Transformation([2, 2, 2]).identity(), Transformation([0, 1, 2])) self.assertEqual( Transformation([1, 2, 3, 3]).identity(), Transformation([0, 1, 2, 3]))
def test_mul(self): self.assertEqual(PartialPerm([0, 1], [0, 1], 2) * \ PartialPerm([0, 1], [0, 1], 2), PartialPerm([0, 1], [0, 1], 2)) self.assertEqual(PartialPerm([1, 2, 4, 6, 7, 23], [0, 5, 2, 4, 6, 7], 26) * \ PartialPerm([2, 4, 3, 5, 0, 19], [7, 8, 2, 3, 23, 0], 26), PartialPerm([1, 2, 4, 6], [23, 3, 7, 8], 26)) self.assertEqual(PartialPerm([0, 3, 7, 2], [5, 7, 1, 3], 8) * \ PartialPerm([4, 7, 3, 6], [5, 0, 3, 2], 8), PartialPerm([2, 3], [3, 0], 8)) with self.assertRaises(TypeError): PartialPerm([0, 1], [0, 1], 2) * Transformation([0, 1]) with self.assertRaises(TypeError): PartialPerm([0, 1], [0, 1], 2) * Bipartition([-2, 1], [-1, 2]) with self.assertRaises(ValueError): PartialPerm([1, 2], [0, 1], 3) * PartialPerm([1, 2], [0, 1], 4)
def test_mul(self): self.assertEqual(Bipartition([1, -1, 2, -2]) * \ Bipartition([1, -1, 2, -2]), Bipartition([1, 2, -1, -2])) self.assertEqual(Bipartition([1, 2], [-1], [-2]) * \ Bipartition([1, -1], [2, -2]), Bipartition([1, 2], [-1], [-2])) self.assertEqual(Bipartition([1, -1], [2, 3, -2], [-3]) * \ Bipartition([1, 3, 2, -3], [-2], [-1]), Bipartition([1, 2, 3, -3], [-1], [-2])) with self.assertRaises(TypeError): Bipartition([1, -1], [2, 3, -3], [-2]) * \ PartialPerm([0, 1], [1, 2], 3) with self.assertRaises(TypeError): Transformation([0, 2, 1]) * Bipartition([1, -1], [2, 3, -3], [-2]) with self.assertRaises(TypeError): Bipartition([1, -1], [2, 3, -3], [-2]) * 26 with self.assertRaises(ValueError): Bipartition([1, -1], [2, 3, -3], [-2]) * \ Bipartition([1, -1, 2, -2])
def test_init(self): Transformation([0, 1, 2, 3]) Transformation([1, 1, 3, 2, 4, 3]) Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5])
def test_degree(self): self.assertEqual( Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5]).degree(), 10) self.assertEqual(Transformation([2, 2, 2]).degree(), 3) self.assertEqual(Transformation([1, 2, 3, 3]).degree(), 4)
def test_pow(self): self.assertEqual( Transformation([9, 3, 1, 2, 0, 8, 1, 2, 0, 5])**6, Transformation([5, 1, 2, 3, 9, 0, 2, 3, 9, 8])) self.assertEqual( Transformation([2, 2, 2])**30, Transformation([2, 2, 2])) self.assertEqual( Transformation([1, 2, 3, 3])**8, Transformation([3, 3, 3, 3])) self.assertEqual( Transformation([1, 1, 3, 2, 4, 3])**0, Transformation([1, 1, 3, 2, 4, 3]).identity()) with self.assertRaises(ValueError): Transformation([1, 2, 3, 0])**-1 with self.assertRaises(TypeError): Transformation([1, 0, 1, 2])**1.5 with self.assertRaises(TypeError): Transformation([3, 2, 0, 0])**'l'
def test_mul(self): self.assertEqual(Transformation([1, 3, 2, 1]) * \ Transformation([0, 3, 2, 2]), Transformation([3, 2, 2, 3])) self.assertEqual( Transformation([2, 2, 2]) * Transformation([1, 0, 1]), Transformation([1, 1, 1])) self.assertEqual(Transformation([0, 1, 2, 3, 4, 5]) * \ Transformation([3, 2, 2, 3, 1, 4]), Transformation([3, 2, 2, 3, 1, 4])) with self.assertRaises(TypeError): Transformation([0, 2, 1]) * PartialPerm([0, 1], [1, 2], 3) with self.assertRaises(TypeError): Transformation([0, 2, 1]) * Bipartition([1, -1], [2, 3, -3], [-2]) with self.assertRaises(TypeError): Transformation([0, 1, 2, 3, 4, 5]) * 8 with self.assertRaises(ValueError): Transformation([0, 2, 1]) * Transformation([1, 2, 3, 0])
def test_richcmp(self): # FIXME should be self.assertEqual and self.assertNotEqual assert Transformation([1, 2, 2, 0]) == Transformation([1, 2, 2, 0]) assert not Transformation([1, 2, 2, 0]) == Transformation([1, 2, 1, 3]) assert Transformation([1, 2, 2, 0]) != Transformation([1, 2, 1, 3]) assert not Transformation([2, 2, 1]) < Transformation([0, 1, 2]) assert Transformation([2, 2, 1]) > Transformation([0, 1, 2]) assert Transformation([2, 2, 1]) <= Transformation([2, 2, 2]) assert Transformation([2, 2, 2]) <= Transformation([2, 2, 2]) assert Transformation([2, 2, 2]) >= Transformation([2, 2, 0]) assert Transformation([3, 2, 3, 0]) >= Transformation([3, 2, 0, 1]) with self.assertRaises(TypeError): Transformation([2, 2, 0]) == Bipartition([1, -1], [2, 3, -2], [-3]) with self.assertRaises(TypeError): Bipartition([1, -1], [2, -2]) < Transformation([0, 1]) with self.assertRaises(TypeError): Bipartition([1, -1], [2, -2]) != Transformation([0, 1])