def test_vectormatrix_to_numpy_1(self): A = VectorMatrix(Shape(10,10,10)) A.fill((1.0, 2.0, 3.0)) B = A.to_numpy() self.assertEquals((10,10,10,3), B.shape) self.assertTrue(np.all(B[:,:,:,0] == 1.0)) self.assertTrue(np.all(B[:,:,:,1] == 2.0)) self.assertTrue(np.all(B[:,:,:,2] == 3.0))
def test_vectormatrix_to_numpy_1(self): A = VectorMatrix(Shape(10, 10, 10)) A.fill((1.0, 2.0, 3.0)) B = A.to_numpy() self.assertEquals((10, 10, 10, 3), B.shape) self.assertTrue(np.all(B[:, :, :, 0] == 1.0)) self.assertTrue(np.all(B[:, :, :, 1] == 2.0)) self.assertTrue(np.all(B[:, :, :, 2] == 3.0))
def test_fill(self): m1 = VectorMatrix(Shape(10, 10, 10)); m1.fill((1.0, 2.0, 3.0)); self.assertEqual(m1.get(4, 4, 4), (1.0, 2.0, 3.0)) self.assertEqual(m1.uniform_value, (1.0, 2.0, 3.0)) self.assertTrue(m1.isUniform()) m1.set(4, 4, 4, (3.0, 2.0, 1.0)) self.assertEqual(m1.get(4, 4, 4), (3.0, 2.0, 1.0)) self.assertEqual(m1.get(0, 1, 2), (1.0, 2.0, 3.0)) self.assertFalse(m1.isUniform())
def test_fill(self): A = VectorMatrix(Shape(100,100,10)) A.fill((1.0, 2.0, 3.0)) for idx in range(A.size()): self.assertTrue(A.get(idx) == (1.0, 2.0, 3.0))