Beispiel #1
0
    def test_array_to_image_bad_channels(self):
        array = np.empty((64, 32, 2), dtype='uint8')
        array[:, :, 0] = 0x44
        array[:, :, 1] = 0x88

        with self.assertRaises(ValueError):
            array_to_image(array)
Beispiel #2
0
    def test_array_to_image_rgb(self):
        array = np.empty((64, 32, 3), dtype='uint8')
        array[:, :, 0] = 0x44
        array[:, :, 1] = 0x88
        array[:, :, 2] = 0xcc

        wximage = array_to_image(array)

        self.assertEqual(wximage.GetWidth(), 32)
        self.assertEqual(wximage.GetHeight(), 64)
        self.assertFalse(wximage.HasAlpha())
Beispiel #3
0
    def test_array_to_image_rgb(self):
        array = np.empty((64, 32, 3), dtype='uint8')
        array[:, :, 0] = 0x44
        array[:, :, 1] = 0x88
        array[:, :, 2] = 0xcc

        qimage = array_to_image(array)

        self.assertEqual(qimage.width(), 32)
        self.assertEqual(qimage.height(), 64)
        self.assertEqual(qimage.format(), QImage.Format.Format_RGB32)
        self.assertTrue(all(
            qimage.pixel(i, j) == 0xff4488cc
            for i in range(32) for j in range(64)
        ))
Beispiel #4
0
 def test_column_header_attribute_updated_empty(self):
     self.model.data = np.empty((2, 4, 0), dtype='int')
     with self.assertTraitDoesNotChange(self.model, "values_changed"):
         self.model.column_header_type.format = str
Beispiel #5
0
 def test_row_header_type_updated_empty(self):
     self.model.data = np.empty((0, 4, 2), dtype='int')
     with self.assertTraitDoesNotChange(self.model, "values_changed"):
         self.model.row_header_type = no_value
Beispiel #6
0
 def test_type_attribute_updated_empty(self):
     self.model.data = np.empty((0, 0, 0), dtype='int')
     with self.assertTraitDoesNotChange(self.model, "values_changed"):
         self.model.value_type.is_editable = False
Beispiel #7
0
 def test_type_updated_empty(self):
     self.model.data = np.empty((0, 0, 0), dtype='int')
     with self.assertTraitDoesNotChange(self.model, "values_changed"):
         self.model.value_type = IntValue()