Example #1
0
def test_max_lh_for_chroma():
    rgb_arr = _img()[:, 0]
    lch_arr = nphusl.rgb_to_lch(rgb_arr)
    with np.errstate(invalid="ignore"):
        mx_arr = nphusl._max_lh_chroma(lch_arr)
    arrays = zip(mx_arr, lch_arr, rgb_arr)
    for mx, lch, rgb in arrays:
        try:
            mx_old = husl.max_chroma_for_LH(float(lch[0]), float(lch[2]))
        except ZeroDivisionError:
            # NOTE: Divide by zero is avoided in nphusl.py
            # we're taking a backdoor here by using max_chroma_for_LH directly 
            assert np.isinf(mx)
        else:
            assert _diff(mx, mx_old)
Example #2
0
def test_max_lh_for_chroma():
    rgb_arr = _img()[:, 0]
    lch_arr = _nphusl._rgb_to_lch(rgb_arr)
    with np.errstate(invalid="ignore"):
        mx_arr = _nphusl._max_lh_chroma(lch_arr)
    arrays = zip(mx_arr, lch_arr, rgb_arr)
    for mx, lch, rgb in arrays:
        try:
            mx_old = husl.max_chroma_for_LH(float(lch[0]), float(lch[2]))
        except ZeroDivisionError:
            # NOTE: Divide by zero is avoided in nphusl.py
            # we're taking a backdoor here by using max_chroma_for_LH directly
            assert np.isinf(mx)
        else:
            _diff(mx, mx_old)
Example #3
0
def test_cython_max_chroma():
    from nphusl import _nphusl_cython
    husl_chroma = husl.max_chroma_for_LH(0.25, 40.0)
    cyth_chroma = _nphusl_cython._test_max_chroma(0.25, 40.0)
    assert abs(husl_chroma - cyth_chroma) < 0.001
Example #4
0
def test_cython_max_chroma():
    from nphusl import _cython_opt
    husl_chroma = husl.max_chroma_for_LH(0.25, 40.0)
    cyth_chroma = _cython_opt._test_max_chroma(0.25, 40.0)
    assert abs(husl_chroma - cyth_chroma) < 0.001