Beispiel #1
0
    def setUp(self):
        self.data = np.empty(shape=(128, 256, 4), dtype='uint8')
        self.data[:, :, 0] = np.arange(256)
        self.data[:, :, 1] = np.arange(128)[:, np.newaxis]
        self.data[:, :, 2] = np.arange(256)[::-1]
        self.data[:, :, 3] = np.arange(128)[::-1, np.newaxis]

        self.image_24 = Image(self.data[..., :3])
        self.image_32 = Image(self.data)
Beispiel #2
0
 def test_bounds_overrride(self):
     image = Image(self.data, bounds=[200, 100])
     self.assertEqual(image.bounds, [200, 100])
Beispiel #3
0
 def test_init_bad_dtype(self):
     data = np.array(['red'] * 65536).reshape(128, 128, 4)
     with self.assertRaises(TraitError):
         Image(data=data)
Beispiel #4
0
 def test_init_bad_shape(self):
     data = np.zeros(shape=(256, 256), dtype='uint8')
     with self.assertRaises(TraitError):
         Image(data=data)