コード例 #1
0
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)
コード例 #2
0
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
コード例 #3
0
def test_32():
    class O32(MG.O):
        dtype = np.float32

        def validate(self, M=None):
            """
            Check that the matrix is (almost) orthogonal.
            """
            if M is None:
                M = self.matrix
            return np.allclose(np.identity(self.ndim[0], dtype=self.dtype), np.dot(M.T, M), atol=1.0e-06)

    a = random_orth(3).matrix.astype(np.float32)

    A = O32(a, 'xyz')
    B = O32(random_orth(3).matrix.astype(np.float32), 'xyz')
    C = MG.product(A, B)
    yield assert_equal, C.dtype, np.float32

    ev = ArrayCoordMap.from_shape(C, (20,30,40))
    yield assert_equal, ev.values.dtype, np.float32
コード例 #4
0
def test_product2():
    O_1 = random_orth(names='xyz')
    O_2 = random_orth(names='xyz')
    O_21 = MG.product(O_2, O_1)