예제 #1
0
        def test_matrix_to_numpy_1(self):
            A = Matrix(Shape(10, 10, 10))
            A.fill(42.0)

            B = A.to_numpy()
            self.assertEquals((10, 10, 10), B.shape)
            self.assertTrue(np.all(B[:, :, :] == 42.0))
예제 #2
0
        def test_matrix_to_numpy_2(self):
            def flub(x, y, z):
                return x * y * z + 42 + (5 * x) * (2 - y) + 8 * z

            A = Matrix(Shape(10, 20, 30))
            for x, y, z in itertools.product(range(10), range(20), range(30)):
                A.set(x, y, z, flub(x, y, z))

            B = A.to_numpy()
            self.assertEquals(A.shape, B.shape)
            for x, y, z in itertools.product(range(10), range(20), range(30)):
                self.assertEquals(flub(x, y, z), B[x, y, z])