Coverage for temperature/tests/test__init__.py: 100%
22 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.temperature` module."""
3from __future__ import annotations
5import numpy as np
7from colour.constants import TOLERANCE_ABSOLUTE_TESTS
8from colour.temperature import CCT_to_xy, xy_to_CCT
10__author__ = "Colour Developers"
11__copyright__ = "Copyright 2013 Colour Developers"
12__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
13__maintainer__ = "Colour Developers"
14__email__ = "colour-developers@colour-science.org"
15__status__ = "Production"
17__all__ = [
18 "TestXy_to_CCT",
19 "TestCCT_to_xy",
20]
23class TestXy_to_CCT:
24 """
25 Define :func:`colour.temperature.xy_to_CCT` definition unit tests methods.
26 """
28 def test_xy_to_CCT(self) -> None:
29 """Test :func:`colour.temperature.xy_to_CCT` definition."""
31 xy = np.array([0.31270, 0.32900])
33 # Test default method (CIE Illuminant D Series)
34 np.testing.assert_allclose(
35 xy_to_CCT(xy),
36 6508.1175148,
37 atol=0.01,
38 )
40 # Test Hernandez 1999 method
41 np.testing.assert_allclose(
42 xy_to_CCT(xy, "Hernandez 1999"),
43 6500.7420431,
44 atol=0.01,
45 )
47 # Test McCamy 1992 method
48 np.testing.assert_allclose(
49 xy_to_CCT(xy, "McCamy 1992"),
50 6505.08059131,
51 atol=0.01,
52 )
55class TestCCT_to_xy:
56 """
57 Define :func:`colour.temperature.CCT_to_xy` definition unit tests methods.
58 """
60 def test_CCT_to_xy(self) -> None:
61 """Test :func:`colour.temperature.CCT_to_xy` definition."""
63 # Test default method (CIE Illuminant D Series)
64 np.testing.assert_allclose(
65 CCT_to_xy(6500),
66 np.array([0.31277888, 0.3291835]),
67 atol=TOLERANCE_ABSOLUTE_TESTS,
68 )
70 # Test explicit CIE Illuminant D Series method
71 np.testing.assert_allclose(
72 CCT_to_xy(6500, method="CIE Illuminant D Series"),
73 np.array([0.31277888, 0.3291835]),
74 atol=TOLERANCE_ABSOLUTE_TESTS,
75 )
77 # Test Hernandez 1999 method
78 np.testing.assert_allclose(
79 CCT_to_xy(6500, "Hernandez 1999"),
80 np.array([0.31191663, 0.33419]),
81 atol=TOLERANCE_ABSOLUTE_TESTS,
82 )