def test_homomorphism(): GLZ_B = MG.GLZ(B, 'xy') GLZ_D = MG.GLZ(D, 'ij') GLZ_BD = MG.product_homomorphism(GLZ_B, GLZ_D) yield assert_true, np.allclose(GLZ_BD.matrix[:2, :2], GLZ_B.matrix) yield assert_true, np.allclose(GLZ_BD.matrix[2:, 2:], GLZ_D.matrix) yield assert_true, np.allclose(GLZ_BD.matrix[2:, :2], 0) yield assert_true, np.allclose(GLZ_BD.matrix[:2, 2:], 0) GLZ_C = MG.GLZ(D, 'xy') # have the same axisnames, an exception will be raised yield assert_raises, ValueError, MG.product_homomorphism, GLZ_C, GLZ_B E = np.array([[7, 8], [8, 9]]) GLZ_E = MG.GLZ(E, 'ij') F = np.array([[6, 7], [5, 6]]) GLZ_F = MG.GLZ(E, 'xy') GLZ_FE = MG.product_homomorphism(GLZ_F, GLZ_E) test1 = MG.product(GLZ_FE, GLZ_BD) test2 = MG.product_homomorphism(MG.product(GLZ_F, GLZ_B), MG.product(GLZ_E, GLZ_D)) yield assert_true, np.allclose(test1.matrix, test2.matrix)
def test_product(): GLZ_A = MG.GLZ(A, 'xy') GLZ_B = MG.GLZ(B, 'xy') GLZ_C = MG.GLZ(B, 'ij') GLZ_AB = MG.product(GLZ_A, GLZ_B) yield (assert_true, np.allclose(GLZ_AB.matrix, np.dot(GLZ_A.matrix, GLZ_B.matrix))) # different coordinates: can't make the product yield assert_raises, ValueError, MG.product, GLZ_A, GLZ_C
def test_init(): """ Test that we can initialize the MatrixGroup subclasses """ O_A = MG.O(A, 'xy') GLR_A = MG.GLR(A, 'xy') GLZ_A = MG.GLZ(A, 'xy') SO_A = MG.SO(np.identity(2), 'xy') B = np.array([[np.sin(0.75), np.cos(0.75)], [-np.cos(0.75), np.sin(0.75)]]) O_B = MG.O(B, 'xy') SO_B = MG.O(B, 'xy') B[1] = -B[1] assert_raises(ValueError, MG.SO, B, 'xy') O_B = MG.O(B, 'xy')