Coverage for models/tests/test_cam16_ucs.py: 100%
23 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-16 22:49 +1300
1"""Define the unit tests for the :mod:`colour.models.cam16_ucs` module."""
3from __future__ import annotations
5import numpy as np
7from colour.constants import TOLERANCE_ABSOLUTE_TESTS
8from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006
9from colour.models.cam16_ucs import (
10 UCS_Li2017_to_XYZ,
11 XYZ_to_UCS_Li2017,
12)
13from colour.models.tests.test_cam02_ucs import (
14 TestJMh_CIECAM02_to_UCS_Luo2006,
15 TestUCS_Luo2006_to_JMh_CIECAM02,
16 TestUCS_Luo2006_to_XYZ,
17 TestXYZ_to_UCS_Luo2006,
18)
20__author__ = "Colour Developers"
21__copyright__ = "Copyright 2013 Colour Developers"
22__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
23__maintainer__ = "Colour Developers"
24__email__ = "colour-developers@colour-science.org"
25__status__ = "Production"
27__all__ = [
28 "TestJMh_CAM16_to_UCS_Li2017",
29 "TestUCS_Li2017_to_JMh_CAM16",
30 "TestXYZ_to_UCS_Li2017",
31 "TestUCS_Li2017_to_XYZ",
32]
35class TestJMh_CAM16_to_UCS_Li2017(TestJMh_CIECAM02_to_UCS_Luo2006):
36 """
37 Define :func:`colour.models.cam16_ucs.JMh_CAM16_to_UCS_Li2017`
38 definition unit tests methods.
40 Notes
41 -----
42 - :func:`colour.models.cam16_ucs.JMh_CAM16_to_UCS_Li2017` is a wrapper
43 of :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` and thus
44 currently adopts the same unittests.
45 """
48class TestUCS_Li2017_to_JMh_CAM16(TestUCS_Luo2006_to_JMh_CIECAM02):
49 """
50 Define :func:`colour.models.cam16_ucs.UCS_Li2017_to_JMh_CAM16`
51 definition unit tests methods.
53 Notes
54 -----
55 - :func:`colour.models.cam16_ucs.UCS_Li2017_to_JMh_CAM16` is a wrapper
56 of :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` and thus
57 currently adopts the same unittests.
58 """
61class TestXYZ_to_UCS_Li2017(TestXYZ_to_UCS_Luo2006):
62 """
63 Define :func:`colour.models.cam16_ucs.XYZ_to_UCS_Li2017`
64 definition unit tests methods.
65 """
67 def test_XYZ_to_UCS_Li2017(self) -> None:
68 """Test :func:`colour.models.cam16_ucs.XYZ_to_UCS_Li2017` definition."""
70 np.testing.assert_allclose(
71 XYZ_to_UCS_Li2017(
72 np.array([0.20654008, 0.12197225, 0.05136952]),
73 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],
74 ),
75 np.array([46.06586033, 41.07586491, 14.51025826]),
76 atol=TOLERANCE_ABSOLUTE_TESTS,
77 )
79 np.testing.assert_allclose(
80 XYZ_to_UCS_Li2017(
81 np.array([0.20654008, 0.12197225, 0.05136952]),
82 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],
83 XYZ_w=np.array([0.95047, 1.0, 1.08883]),
84 ),
85 np.array([46.06573617, 41.07444159, 14.50807598]),
86 atol=TOLERANCE_ABSOLUTE_TESTS,
87 )
90class TestUCS_Li2017_to_XYZ(TestUCS_Luo2006_to_XYZ):
91 """
92 Define :func:`colour.models.cam16_ucs.UCS_Li2017_to_XYZ`
93 definition unit tests methods.
94 """
96 def test_UCS_Li2017_to_XYZ(self) -> None:
97 """Test :func:`colour.models.cam16_ucs.UCS_Li2017_to_XYZ` definition."""
99 np.testing.assert_allclose(
100 UCS_Li2017_to_XYZ(
101 np.array([46.06586033, 41.07586491, 14.51025826]),
102 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],
103 ),
104 np.array([0.20654008, 0.12197225, 0.05136952]),
105 atol=TOLERANCE_ABSOLUTE_TESTS,
106 )
108 np.testing.assert_allclose(
109 UCS_Li2017_to_XYZ(
110 np.array([46.06586033, 41.07586491, 14.51025826]),
111 COEFFICIENTS_UCS_LUO2006["CAM02-LCD"],
112 XYZ_w=np.array([0.95047, 1.0, 1.08883]),
113 ),
114 np.array([0.2065444, 0.12197263, 0.05136016]),
115 atol=TOLERANCE_ABSOLUTE_TESTS,
116 )