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])
def test_fill(self): m1 = Matrix(Shape(10, 10, 10)); m1.fill(1.0) self.assertEqual(m1.get(4, 4, 4), 1.0) self.assertEqual(m1.uniform_value, 1.0) self.assertTrue(m1.isUniform()) m1.set(4, 4, 4, 2.0); self.assertEqual(m1.get(4, 4, 4), 2.0) self.assertFalse(m1.isUniform())
def test_fill(self): m1 = Matrix(Shape(10, 10, 10)) m1.fill(1.0) self.assertEqual(m1.get(4, 4, 4), 1.0) self.assertEqual(m1.uniform_value, 1.0) self.assertTrue(m1.isUniform()) m1.set(4, 4, 4, 2.0) self.assertEqual(m1.get(4, 4, 4), 2.0) self.assertFalse(m1.isUniform())
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])