示例#1
0
def test_clim():

    # 2D uint8
    image = Image()
    image.value = np.random.rand(60, 60)
    rendered = image.image_rgba
    assert isinstance(rendered, np.ndarray)
    assert rendered.shape == (60, 60, 4)
    image.set_clim(0.5, 0.7)
    rendered2 = image.image_rgba
    assert not np.allclose(rendered, rendered2)
    assert image.get_clim() == (0.5, 0.7)
示例#2
0
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)