Beispiel #1
0
def test_affine_identity():
    aff = Affine.identity('ijk')
    yield assert_equal, aff.affine, np.eye(4)
    yield assert_equal, aff.input_coords, aff.output_coords
    x = np.array([3, 4, 5])
    y = aff.mapping(x)
    yield assert_equal, y, x
Beispiel #2
0
    def test_box_slice(self):
        coordmap = Affine.identity(names)
        t = zslice(5, [0, 9], [0, 9], coordmap.output_coords, (10,10))
        assert_almost_equal(t.coordmap.affine, [[ 0.,  0.,  5.],
                                                [ 1.,  0.,  0.],
                                                [ 0.,  1.,  0.],
                                                [ 0.,  0.,  1.]])
        

        t = yslice(4, [0, 9], [0, 9], coordmap.output_coords, (10,10))
        assert_almost_equal(t.coordmap.affine, [[ 1.,  0.,  0.],
                                                [ 0.,  0.,  4.],
                                                [ 0.,  1.,  0.],
                                                [ 0.,  0.,  1.]])
        
        t = xslice(3, [0, 9], [0, 9], coordmap.output_coords, (10,10))
        assert_almost_equal(t.coordmap.affine, [[ 1.,  0.,  0.],
                                                [ 0.,  1.,  0.],
                                                [ 0.,  0.,  3.],
                                                [ 0.,  0.,  1.]])
Beispiel #3
0
def setup():
    def f(x):
        return 2*x
    def g(x):
        return x/2.0
    x = CoordinateSystem('x', 'x')
    E.a = CoordinateMap(f, x, x)
    E.b = CoordinateMap(f, x, x, inverse_mapping=g)
    E.c = CoordinateMap(g, x, x)        
    E.d = CoordinateMap(g, x, x, inverse_mapping=f)        
    E.e = Affine.identity('ijk')

    A = np.identity(4)
    A[0:3] = np.random.standard_normal((3,4))
    E.mapping = Affine.from_params('ijk' ,'xyz', A)
    
    E.singular = Affine.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]]))
Beispiel #4
0
 def test_bounding_box(self):
     shape = (10, 10, 10)
     coordmap = Affine.identity(names)
     #print coordmap.affine.dtype, 'affine'
     self.assertEqual(bounding_box(coordmap, shape), [[0., 9.], [0, 9], [0, 9]])