예제 #1
0
def test_saturation():
    rgb = _make_array(0.392156, 0.776470, 0.164705)
    saturated = _make_array(0.3425, 0.78372, 0.0)
    assert np.allclose(saturate_rgb(rgb, 1.1), saturated, atol=0.2)

    rgb = _make_array(0.0392, 0.1960, 0.3529)
    saturated = _make_array(0.0456, 0.1929, 0.3941)
    assert np.allclose(saturate_rgb(rgb, 1.25), saturated, atol=0.2)
예제 #2
0
def test_bad_array_type():
    bad = np.random.random((3, 3, 3)).astype("uint8")
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert "dtype mismatch" in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert "dtype mismatch" in str(exc.value)
예제 #3
0
def test_bad_array_dims():
    bad = np.random.random((3, 3))
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert "wrong number of dimensions" in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert "wrong number of dimensions" in str(exc.value)
예제 #4
0
def test_bad_array_bands():
    bad = np.random.random((2, 3, 3))
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert "3 bands" in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert "3 bands" in str(exc.value)
예제 #5
0
def test_bad_array_type():
    bad = np.random.random((3, 3, 3)).astype('uint8')
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert 'dtype mismatch' in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert 'dtype mismatch' in str(exc.value)
예제 #6
0
def test_bad_array_dims():
    bad = np.random.random((3, 3))
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert 'wrong number of dimensions' in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert 'wrong number of dimensions' in str(exc.value)
예제 #7
0
def test_bad_array_bands():
    bad = np.random.random((2, 3, 3))
    with pytest.raises(ValueError) as exc:
        saturate_rgb(bad, 1.1)
    assert '3 bands' in str(exc.value)

    with pytest.raises(ValueError) as exc:
        convert_arr(bad, cs.rgb, cs.lch)
    assert '3 bands' in str(exc.value)
예제 #8
0
def test_saturation():
    rgb = _make_array(0.392156, 0.776470, 0.164705)
    saturated = _make_array(0.3425, 0.78372, 0.0)
    assert np.allclose(
        saturate_rgb(rgb, 1.1),
        saturated,
        atol=0.2)

    rgb = _make_array(0.0392, 0.1960, 0.3529)
    saturated = _make_array(0.0456, 0.1929, 0.3941)
    assert np.allclose(
        saturate_rgb(rgb, 1.25),
        saturated,
        atol=0.2)
예제 #9
0
def test_saturation_bw():
    rgb = _make_array(0.392156, 0.776470, 0.164705)
    sat = saturate_rgb(rgb, 0.0)
    assert _near((sat[0, 0, 0], ), (sat[1, 0, 0], ), tol=0.1)
    assert _near((sat[1, 0, 0], ), (sat[2, 0, 0], ), tol=0.1)
예제 #10
0
def test_saturation_1(pair):
    rgb, lch = pair
    rgb = _make_array(*rgb)
    assert np.allclose(saturate_rgb(rgb, 1.0), rgb, atol=0.2)
예제 #11
0
def test_saturation_bw():
    rgb = _make_array(0.392156, 0.776470, 0.164705)
    sat = saturate_rgb(rgb, 0.0)
    assert _near((sat[0, 0, 0], ), (sat[1, 0, 0], ), tol=0.1)
    assert _near((sat[1, 0, 0], ), (sat[2, 0, 0], ), tol=0.1)
예제 #12
0
def test_saturation_1(pair):
    rgb, lch = pair
    rgb = _make_array(*rgb)
    assert np.allclose(
        saturate_rgb(rgb, 1.0), rgb, atol=0.2)