def test_from_numpy_array(self): """ Test init image from different formats with validation """ colorToNdArrayMap = self.generateColorToArrayMap() for color, ndarray in colorToNdArrayMap.items(): with self.subTest(color=color.name): img = VLImage.fromNumpyArray(ndarray, color) assert color == img.format, img.format
def test_zero_numpy_array(self): """ Test image validation with a zero array: (0, 0, 0), (0, 0, 0), (0, 0, 0) (0, 0, 0), (0, 0, 0), (0, 0, 0) (0, 0, 0), (0, 0, 0), (0, 0, 0) """ zeroArray = np.zeros(shape=(3, 3, 3)) blackImage = VLImage.fromNumpyArray(arr=zeroArray, inputColorFormat="RGB", filename="array") assert blackImage.isValid() self.checkRectAttr(blackImage.rect)
def getColorToImageMap() -> Dict[ColorFormat, VLImage]: """ Get images as vl image in all available color formats. Returns: color format to vl image map """ return { color: VLImage.fromNumpyArray(ndarray, color) for color, ndarray in BaseTestClass.generateColorToArrayMap().items() }