def test_affine_identity(): aff = AffineTransform.identity('ijk') yield assert_equal, aff.affine, np.eye(4) yield assert_equal, aff.function_domain, aff.function_range x = np.array([3, 4, 5]) # AffineTransform's aren't CoordinateMaps, so # they don't have "function" attributes yield assert_false, hasattr(aff, 'function')
def setup(): def f(x): return 2 * x def g(x): return x / 2.0 x = CoordinateSystem("x", "x") E.a = CoordinateMap(x, x, f) E.b = CoordinateMap(x, x, f, inverse_function=g) E.c = CoordinateMap(x, x, g) E.d = CoordinateMap(x, x, g, inverse_function=f) E.e = AffineTransform.identity("ijk") A = np.identity(4) A[0:3] = np.random.standard_normal((3, 4)) E.mapping = AffineTransform.from_params("ijk", "xyz", A) E.singular = AffineTransform.from_params( "ijk", "xyzt", np.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [8, 9, 10, 11], [0, 0, 0, 1]]) )
def test_bounding_box(): shape = (10, 14, 16) coordmap = AffineTransform.identity(names) yield assert_equal( bounding_box(coordmap, shape), ((0., 9.), (0, 13), (0, 15)))
def test_bounding_box(self): shape = (10, 14, 16) coordmap = AffineTransform.identity(names) #print coordmap.affine.dtype, 'affine' self.assertEqual(bounding_box(coordmap, shape), ([0., 9.], [0, 13], [0, 15]))