Debian Codegraph @

tests/test_argyll_rgb2xyz.py

raw
1 import pytest
2
3 from DisplayCAL.argyll_rgb2xyz import rgb2xyz, xyz2rgb
4
5
6 @pytest.mark.parametrize("colorspace", ("RGB", "XYZ"))
7 def test_agryll_colorspace_conversion(colorspace: str) -> None:
8 """Test value conversion between RGB and XYZ colorspace."""
9 for RGB, XYZ in iter(
10 (
11 ((1.0, 1.0, 1.0), (0.951065, 1.000000, 1.088440)),
12 ((0.0, 0.0, 0.0), (0.010000, 0.010000, 0.010000)),
13 ((0.5, 0.0, 0.0), (0.097393, 0.055060, 0.014095)),
14 ((1.0, 0.0, 0.0), (0.418302, 0.220522, 0.029132)),
15 ((0.0, 0.5, 0.0), (0.085782, 0.161542, 0.035261)),
16 ((0.5, 0.5, 0.0), (0.173175, 0.206603, 0.039356)),
17 ((1.0, 0.5, 0.0), (0.494083, 0.372064, 0.054393)),
18 ((0.0, 1.0, 0.0), (0.364052, 0.718005, 0.128018)),
19 ((0.5, 1.0, 0.0), (0.451445, 0.763065, 0.132113)),
20 ((1.0, 1.0, 0.0), (0.772354, 0.928527, 0.147151)),
21 ((0.0, 0.0, 0.5), (0.048252, 0.025298, 0.211475)),
22 ((0.5, 0.0, 0.5), (0.135645, 0.070358, 0.215570)),
23 ((1.0, 0.0, 0.5), (0.456553, 0.235820, 0.230607)),
24 ((0.0, 0.5, 0.5), (0.124033, 0.176840, 0.236735)),
25 ((0.5, 0.5, 0.5), (0.211427, 0.221901, 0.240831)),
26 ((1.0, 0.5, 0.5), (0.532335, 0.387362, 0.255868)),
27 ((0.0, 1.0, 0.5), (0.402304, 0.733303, 0.329493)),
28 ((0.5, 1.0, 0.5), (0.489697, 0.778364, 0.333588)),
29 ((1.0, 1.0, 0.5), (0.810605, 0.943825, 0.348625)),
30 ((0.0, 0.0, 1.0), (0.188711, 0.081473, 0.951290)),
31 ((0.5, 0.0, 1.0), (0.276104, 0.126533, 0.955385)),
32 ((1.0, 0.0, 1.0), (0.597013, 0.291995, 0.970422)),
33 ((0.0, 0.5, 1.0), (0.264493, 0.233015, 0.976550)),
34 ((0.5, 0.5, 1.0), (0.351886, 0.278076, 0.980645)),
35 ((1.0, 0.5, 1.0), (0.672794, 0.443537, 0.995683)),
36 ((0.0, 1.0, 1.0), (0.542763, 0.789478, 1.069308)),
37 ((0.5, 1.0, 1.0), (0.630157, 0.834539, 1.073403)),
38 )
39 ):
40 if colorspace == "RGB":
41 conversion = tuple(str(round(c, 6)) for c in rgb2xyz(*RGB))
42 result = tuple(str(c) for c in XYZ)
43 else:
44 conversion = tuple(str(round(c, 1)) for c in xyz2rgb(*XYZ))
45 result = tuple(str(c) for c in RGB)
46 assert conversion == result