testing all conversions

This commit is contained in:
Martin Diehl 2020-06-27 18:55:27 +02:00
parent 234699bd18
commit cf63226721
1 changed files with 24 additions and 3 deletions

View File

@ -21,10 +21,14 @@ class TestColormap:
print('rgb',rgb) print('rgb',rgb)
# rgb2hsv2rgb # rgb2hsv2rgb
assert np.allclose(Colormap._hsv2rgb(Colormap._rgb2hsv(rgb)),rgb) hsv = Colormap._rgb2hsv(rgb)
print('hsv',hsv)
assert np.allclose(Colormap._hsv2rgb(hsv),rgb)
# rgb2hsl2rgb # rgb2hsl2rgb
assert np.allclose(Colormap._hsl2rgb(Colormap._rgb2hsl(rgb)),rgb) hsl = Colormap._rgb2hsl(rgb)
print('hsl',hsl)
assert np.allclose(Colormap._hsl2rgb(hsl),rgb)
# rgb2xyz2rgb # rgb2xyz2rgb
xyz = Colormap._rgb2xyz(rgb) xyz = Colormap._rgb2xyz(rgb)
@ -37,4 +41,21 @@ class TestColormap:
assert np.allclose(Colormap._lab2xyz(lab),xyz) assert np.allclose(Colormap._lab2xyz(lab),xyz)
# lab2msh2lab # lab2msh2lab
assert np.allclose(Colormap._msh2lab(Colormap._lab2msh(lab)),lab) msh = Colormap._lab2msh(lab)
print('msh',msh)
assert np.allclose(Colormap._msh2lab(msh),lab)
# lab2rgb2lab
assert np.allclose(Colormap._rgb2lab(Colormap._lab2rgb(lab)),lab,atol=1.e-6,rtol=0)
# rgb2msh2rgb
assert np.allclose(Colormap._msh2rgb(Colormap._rgb2msh(rgb)),rgb,atol=1.e-6,rtol=0)
# hsv2msh
assert np.allclose(Colormap._hsv2msh(hsv),msh,atol=1.e-6,rtol=0)
# hsl2msh
assert np.allclose(Colormap._hsv2msh(hsv),msh,atol=1.e-6,rtol=0)
# xyz2msh
assert np.allclose(Colormap._xyz2msh(xyz),msh,atol=1.e-6,rtol=0)