Coverage for colorimetry/tests/test_correction.py: 100%
17 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.colorimetry.correction` module."""
3from __future__ import annotations
5import numpy as np
7from colour.colorimetry import SpectralDistribution, bandpass_correction_Stearns1988
8from colour.constants import TOLERANCE_ABSOLUTE_TESTS
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 "DATA_NON_BANDPASS_CORRECTED",
19 "DATA_BANDPASS_CORRECTED",
20 "TestBandpassCorrectionStearns1988",
21]
23DATA_NON_BANDPASS_CORRECTED: tuple = (
24 9.3700,
25 12.3200,
26 12.4600,
27 9.5100,
28 5.9200,
29 4.3300,
30 4.2900,
31 3.8800,
32 4.5100,
33 10.9200,
34 27.5000,
35 49.6700,
36 69.5900,
37 81.7300,
38 88.1900,
39 86.0500,
40)
42DATA_BANDPASS_CORRECTED: tuple = (
43 9.12515000,
44 12.57355255,
45 12.69542514,
46 9.54357971,
47 5.75121288,
48 4.21535933,
49 4.33022518,
50 3.79034131,
51 4.03770167,
52 10.11509076,
53 27.10283747,
54 49.88971449,
55 70.21750370,
56 82.14935719,
57 88.88373581,
58 85.87238000,
59)
62class TestBandpassCorrectionStearns1988:
63 """
64 Define :func:`colour.colorimetry.correction.\
65bandpass_correction_Stearns1988` definition unit tests methods.
66 """
68 def test_bandpass_correction_Stearns1988(self) -> None:
69 """
70 Test :func:`colour.colorimetry.correction.\
71bandpass_correction_Stearns1988` definition.
72 """
74 sd = SpectralDistribution(
75 dict(
76 zip(
77 range(len(DATA_NON_BANDPASS_CORRECTED)),
78 DATA_NON_BANDPASS_CORRECTED,
79 strict=True,
80 )
81 )
82 )
84 np.testing.assert_allclose(
85 bandpass_correction_Stearns1988(sd).values,
86 DATA_BANDPASS_CORRECTED,
87 atol=TOLERANCE_ABSOLUTE_TESTS,
88 )