def test_empty_image(): image = Image() assert image.image_data is None assert image.image_rgba is None assert image.get_clim() == (None, None) with pytest.raises(RuntimeError): image.set_clim(0, 100) with pytest.raises(RuntimeError): image.set_clim(0, 100) with pytest.raises(RuntimeError): image.set_cmap("turbo") with pytest.raises(RuntimeError): image.set_norm(1)
def test_mpl_norm(): mplcolor = pytest.importorskip("matplotlib.colors") # 2D uint8 image = Image() data = np.random.randint(0, 255, (60, 60)).astype("uint8") image.set_data(data) rendered = image.image_rgba assert isinstance(rendered, np.ndarray) assert rendered.shape == (60, 60, 4) image.set_norm(mplcolor.PowerNorm(0.5)) rendered2 = image.image_rgba assert isinstance(rendered2, np.ndarray) assert rendered2.shape == (60, 60, 4) assert not np.allclose(rendered, rendered2)