示例#1
0
    def test_read_slices(self):
        for _, d in slice_generator(self.img):
            self.assertEquals(d.shape, (20, 30))

        for _, d in slice_generator(self.img, axis=1):
            self.assertEquals(d.shape, (10, 30))

        for _, d in slice_generator(self.img, axis=2):
            self.assertEquals(d.shape, (10, 20))
示例#2
0
    def test_write_slices(self):
        tmp = np.zeros(self.img.shape)
        write_data(tmp, slice_generator(self.img))
        assert_almost_equal(tmp, np.asarray(self.img))

        tmp = np.zeros(self.img.shape)
        write_data(tmp, slice_generator(self.img, axis=1))
        assert_almost_equal(tmp, np.asarray(self.img))

        tmp = np.zeros(self.img.shape)
        write_data(tmp, slice_generator(self.img, axis=2))
        assert_almost_equal(tmp, np.asarray(self.img))
示例#3
0
 def test_multi_slice_write(self):
     a = np.zeros(self.img.shape)
     write_data(a, slice_generator(self.img, axis=[0, 1]))
     assert_almost_equal(a, np.asarray(self.img))
示例#4
0
    def test_multi_slice(self):
        for _, d in slice_generator(self.img, axis=[0, 1]):
            self.assertEquals(d.shape, (30,))

        for _, d in slice_generator(self.img, axis=[2, 1]):
            self.assertEquals(d.shape, (10,))