From 8d9b79d00f3e4bd49bb0c37999f5d5f518a26df9 Mon Sep 17 00:00:00 2001 From: TJDCS Date: Fri, 3 Jan 2025 14:15:19 -0800 Subject: [PATCH 1/2] add default arguments to `sd_reference_illuminant` `shape` --- colour/quality/cfi2017.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index f9d271cea..8fcb84e1c 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -42,7 +42,8 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, List, Literal, Tuple -from colour.hints import NDArrayFloat, cast +from colour.colorimetry.spectrum import SPECTRAL_SHAPE_DEFAULT +from colour.hints import ArrayLike, List, NDArrayFloat, Tuple, cast from colour.models import JMh_CIECAM02_to_CAM02UCS, UCS_to_uv, XYZ_to_UCS from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Ohno2013 from colour.utilities import ( @@ -66,16 +67,16 @@ __status__ = "Production" __all__ = [ - "SPECTRAL_SHAPE_CIE2017", "ROOT_RESOURCES_CIE2017", - "DataColorimetry_TCS_CIE2017", + "SPECTRAL_SHAPE_CIE2017", + "CCT_reference_illuminant", "ColourRendering_Specification_CIE2017", + "DataColorimetry_TCS_CIE2017", "colour_fidelity_index_CIE2017", + "delta_E_to_R_f", "load_TCS_CIE2017", - "CCT_reference_illuminant", "sd_reference_illuminant", "tcs_colorimetry_data", - "delta_E_to_R_f", ] SPECTRAL_SHAPE_CIE2017: SpectralShape = SpectralShape(380, 780, 1) @@ -346,7 +347,9 @@ def CCT_reference_illuminant(sd: SpectralDistribution) -> NDArrayFloat: return uv_to_CCT_Ohno2013(UCS_to_uv(XYZ_to_UCS(XYZ)), start=1000, end=25000) -def sd_reference_illuminant(CCT: float, shape: SpectralShape) -> SpectralDistribution: +def sd_reference_illuminant( + CCT: float, shape: SpectralShape = SPECTRAL_SHAPE_DEFAULT +) -> SpectralDistribution: """ Compute the reference illuminant for a given correlated colour temperature :math:`T_{cp}` for use in *CIE 2017 Colour Fidelity Index* (CFI) @@ -357,7 +360,8 @@ def sd_reference_illuminant(CCT: float, shape: SpectralShape) -> SpectralDistrib CCT Correlated colour temperature :math:`T_{cp}`. shape - Desired shape of the returned spectral distribution. + Desired shape of the returned spectral distribution. Defaults to + SPECTRAL_SHAPE_DEFAULT Returns ------- From 1a49fff988ade674ef4f70ecd119dc7561aa0df6 Mon Sep 17 00:00:00 2001 From: TJDCS Date: Fri, 3 Jan 2025 14:38:10 -0800 Subject: [PATCH 2/2] test default sd_reference_illum shape --- colour/quality/tests/test_cfi2017.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/colour/quality/tests/test_cfi2017.py b/colour/quality/tests/test_cfi2017.py index 347b458ae..b62bd5b35 100644 --- a/colour/quality/tests/test_cfi2017.py +++ b/colour/quality/tests/test_cfi2017.py @@ -19,6 +19,7 @@ reshape_sd, sd_blackbody, ) +from colour.colorimetry.spectrum import SPECTRAL_SHAPE_DEFAULT from colour.quality.cfi2017 import ( CCT_reference_illuminant, colour_fidelity_index_CIE2017, @@ -924,6 +925,14 @@ class TestSdReferenceIlluminant: definition unit tests methods. """ + def test_default_args(self) -> None: + """Test :func:`color.quality.CIE2017.sd_reference_illuminant` for + default shape argument. + """ + + sd = sd_reference_illuminant(5421) + assert sd.shape == SPECTRAL_SHAPE_DEFAULT + def test_sd_reference_illuminant(self) -> None: """ Test :func:`colour.quality.CIE2017.sd_reference_illuminant`