From 268b4cea9a708a03b2c8730163e25f8ea6af6ad5 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 17:16:57 +1300 Subject: [PATCH 01/42] Update `requirements.txt` file. --- docs/requirements.txt | 42 +++++++------- requirements.txt | 132 +++++++++++++++++++++--------------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 4706e4d1e..95909bac4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -5,44 +5,44 @@ alabaster==1.0.0 babel==2.16.0 beautifulsoup4==4.12.3 biblib-simple==0.1.2 -certifi==2024.8.30 +certifi==2024.12.14 charset-normalizer==3.4.0 -colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows' -contourpy==1.3.0 +colorama==0.4.6 ; sys_platform == 'win32' +contourpy==1.3.1 cycler==0.12.1 docutils==0.21.2 -fonttools==4.54.1 +fonttools==4.55.3 idna==3.10 -imageio==2.35.1 +imageio==2.36.1 imagesize==1.4.1 jinja2==3.1.4 kiwisolver==1.4.7 latexcodec==3.0.0 -markupsafe==3.0.1 -matplotlib==3.9.2 -networkx==3.4 -numpy==2.1.2 -opencolorio==2.4.0 -packaging==24.1 +markupsafe==3.0.2 +matplotlib==3.10.0 +networkx==3.4.2 +numpy==2.2.0 +opencolorio==2.4.1 +packaging==24.2 pandas==2.2.3 -pillow==10.4.0 +pillow==11.0.0 pybtex==0.24.0 pybtex-docutils==1.0.3 -pydata-sphinx-theme==0.15.4 -pydot==3.0.2 +pydata-sphinx-theme==0.16.1 +pydot==3.0.3 pygments==2.18.0 -pyparsing==3.1.4 +pyparsing==3.2.0 python-dateutil==2.9.0.post0 pytz==2024.2 pyyaml==6.0.2 requests==2.32.3 restructuredtext-lint==1.4.0 scipy==1.14.1 -setuptools==75.1.0 ; python_full_version >= '3.12' -six==1.16.0 +setuptools==75.6.0 ; python_full_version >= '3.12' +six==1.17.0 snowballstemmer==2.2.0 soupsieve==2.6 -sphinx==8.1.0 +sphinx==8.1.3 sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.3 sphinxcontrib-devhelp==2.0.0 @@ -50,9 +50,9 @@ sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==2.0.0 sphinxcontrib-serializinghtml==2.0.0 -tomli==2.0.2 ; python_full_version < '3.11' -tqdm==4.66.5 -trimesh==4.4.9 +tomli==2.2.1 ; python_full_version < '3.11' +tqdm==4.67.1 +trimesh==4.5.3 typing-extensions==4.12.2 tzdata==2024.2 urllib3==2.2.3 diff --git a/requirements.txt b/requirements.txt index a32822dcc..deb8cb848 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,32 +2,32 @@ # uv export --no-hashes --all-extras accessible-pygments==0.0.5 alabaster==1.0.0 -anyio==4.6.0 -appnope==0.1.4 ; platform_system == 'Darwin' +anyio==4.7.0 +appnope==0.1.4 ; sys_platform == 'darwin' argon2-cffi==23.1.0 argon2-cffi-bindings==21.2.0 arrow==1.3.0 -asttokens==2.4.1 +asttokens==3.0.0 async-lru==2.0.4 -attrs==24.2.0 +attrs==24.3.0 babel==2.16.0 backports-tarfile==1.2.0 ; python_full_version < '3.12' beautifulsoup4==4.12.3 biblib-simple==0.1.2 -bleach==6.1.0 -certifi==2024.8.30 +bleach==6.2.0 +certifi==2024.12.14 cffi==1.17.1 cfgv==3.4.0 charset-normalizer==3.4.0 click==8.1.7 -colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows' +colorama==0.4.6 ; sys_platform == 'win32' comm==0.2.2 -contourpy==1.3.0 -coverage==7.6.2 +contourpy==1.3.1 +coverage==7.6.9 coveralls==4.0.1 -cryptography==43.0.1 ; sys_platform == 'linux' +cryptography==44.0.0 ; sys_platform == 'linux' cycler==0.12.1 -debugpy==1.8.7 +debugpy==1.8.11 decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.9 @@ -36,34 +36,34 @@ docutils==0.21.2 exceptiongroup==1.2.2 ; python_full_version < '3.11' execnet==2.1.1 executing==2.1.0 -fastjsonschema==2.20.0 +fastjsonschema==2.21.1 filelock==3.16.1 -fonttools==4.54.1 +fonttools==4.55.3 fqdn==1.5.1 h11==0.14.0 -hatch==1.12.0 -hatchling==1.25.0 -httpcore==1.0.6 -httpx==0.27.2 +hatch==1.14.0 +hatchling==1.27.0 +httpcore==1.0.7 +httpx==0.28.1 hyperlink==21.0.0 -identify==2.6.1 +identify==2.6.3 idna==3.10 -imageio==2.35.1 +imageio==2.36.1 imagesize==1.4.1 -importlib-metadata==8.5.0 +importlib-metadata==8.5.0 ; python_full_version < '3.12' iniconfig==2.0.0 invoke==2.2.0 ipykernel==6.29.5 -ipython==8.28.0 +ipython==8.31.0 ipywidgets==8.1.5 isoduration==20.11.0 jaraco-classes==3.4.0 jaraco-context==6.0.1 jaraco-functools==4.1.0 -jedi==0.19.1 +jedi==0.19.2 jeepney==0.8.0 ; sys_platform == 'linux' jinja2==3.1.4 -json5==0.9.25 +json5==0.10.0 jsonpointer==3.0.0 jsonschema==4.23.0 jsonschema-specifications==2024.10.1 @@ -71,69 +71,69 @@ jupyter==1.1.1 jupyter-client==8.6.3 jupyter-console==6.6.3 jupyter-core==5.7.2 -jupyter-events==0.10.0 +jupyter-events==0.11.0 jupyter-lsp==2.2.5 -jupyter-server==2.14.2 +jupyter-server==2.15.0 jupyter-server-terminals==0.5.3 -jupyterlab==4.2.5 +jupyterlab==4.3.4 jupyterlab-pygments==0.3.0 jupyterlab-server==2.27.3 jupyterlab-widgets==3.0.13 -keyring==25.4.1 +keyring==25.5.0 kiwisolver==1.4.7 latexcodec==3.0.0 markdown-it-py==3.0.0 -markupsafe==3.0.1 -matplotlib==3.9.2 +markupsafe==3.0.2 +matplotlib==3.10.0 matplotlib-inline==0.1.7 mdurl==0.1.2 mistune==3.0.2 more-itertools==10.5.0 -nbclient==0.10.0 +nbclient==0.10.2 nbconvert==7.16.4 nbformat==5.10.4 nest-asyncio==1.6.0 -networkx==3.4 -nh3==0.2.18 +networkx==3.4.2 +nh3==0.2.20 nodeenv==1.9.1 -notebook==7.2.2 +notebook==7.3.1 notebook-shim==0.2.4 -numpy==2.1.2 -opencolorio==2.4.0 +numpy==2.2.0 +opencolorio==2.4.1 overrides==7.7.0 -packaging==24.1 +packaging==24.2 pandas==2.2.3 pandocfilters==1.5.1 parso==0.8.4 pathspec==0.12.1 pexpect==4.9.0 -pillow==10.4.0 -pkginfo==1.10.0 +pillow==11.0.0 +pkginfo==1.12.0 platformdirs==4.3.6 pluggy==1.5.0 pre-commit==4.0.1 -prometheus-client==0.21.0 +prometheus-client==0.21.1 prompt-toolkit==3.0.48 -psutil==6.0.0 +psutil==6.1.1 ptyprocess==0.7.0 pure-eval==0.2.3 pybtex==0.24.0 pybtex-docutils==1.0.3 pycparser==2.22 -pydata-sphinx-theme==0.15.4 -pydot==3.0.2 +pydata-sphinx-theme==0.16.1 +pydot==3.0.3 pygments==2.18.0 -pyparsing==3.1.4 -pyright==1.1.384 -pytest==8.3.3 -pytest-cov==5.0.0 +pyparsing==3.2.0 +pyright==1.1.391 +pytest==8.3.4 +pytest-cov==6.0.0 pytest-xdist==3.6.1 python-dateutil==2.9.0.post0 -python-json-logger==2.0.7 +python-json-logger==3.2.1 pytz==2024.2 -pywin32==307 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32' +pywin32==308 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32' pywin32-ctypes==0.2.3 ; sys_platform == 'win32' -pywinpty==2.0.13 ; os_name == 'nt' +pywinpty==2.0.14 ; os_name == 'nt' pyyaml==6.0.2 pyzmq==26.2.0 readme-renderer==44.0 @@ -144,18 +144,18 @@ restructuredtext-lint==1.4.0 rfc3339-validator==0.1.4 rfc3986==2.0.0 rfc3986-validator==0.1.1 -rich==13.9.2 -rpds-py==0.20.0 +rich==13.9.4 +rpds-py==0.22.3 scipy==1.14.1 secretstorage==3.3.3 ; sys_platform == 'linux' send2trash==1.8.3 -setuptools==75.1.0 +setuptools==75.6.0 shellingham==1.5.4 -six==1.16.0 +six==1.17.0 sniffio==1.3.1 snowballstemmer==2.2.0 soupsieve==2.6 -sphinx==8.1.0 +sphinx==8.1.3 sphinxcontrib-applehelp==2.0.0 sphinxcontrib-bibtex==2.6.3 sphinxcontrib-devhelp==2.0.0 @@ -165,30 +165,30 @@ sphinxcontrib-qthelp==2.0.0 sphinxcontrib-serializinghtml==2.0.0 stack-data==0.6.3 terminado==0.18.1 -tinycss2==1.3.0 +tinycss2==1.4.0 toml==0.10.2 -tomli==2.0.2 ; python_full_version <= '3.11' +tomli==2.2.1 ; python_full_version <= '3.11' tomli-w==1.1.0 tomlkit==0.13.2 -tornado==6.4.1 -tqdm==4.66.5 +tornado==6.4.2 +tqdm==4.67.1 traitlets==5.14.3 -trimesh==4.4.9 -trove-classifiers==2024.9.12 -twine==5.1.1 -types-python-dateutil==2.9.0.20241003 +trimesh==4.5.3 +trove-classifiers==2024.10.21.16 +twine==6.0.1 +types-python-dateutil==2.9.0.20241206 typing-extensions==4.12.2 tzdata==2024.2 uri-template==1.3.0 urllib3==2.2.3 userpath==1.9.2 -uv==0.4.20 -virtualenv==20.26.6 +uv==0.5.11 +virtualenv==20.28.0 wcwidth==0.2.13 -webcolors==24.8.0 +webcolors==24.11.1 webencodings==0.5.1 websocket-client==1.8.0 widgetsnbextension==4.0.13 xxhash==3.5.0 -zipp==3.20.2 +zipp==3.21.0 ; python_full_version < '3.12' zstandard==0.23.0 From 8bbeaa8e64e2f411cf10e4b49c9d71e853828b85 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 12:18:39 +1300 Subject: [PATCH 02/42] Fix incorrect if clause in `colour.utilities.verbose.show_warning` definition. --- colour/utilities/verbose.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index edd710beb..082cf5b2e 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -267,7 +267,8 @@ def show_warning( frame_range = (1, None) - file = file if file is None else sys.stderr + file = sys.stderr if file is None else file + if file is None: return @@ -289,7 +290,6 @@ def show_warning( frame_in -= 1 traceback.print_stack(frame, frame_out, file) - file.write(formatwarning(message, category, filename, lineno, line)) except (OSError, UnicodeError): pass From 09454164a53acce5101d98e8bdfbc074da2ee541 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 17:36:13 +1300 Subject: [PATCH 03/42] Remove unused warning in `colour.characterisation.aces_it` module. --- colour/characterisation/aces_it.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 724f3a237..07fa32db3 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -116,7 +116,6 @@ ones, optional, runtime_warning, - suppress_warnings, tsplit, zeros, ) @@ -392,13 +391,10 @@ def generate_illuminants_rawtoaces_v1() -> CanonicalMapping: sd.name = f"D{int(CCT / 100):d}" illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES) - # TODO: Remove when removing the "colour.sd_blackbody" definition - # warning. - with suppress_warnings(colour_usage_warnings=True): - # Blackbody from 1000K to 4000K. - for i in np.arange(1000, 4000, 500): - sd = sd_blackbody(i, SPECTRAL_SHAPE_RAWTOACES) - illuminants[sd.name] = sd + # Blackbody from 1000K to 4000K. + for i in np.arange(1000, 4000, 500): + sd = sd_blackbody(i, SPECTRAL_SHAPE_RAWTOACES) + illuminants[sd.name] = sd # A.M.P.A.S. variant of ISO 7589 Studio Tungsten. sd = read_sds_from_csv_file( From 16befc159890353537fcbdd065f46051df0319a4 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 20:30:12 +1300 Subject: [PATCH 04/42] Update `README.rst` file. --- README.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.rst b/README.rst index 29d541ddc..2a2216e8b 100644 --- a/README.rst +++ b/README.rst @@ -1827,17 +1827,17 @@ Reflectance Recovery .. code-block:: text -SpectralDistribution([[ 3.60000000e+02, 8.52694330e-02], - [ 3.65000000e+02, 8.52203359e-02], - [ 3.70000000e+02, 8.52841304e-02], - ... - [ 7.70000000e+02, 4.46546872e-01], - [ 7.75000000e+02, 4.46638451e-01], - [ 7.80000000e+02, 4.46641739e-01]], - SpragueInterpolator, - {}, - Extrapolator, - {'method': 'Constant', 'left': None, 'right': None}) + SpectralDistribution([[ 3.60000000e+02, 8.52694330e-02], + [ 3.65000000e+02, 8.52203359e-02], + [ 3.70000000e+02, 8.52841304e-02], + ... + [ 7.70000000e+02, 4.46546872e-01], + [ 7.75000000e+02, 4.46638451e-01], + [ 7.80000000e+02, 4.46641739e-01]], + SpragueInterpolator, + {}, + Extrapolator, + {'method': 'Constant', 'left': None, 'right': None}) .. code-block:: python From 994043d2cb26f3a71ab96d0bffa2a3208aa9c294 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:34:39 +1300 Subject: [PATCH 05/42] Enable all *Ruff* fixes. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a678f5306..a13d52a47 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -227,7 +227,6 @@ ignore = [ "UP038", ] typing-modules = ["colour.hints"] -fixable = ["B", "C", "E", "F", "PIE", "RUF", "SIM", "UP", "W"] [tool.ruff.pydocstyle] convention = "numpy" From 3f130e2948147fc747aa48ab6b4f83fde75dd4ea Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 20:33:15 +1300 Subject: [PATCH 06/42] Enable `ANN` checks. Add type annotations to unit tests. --- colour/__init__.py | 2 +- colour/adaptation/tests/test__init__.py | 6 +- colour/adaptation/tests/test_cie1994.py | 10 +- colour/adaptation/tests/test_cmccat2000.py | 18 +- colour/adaptation/tests/test_fairchild1990.py | 10 +- colour/adaptation/tests/test_fairchild2020.py | 18 +- colour/adaptation/tests/test_vonkries.py | 18 +- colour/adaptation/tests/test_zhai2018.py | 10 +- colour/algebra/__init__.py | 2 +- colour/algebra/common.py | 8 +- .../coordinates/tests/test_transformations.py | 38 ++-- colour/algebra/extrapolation.py | 8 +- colour/algebra/interpolation.py | 48 ++--- colour/algebra/tests/test_common.py | 54 ++--- colour/algebra/tests/test_extrapolation.py | 18 +- colour/algebra/tests/test_interpolation.py | 102 ++++----- colour/algebra/tests/test_prng.py | 2 +- colour/algebra/tests/test_regression.py | 4 +- colour/appearance/hunt.py | 12 +- colour/appearance/kim2009.py | 2 +- colour/appearance/tests/test_atd95.py | 10 +- colour/appearance/tests/test_cam16.py | 24 ++- colour/appearance/tests/test_ciecam02.py | 24 ++- colour/appearance/tests/test_ciecam16.py | 24 ++- colour/appearance/tests/test_hellwig2022.py | 24 ++- colour/appearance/tests/test_hke.py | 26 +-- colour/appearance/tests/test_hunt.py | 14 +- colour/appearance/tests/test_kim2009.py | 24 ++- colour/appearance/tests/test_llab.py | 24 ++- colour/appearance/tests/test_nayatani95.py | 10 +- colour/appearance/tests/test_rlab.py | 10 +- colour/appearance/tests/test_zcam.py | 32 +-- .../tests/test_michaelis_menten.py | 26 +-- colour/blindness/tests/test_machado2009.py | 32 +-- colour/characterisation/aces_it.py | 11 +- colour/characterisation/cameras.py | 5 +- colour/characterisation/correction.py | 20 +- colour/characterisation/displays.py | 5 +- colour/characterisation/tests/test_aces_it.py | 64 +++--- .../characterisation/tests/test_correction.py | 64 +++--- colour/colorimetry/cmfs.py | 11 +- colour/colorimetry/spectrum.py | 38 ++-- colour/colorimetry/tests/test_blackbody.py | 18 +- colour/colorimetry/tests/test_correction.py | 4 +- colour/colorimetry/tests/test_dominant.py | 42 ++-- colour/colorimetry/tests/test_generation.py | 22 +- colour/colorimetry/tests/test_illuminants.py | 10 +- colour/colorimetry/tests/test_lefs.py | 10 +- colour/colorimetry/tests/test_lightness.py | 63 +++--- colour/colorimetry/tests/test_luminance.py | 63 +++--- colour/colorimetry/tests/test_photometry.py | 8 +- colour/colorimetry/tests/test_spectrum.py | 106 +++++----- .../colorimetry/tests/test_transformations.py | 32 +-- .../tests/test_tristimulus_values.py | 54 ++--- colour/colorimetry/tests/test_uniformity.py | 2 +- colour/colorimetry/tests/test_whiteness.py | 52 ++--- colour/colorimetry/tests/test_yellowness.py | 28 +-- colour/colorimetry/uniformity.py | 3 + colour/continuous/abstract.py | 18 +- colour/continuous/multi_signals.py | 42 ++-- colour/continuous/signal.py | 39 ++-- colour/continuous/tests/test_abstract.py | 6 +- colour/continuous/tests/test_multi_signal.py | 80 +++---- colour/continuous/tests/test_signal.py | 68 +++--- colour/contrast/__init__.py | 4 +- colour/contrast/tests/test_barten1999.py | 38 ++-- colour/corresponding/datasets/breneman1987.py | 23 +- colour/corresponding/tests/test_prediction.py | 12 +- colour/difference/tests/test__init__.py | 4 +- colour/difference/tests/test_cam02_ucs.py | 8 +- colour/difference/tests/test_cam16_ucs.py | 2 + colour/difference/tests/test_delta_e.py | 62 +++--- colour/difference/tests/test_din99.py | 10 +- colour/difference/tests/test_huang2015.py | 4 +- colour/difference/tests/test_stress.py | 4 +- colour/examples/io/examples_ctl.py | 3 +- .../plotting/examples_section_plots.py | 2 +- colour/geometry/section.py | 4 +- colour/geometry/tests/test_ellipse.py | 10 +- colour/geometry/tests/test_intersection.py | 6 +- colour/geometry/tests/test_primitives.py | 10 +- colour/geometry/tests/test_section.py | 10 +- colour/geometry/tests/test_vertices.py | 10 +- colour/geometry/vertices.py | 30 +-- colour/graph/conversion.py | 22 +- colour/graph/tests/test_conversion.py | 8 +- colour/hints/__init__.py | 8 +- colour/io/__init__.py | 2 +- colour/io/fichet2021.py | 22 +- colour/io/image.py | 6 +- colour/io/luts/cinespace_csp.py | 6 +- colour/io/luts/iridas_cube.py | 6 +- colour/io/luts/lut.py | 12 +- colour/io/luts/operator.py | 8 +- colour/io/luts/sequence.py | 12 +- colour/io/luts/tests/test__init__.py | 22 +- colour/io/luts/tests/test_cinespace_csp.py | 141 +++++++++---- colour/io/luts/tests/test_common.py | 4 +- colour/io/luts/tests/test_iridas_cube.py | 11 +- colour/io/luts/tests/test_lut.py | 100 ++++----- colour/io/luts/tests/test_operator.py | 26 +-- colour/io/luts/tests/test_resolve_cube.py | 110 ++++++---- colour/io/luts/tests/test_sequence.py | 30 +-- colour/io/luts/tests/test_sony_spi1d.py | 8 +- colour/io/luts/tests/test_sony_spi3d.py | 8 +- colour/io/luts/tests/test_sony_spimtx.py | 8 +- colour/io/tests/test_ctl.py | 12 +- colour/io/tests/test_fichet2021.py | 63 +++--- colour/io/tests/test_image.py | 98 +++++---- colour/io/tests/test_ocio.py | 4 +- colour/io/tests/test_tabular.py | 12 +- colour/io/tests/test_tm2714.py | 36 ++-- colour/io/tests/test_uprtek_sekonic.py | 22 +- colour/io/tests/test_xrite.py | 2 +- colour/io/tm2714.py | 38 ++-- colour/models/cie_luv.py | 2 +- colour/models/cie_ucs.py | 2 +- colour/models/cie_xyy.py | 2 +- colour/models/hunter_lab.py | 12 +- colour/models/hunter_rdab.py | 12 +- .../models/rgb/datasets/tests/test__init__.py | 12 +- colour/models/rgb/ictcp.py | 8 +- colour/models/rgb/itut_h_273.py | 14 +- colour/models/rgb/rgb_colourspace.py | 28 +-- colour/models/rgb/tests/test_cmyk.py | 34 +-- colour/models/rgb/tests/test_common.py | 6 +- colour/models/rgb/tests/test_cylindrical.py | 50 ++--- colour/models/rgb/tests/test_derivation.py | 28 +-- colour/models/rgb/tests/test_hanbury2003.py | 18 +- colour/models/rgb/tests/test_ictcp.py | 34 +-- colour/models/rgb/tests/test_itut_h_273.py | 8 +- colour/models/rgb/tests/test_prismatic.py | 18 +- .../models/rgb/tests/test_rgb_colourspace.py | 122 +++++------ colour/models/rgb/tests/test_ycbcr.py | 42 ++-- colour/models/rgb/tests/test_ycocg.py | 14 +- .../models/rgb/transfer_functions/__init__.py | 2 +- .../rgb/transfer_functions/itur_bt_1361.py | 7 +- .../rgb/transfer_functions/itut_h_273.py | 27 ++- colour/models/rgb/transfer_functions/red.py | 2 +- .../transfer_functions/tests/test__init__.py | 6 +- .../rgb/transfer_functions/tests/test_aces.py | 52 ++--- .../tests/test_apple_log_profile.py | 16 +- .../tests/test_arib_std_b67.py | 16 +- .../rgb/transfer_functions/tests/test_arri.py | 32 +-- .../tests/test_blackmagic_design.py | 16 +- .../transfer_functions/tests/test_canon.py | 96 ++++----- .../transfer_functions/tests/test_cineon.py | 16 +- .../transfer_functions/tests/test_common.py | 14 +- .../tests/test_davinci_intermediate.py | 16 +- .../rgb/transfer_functions/tests/test_dcdm.py | 16 +- .../tests/test_dicom_gsdf.py | 16 +- .../tests/test_dji_d_log.py | 16 +- .../transfer_functions/tests/test_exponent.py | 12 +- .../tests/test_filmic_pro.py | 16 +- .../tests/test_filmlight_t_log.py | 16 +- .../tests/test_fujifilm_f_log.py | 32 +-- .../transfer_functions/tests/test_gamma.py | 6 +- .../transfer_functions/tests/test_gopro.py | 16 +- .../tests/test_itur_bt_1361.py | 16 +- .../tests/test_itur_bt_1886.py | 16 +- .../tests/test_itur_bt_2020.py | 16 +- .../tests/test_itur_bt_2100.py | 130 ++++++------ .../tests/test_itur_bt_601.py | 16 +- .../tests/test_itur_bt_709.py | 16 +- .../tests/test_itut_h_273.py | 64 +++--- .../tests/test_leica_l_log.py | 16 +- .../transfer_functions/tests/test_linear.py | 6 +- .../rgb/transfer_functions/tests/test_log.py | 34 +-- .../tests/test_nikon_n_log.py | 16 +- .../transfer_functions/tests/test_panalog.py | 16 +- .../tests/test_panasonic_vlog.py | 16 +- .../tests/test_pivoted_log.py | 16 +- .../rgb/transfer_functions/tests/test_red.py | 96 ++++----- .../tests/test_rimm_romm_rgb.py | 48 ++--- .../tests/test_smpte_240m.py | 16 +- .../rgb/transfer_functions/tests/test_sony.py | 48 ++--- .../rgb/transfer_functions/tests/test_srgb.py | 16 +- .../transfer_functions/tests/test_st_2084.py | 16 +- .../tests/test_viper_log.py | 16 +- colour/models/tests/test_cam02_ucs.py | 36 ++-- colour/models/tests/test_cam16_ucs.py | 2 + colour/models/tests/test_cie_lab.py | 18 +- colour/models/tests/test_cie_luv.py | 62 +++--- colour/models/tests/test_cie_ucs.py | 62 +++--- colour/models/tests/test_cie_uvw.py | 18 +- colour/models/tests/test_cie_xyy.py | 54 ++--- colour/models/tests/test_common.py | 38 ++-- colour/models/tests/test_din99.py | 34 +-- colour/models/tests/test_hdr_cie_lab.py | 26 +-- colour/models/tests/test_hdr_ipt.py | 26 +-- colour/models/tests/test_hunter_lab.py | 24 ++- colour/models/tests/test_hunter_rdab.py | 18 +- colour/models/tests/test_icacb.py | 18 +- colour/models/tests/test_igpgtg.py | 18 +- colour/models/tests/test_ipt.py | 26 +-- colour/models/tests/test_jzazbz.py | 34 +-- colour/models/tests/test_oklab.py | 18 +- colour/models/tests/test_osa_ucs.py | 18 +- colour/models/tests/test_prolab.py | 18 +- colour/models/tests/test_ragoo2021.py | 18 +- colour/models/tests/test_yrg.py | 34 +-- colour/notation/munsell.py | 2 +- colour/notation/tests/test_css_color_3.py | 2 +- colour/notation/tests/test_hexadecimal.py | 16 +- colour/notation/tests/test_munsell.py | 116 +++++------ colour/phenomena/tests/test_rayleigh.py | 92 ++++---- colour/plotting/colorimetry.py | 2 + colour/plotting/common.py | 11 +- colour/plotting/diagrams.py | 8 + colour/plotting/models.py | 3 +- colour/plotting/quality.py | 3 + colour/plotting/temperature.py | 5 +- colour/plotting/tests/test_blindness.py | 4 +- .../plotting/tests/test_characterisation.py | 6 +- colour/plotting/tests/test_colorimetry.py | 28 +-- colour/plotting/tests/test_common.py | 87 ++++---- colour/plotting/tests/test_corresponding.py | 4 +- colour/plotting/tests/test_diagrams.py | 24 ++- colour/plotting/tests/test_graph.py | 4 +- colour/plotting/tests/test_models.py | 40 ++-- colour/plotting/tests/test_notation.py | 6 +- colour/plotting/tests/test_phenomena.py | 6 +- colour/plotting/tests/test_quality.py | 14 +- colour/plotting/tests/test_section.py | 10 +- colour/plotting/tests/test_temperature.py | 16 +- colour/plotting/tests/test_volume.py | 10 +- colour/plotting/tm3018/components.py | 2 +- .../plotting/tm3018/tests/test_components.py | 14 +- colour/plotting/tm3018/tests/test_report.py | 10 +- colour/plotting/volume.py | 28 +-- colour/quality/__init__.py | 2 +- colour/quality/tests/test_cfi2017.py | 25 ++- colour/quality/tests/test_cqs.py | 196 ++++++++++-------- colour/quality/tests/test_cri.py | 24 ++- colour/quality/tests/test_ssi.py | 4 +- colour/quality/tests/test_tm3018.py | 15 +- colour/recovery/jakob2019.py | 4 +- colour/recovery/jiang2013.py | 3 +- colour/recovery/otsu2018.py | 16 +- colour/recovery/tests/test__init__.py | 6 +- colour/recovery/tests/test_jakob2019.py | 48 +++-- colour/recovery/tests/test_jiang2013.py | 18 +- colour/recovery/tests/test_mallett2019.py | 25 ++- colour/recovery/tests/test_meng2015.py | 10 +- colour/recovery/tests/test_otsu2018.py | 133 ++++++------ colour/recovery/tests/test_smits1999.py | 6 +- colour/temperature/ohno2013.py | 4 +- colour/temperature/tests/test_cie_d.py | 14 +- .../temperature/tests/test_hernandez1999.py | 14 +- colour/temperature/tests/test_kang2002.py | 14 +- colour/temperature/tests/test_krystek1985.py | 14 +- colour/temperature/tests/test_mccamy1992.py | 14 +- colour/temperature/tests/test_ohno2013.py | 28 +-- colour/temperature/tests/test_planck1900.py | 14 +- .../temperature/tests/test_robertson1968.py | 24 +-- colour/utilities/__init__.py | 2 +- colour/utilities/array.py | 24 ++- colour/utilities/common.py | 25 ++- colour/utilities/network.py | 55 ++--- colour/utilities/structures.py | 12 +- colour/utilities/tests/test_array.py | 156 +++++++------- colour/utilities/tests/test_callback.py | 16 +- colour/utilities/tests/test_common.py | 58 +++--- colour/utilities/tests/test_deprecated.py | 4 +- colour/utilities/tests/test_deprecation.py | 58 +++--- colour/utilities/tests/test_documentation.py | 4 +- colour/utilities/tests/test_metrics.py | 6 +- colour/utilities/tests/test_network.py | 173 ++++++++-------- colour/utilities/tests/test_structures.py | 62 +++--- colour/utilities/tests/test_verbose.py | 24 ++- colour/utilities/verbose.py | 16 +- colour/volume/tests/test_macadam_limits.py | 8 +- colour/volume/tests/test_mesh.py | 10 +- colour/volume/tests/test_pointer_gamut.py | 8 +- colour/volume/tests/test_rgb.py | 20 +- colour/volume/tests/test_spectrum.py | 12 +- docs/colour.hints.rst | 1 + pyproject.toml | 3 +- tasks.py | 32 +-- utilities/export_todo.py | 2 +- utilities/generate_plots.py | 2 +- utilities/literalise.py | 2 +- utilities/mock_for_colour.py | 2 +- utilities/unicode_to_ascii.py | 2 +- 284 files changed, 3830 insertions(+), 3222 deletions(-) diff --git a/colour/__init__.py b/colour/__init__.py index fe7258a02..ca0f660e9 100644 --- a/colour/__init__.py +++ b/colour/__init__.py @@ -923,7 +923,7 @@ class colour(ModuleAPI): """Define a class acting like the *colour* module.""" - def __getattr__(self, attribute) -> Any: + def __getattr__(self, attribute: str) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) diff --git a/colour/adaptation/tests/test__init__.py b/colour/adaptation/tests/test__init__.py index 3913219ad..22018f9aa 100644 --- a/colour/adaptation/tests/test__init__.py +++ b/colour/adaptation/tests/test__init__.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation` module.""" +from __future__ import annotations + import numpy as np from colour.adaptation import chromatic_adaptation @@ -24,7 +26,7 @@ class TestChromaticAdaptation: tests methods. """ - def test_chromatic_adaptation(self): + def test_chromatic_adaptation(self) -> None: """Test :func:`colour.adaptation.chromatic_adaptation` definition.""" XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) @@ -68,7 +70,7 @@ def test_chromatic_adaptation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation(self): + def test_domain_range_scale_chromatic_adaptation(self) -> None: """ Test :func:`colour.adaptation.chromatic_adaptation` definition domain and range scale support. diff --git a/colour/adaptation/tests/test_cie1994.py b/colour/adaptation/tests/test_cie1994.py index bbb96a54c..7d6841196 100644 --- a/colour/adaptation/tests/test_cie1994.py +++ b/colour/adaptation/tests/test_cie1994.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation.cie1994` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -26,7 +28,7 @@ class TestChromaticAdaptationCIE1994: definition unit tests methods. """ - def test_chromatic_adaptation_CIE1994(self): + def test_chromatic_adaptation_CIE1994(self) -> None: """ Test :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition. @@ -71,7 +73,7 @@ def test_chromatic_adaptation_CIE1994(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_CIE1994(self): + def test_n_dimensional_chromatic_adaptation_CIE1994(self) -> None: """ Test :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition n-dimensional arrays support. @@ -117,7 +119,7 @@ def test_n_dimensional_chromatic_adaptation_CIE1994(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_CIE1994(self): + def test_domain_range_scale_chromatic_adaptation_CIE1994(self) -> None: """ Test :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition domain and range scale support. @@ -143,7 +145,7 @@ def test_domain_range_scale_chromatic_adaptation_CIE1994(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_CIE1994(self): + def test_nan_chromatic_adaptation_CIE1994(self) -> None: """ Test :func:`colour.adaptation.cie1994.chromatic_adaptation_CIE1994` definition nan support. diff --git a/colour/adaptation/tests/test_cmccat2000.py b/colour/adaptation/tests/test_cmccat2000.py index 4e9c809f7..dfb99102d 100644 --- a/colour/adaptation/tests/test_cmccat2000.py +++ b/colour/adaptation/tests/test_cmccat2000.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation.cmccat2000.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestChromaticAdaptationForwardCMCCAT2000: chromatic_adaptation_forward_CMCCAT2000` definition unit tests methods. """ - def test_chromatic_adaptation_forward_CMCCAT2000(self): + def test_chromatic_adaptation_forward_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_forward_CMCCAT2000` definition. @@ -72,7 +74,7 @@ def test_chromatic_adaptation_forward_CMCCAT2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self): + def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_forward_CMCCAT2000` definition n-dimensional arrays @@ -116,7 +118,7 @@ def test_n_dimensional_chromatic_adaptation_forward_CMCCAT2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): + def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_forward_CMCCAT2000` definition domain and range scale @@ -146,7 +148,7 @@ def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_forward_CMCCAT2000(self): + def test_nan_chromatic_adaptation_forward_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_forward_CMCCAT2000` definition nan support. @@ -165,7 +167,7 @@ class TestChromaticAdaptationInverseCMCCAT2000: chromatic_adaptation_inverse_CMCCAT2000` definition unit tests methods. """ - def test_chromatic_adaptation_inverse_CMCCAT2000(self): + def test_chromatic_adaptation_inverse_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_inverse_CMCCAT2000` definition. @@ -207,7 +209,7 @@ def test_chromatic_adaptation_inverse_CMCCAT2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self): + def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_inverse_CMCCAT2000` definition n-dimensional arrays @@ -251,7 +253,7 @@ def test_n_dimensional_chromatic_adaptation_inverse_CMCCAT2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): + def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_inverse_CMCCAT2000` definition domain and range scale @@ -281,7 +283,7 @@ def test_domain_range_scale_chromatic_adaptation_CMCCAT2000(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_inverse_CMCCAT2000(self): + def test_nan_chromatic_adaptation_inverse_CMCCAT2000(self) -> None: """ Test :func:`colour.adaptation.cmccat2000.\ chromatic_adaptation_inverse_CMCCAT2000` definition nan support. diff --git a/colour/adaptation/tests/test_fairchild1990.py b/colour/adaptation/tests/test_fairchild1990.py index d7fbb5b47..d6bab70aa 100644 --- a/colour/adaptation/tests/test_fairchild1990.py +++ b/colour/adaptation/tests/test_fairchild1990.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation.fairchild1990` module.""" +from __future__ import annotations + import contextlib from itertools import product @@ -28,7 +30,7 @@ class TestChromaticAdaptationFairchild1990: chromatic_adaptation_Fairchild1990` definition unit tests methods. """ - def test_chromatic_adaptation_Fairchild1990(self): + def test_chromatic_adaptation_Fairchild1990(self) -> None: """ Test :func:`colour.adaptation.fairchild1990.\ chromatic_adaptation_Fairchild1990` definition. @@ -67,7 +69,7 @@ def test_chromatic_adaptation_Fairchild1990(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_Fairchild1990(self): + def test_n_dimensional_chromatic_adaptation_Fairchild1990(self) -> None: """ Test :func:`colour.adaptation.fairchild1990.\ chromatic_adaptation_Fairchild1990` definition n-dimensional arrays support. @@ -107,7 +109,7 @@ def test_n_dimensional_chromatic_adaptation_Fairchild1990(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_Fairchild1990(self): + def test_domain_range_scale_chromatic_adaptation_Fairchild1990(self) -> None: """ Test :func:`colour.adaptation.fairchild1990.\ chromatic_adaptation_Fairchild1990` definition domain and range scale support. @@ -131,7 +133,7 @@ def test_domain_range_scale_chromatic_adaptation_Fairchild1990(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_Fairchild1990(self): + def test_nan_chromatic_adaptation_Fairchild1990(self) -> None: """ Test :func:`colour.adaptation.fairchild1990.\ chromatic_adaptation_Fairchild1990` definition nan support. diff --git a/colour/adaptation/tests/test_fairchild2020.py b/colour/adaptation/tests/test_fairchild2020.py index 982706242..399b9d94d 100644 --- a/colour/adaptation/tests/test_fairchild2020.py +++ b/colour/adaptation/tests/test_fairchild2020.py @@ -2,6 +2,8 @@ Define the unit tests for the :mod:`colour.adaptation.fairchild2020` module. """ +from __future__ import annotations + import unittest from itertools import product @@ -36,7 +38,7 @@ class TestMatrixChromaticAdaptationVonKries(unittest.TestCase): matrix_chromatic_adaptation_vk20` definition unit tests methods. """ - def test_matrix_chromatic_adaptation_vk20(self): + def test_matrix_chromatic_adaptation_vk20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.\ matrix_chromatic_adaptation_vk20` definition. @@ -121,7 +123,7 @@ def test_matrix_chromatic_adaptation_vk20(self): decimal=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_matrix_chromatic_adaptation_vk20(self): + def test_n_dimensional_matrix_chromatic_adaptation_vk20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.\ matrix_chromatic_adaptation_vk20` definition n-dimensional arrays support. @@ -149,7 +151,7 @@ def test_n_dimensional_matrix_chromatic_adaptation_vk20(self): decimal=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_matrix_chromatic_adaptation_vk20(self): + def test_domain_range_scale_matrix_chromatic_adaptation_vk20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.\ matrix_chromatic_adaptation_vk20` definition domain and range scale @@ -173,7 +175,7 @@ def test_domain_range_scale_matrix_chromatic_adaptation_vk20(self): ) @ignore_numpy_errors - def test_nan_matrix_chromatic_adaptation_vk20(self): + def test_nan_matrix_chromatic_adaptation_vk20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.\ matrix_chromatic_adaptation_vk20` definition nan support. @@ -190,7 +192,7 @@ class TestChromaticAdaptationVonKries(unittest.TestCase): definition unit tests methods. """ - def test_chromatic_adaptation_vK20(self): + def test_chromatic_adaptation_vK20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.chromatic_adaptation_vK20` definition. @@ -260,7 +262,7 @@ def test_chromatic_adaptation_vK20(self): decimal=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_vK20(self): + def test_n_dimensional_chromatic_adaptation_vK20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.chromatic_adaptation_vK20` definition n-dimensional arrays support. @@ -291,7 +293,7 @@ def test_n_dimensional_chromatic_adaptation_vK20(self): decimal=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_vK20(self): + def test_domain_range_scale_chromatic_adaptation_vK20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.chromatic_adaptation_vK20` definition domain and range scale support. @@ -318,7 +320,7 @@ def test_domain_range_scale_chromatic_adaptation_vK20(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_vK20(self): + def test_nan_chromatic_adaptation_vK20(self) -> None: """ Test :func:`colour.adaptation.fairchild2020.chromatic_adaptation_vK20` definition nan support. diff --git a/colour/adaptation/tests/test_vonkries.py b/colour/adaptation/tests/test_vonkries.py index a5b0bc55e..d856fca39 100644 --- a/colour/adaptation/tests/test_vonkries.py +++ b/colour/adaptation/tests/test_vonkries.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation.vonkries` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestMatrixChromaticAdaptationVonKries: matrix_chromatic_adaptation_VonKries` definition unit tests methods. """ - def test_matrix_chromatic_adaptation_VonKries(self): + def test_matrix_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.\ matrix_chromatic_adaptation_VonKries` definition. @@ -128,7 +130,7 @@ def test_matrix_chromatic_adaptation_VonKries(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_matrix_chromatic_adaptation_VonKries(self): + def test_n_dimensional_matrix_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.\ matrix_chromatic_adaptation_VonKries` definition n-dimensional arrays support. @@ -156,7 +158,7 @@ def test_n_dimensional_matrix_chromatic_adaptation_VonKries(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_matrix_chromatic_adaptation_VonKries(self): + def test_domain_range_scale_matrix_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.\ matrix_chromatic_adaptation_VonKries` definition domain and range scale @@ -179,7 +181,7 @@ def test_domain_range_scale_matrix_chromatic_adaptation_VonKries(self): ) @ignore_numpy_errors - def test_nan_matrix_chromatic_adaptation_VonKries(self): + def test_nan_matrix_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.\ matrix_chromatic_adaptation_VonKries` definition nan support. @@ -196,7 +198,7 @@ class TestChromaticAdaptationVonKries: definition unit tests methods. """ - def test_chromatic_adaptation_VonKries(self): + def test_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.chromatic_adaptation_VonKries` definition. @@ -265,7 +267,7 @@ def test_chromatic_adaptation_VonKries(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_VonKries(self): + def test_n_dimensional_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.chromatic_adaptation_VonKries` definition n-dimensional arrays support. @@ -296,7 +298,7 @@ def test_n_dimensional_chromatic_adaptation_VonKries(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_VonKries(self): + def test_domain_range_scale_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.chromatic_adaptation_VonKries` definition domain and range scale support. @@ -319,7 +321,7 @@ def test_domain_range_scale_chromatic_adaptation_VonKries(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_VonKries(self): + def test_nan_chromatic_adaptation_VonKries(self) -> None: """ Test :func:`colour.adaptation.vonkries.chromatic_adaptation_VonKries` definition nan support. diff --git a/colour/adaptation/tests/test_zhai2018.py b/colour/adaptation/tests/test_zhai2018.py index ad42fdfdf..6bbc87fbb 100644 --- a/colour/adaptation/tests/test_zhai2018.py +++ b/colour/adaptation/tests/test_zhai2018.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.adaptation.zhai2018` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -26,7 +28,7 @@ class TestChromaticAdaptationZhai2018: definition unit tests methods. """ - def test_chromatic_adaptation_Zhai2018(self): + def test_chromatic_adaptation_Zhai2018(self) -> None: """ Test :func:`colour.adaptation.zhai2018.chromatic_adaptation_Zhai2018` definition. @@ -96,7 +98,7 @@ def test_chromatic_adaptation_Zhai2018(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_chromatic_adaptation_Zhai2018(self): + def test_n_dimensional_chromatic_adaptation_Zhai2018(self) -> None: """ Test :func:`colour.adaptation.zhai2018.chromatic_adaptation_Zhai2018` definition n-dimensional arrays support. @@ -139,7 +141,7 @@ def test_n_dimensional_chromatic_adaptation_Zhai2018(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_chromatic_adaptation_Zhai2018(self): + def test_domain_range_scale_chromatic_adaptation_Zhai2018(self) -> None: """ Test :func:`colour.adaptation.zhai2018.chromatic_adaptation_Zhai2018` definition domain and range scale support. @@ -162,7 +164,7 @@ def test_domain_range_scale_chromatic_adaptation_Zhai2018(self): ) @ignore_numpy_errors - def test_nan_chromatic_adaptation_Zhai2018(self): + def test_nan_chromatic_adaptation_Zhai2018(self) -> None: """ Test :func:`colour.adaptation.zhai2018.chromatic_adaptation_Zhai2018` definition nan support. diff --git a/colour/algebra/__init__.py b/colour/algebra/__init__.py index e5c0d248a..06b9b3408 100644 --- a/colour/algebra/__init__.py +++ b/colour/algebra/__init__.py @@ -114,7 +114,7 @@ class algebra(ModuleAPI): """Define a class acting like the *algebra* module.""" - def __getattr__(self, attribute) -> Any: + def __getattr__(self, attribute: str) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) diff --git a/colour/algebra/common.py b/colour/algebra/common.py index 44da82652..333753128 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -122,7 +122,7 @@ def set_sdiv_mode( ] | str ), -): +) -> None: """ Set *Colour* safe division function mode. @@ -212,7 +212,7 @@ def __enter__(self) -> sdiv_mode: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """ Set the *Colour* safe division function mode upon exiting the context manager. @@ -371,7 +371,7 @@ def is_spow_enabled() -> bool: return _SPOW_ENABLED -def set_spow_enable(enable: bool): +def set_spow_enable(enable: bool) -> None: """ Set *Colour* safe / symmetrical power function enabled state. @@ -421,7 +421,7 @@ def __enter__(self) -> spow_enable: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """ Set the *Colour* safe / symmetrical power function enabled state upon exiting the context manager. diff --git a/colour/algebra/coordinates/tests/test_transformations.py b/colour/algebra/coordinates/tests/test_transformations.py index 6595ff4ae..e5b752aa6 100644 --- a/colour/algebra/coordinates/tests/test_transformations.py +++ b/colour/algebra/coordinates/tests/test_transformations.py @@ -3,6 +3,8 @@ :mod:`colour.algebra.coordinates.transformations` module. """ +from __future__ import annotations + from itertools import product import numpy as np @@ -41,7 +43,7 @@ class TestCartesianToSpherical: cartesian_to_spherical` definition unit tests methods. """ - def test_cartesian_to_spherical(self): + def test_cartesian_to_spherical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition. @@ -65,7 +67,7 @@ def test_cartesian_to_spherical(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_cartesian_to_spherical(self): + def test_n_dimensional_cartesian_to_spherical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition n-dimensional arrays support. @@ -87,7 +89,7 @@ def test_n_dimensional_cartesian_to_spherical(self): ) @ignore_numpy_errors - def test_nan_cartesian_to_spherical(self): + def test_nan_cartesian_to_spherical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_spherical` definition nan support. @@ -104,7 +106,7 @@ class TestSphericalToCartesian: spherical_to_cartesian` definition unit tests methods. """ - def test_spherical_to_cartesian(self): + def test_spherical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ spherical_to_cartesian` definition. @@ -128,7 +130,7 @@ def test_spherical_to_cartesian(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_spherical_to_cartesian(self): + def test_n_dimensional_spherical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ spherical_to_cartesian` definition n-dimensional arrays support. @@ -150,7 +152,7 @@ def test_n_dimensional_spherical_to_cartesian(self): ) @ignore_numpy_errors - def test_nan_spherical_to_cartesian(self): + def test_nan_spherical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ spherical_to_cartesian` definition nan support. @@ -167,7 +169,7 @@ class TestCartesianToPolar: cartesian_to_polar` definition unit tests methods. """ - def test_cartesian_to_polar(self): + def test_cartesian_to_polar(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_polar` definition. @@ -191,7 +193,7 @@ def test_cartesian_to_polar(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_cartesian_to_polar(self): + def test_n_dimensional_cartesian_to_polar(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_polar` definition n-dimensional arrays support. @@ -213,7 +215,7 @@ def test_n_dimensional_cartesian_to_polar(self): ) @ignore_numpy_errors - def test_nan_cartesian_to_polar(self): + def test_nan_cartesian_to_polar(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_polar` definition nan support. @@ -230,7 +232,7 @@ class TestPolarToCartesian: polar_to_cartesian` definition unit tests methods. """ - def test_polar_to_cartesian(self): + def test_polar_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ polar_to_cartesian` definition. @@ -254,7 +256,7 @@ def test_polar_to_cartesian(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_polar_to_cartesian(self): + def test_n_dimensional_polar_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ polar_to_cartesian` definition n-dimensional arrays support. @@ -276,7 +278,7 @@ def test_n_dimensional_polar_to_cartesian(self): ) @ignore_numpy_errors - def test_nan_polar_to_cartesian(self): + def test_nan_polar_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ polar_to_cartesian` definition nan support. @@ -293,7 +295,7 @@ class TestCartesianToCylindrical: cartesian_to_cylindrical` definition unit tests methods. """ - def test_cartesian_to_cylindrical(self): + def test_cartesian_to_cylindrical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_cylindrical` definition. @@ -317,7 +319,7 @@ def test_cartesian_to_cylindrical(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_cartesian_to_cylindrical(self): + def test_n_dimensional_cartesian_to_cylindrical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_cylindrical` definition n-dimensional arrays support. @@ -339,7 +341,7 @@ def test_n_dimensional_cartesian_to_cylindrical(self): ) @ignore_numpy_errors - def test_nan_cartesian_to_cylindrical(self): + def test_nan_cartesian_to_cylindrical(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cartesian_to_cylindrical` definition nan support. @@ -356,7 +358,7 @@ class TestCylindricalToCartesian: cylindrical_to_cartesian` definition unit tests methods. """ - def test_cylindrical_to_cartesian(self): + def test_cylindrical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cylindrical_to_cartesian` definition. @@ -380,7 +382,7 @@ def test_cylindrical_to_cartesian(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_cylindrical_to_cartesian(self): + def test_n_dimensional_cylindrical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cylindrical_to_cartesian` definition n-dimensional arrays support. @@ -402,7 +404,7 @@ def test_n_dimensional_cylindrical_to_cartesian(self): ) @ignore_numpy_errors - def test_nan_cylindrical_to_cartesian(self): + def test_nan_cylindrical_to_cartesian(self) -> None: """ Test :func:`colour.algebra.coordinates.transformations.\ cylindrical_to_cartesian` definition nan support. diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 271af7f9a..074d72e88 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -179,7 +179,7 @@ class instance. return self._interpolator @interpolator.setter - def interpolator(self, value: ProtocolInterpolator): + def interpolator(self, value: ProtocolInterpolator) -> None: """Setter for the **self.interpolator** property.""" attest( @@ -213,7 +213,7 @@ def method(self) -> Literal["Linear", "Constant"] | str: return self._method @method.setter - def method(self, value: Literal["Linear", "Constant"] | str): + def method(self, value: Literal["Linear", "Constant"] | str) -> None: """Setter for the **self.method** property.""" attest( @@ -244,7 +244,7 @@ def left(self) -> Real | None: return self._left @left.setter - def left(self, value: Real | None): + def left(self, value: Real | None) -> None: """Setter for the **self.left** property.""" if value is not None: @@ -274,7 +274,7 @@ def right(self) -> Real | None: return self._right @right.setter - def right(self, value: Real | None): + def right(self, value: Real | None) -> None: """Setter for the **self.right** property.""" if value is not None: diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index bb08f3251..7673ede5b 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -452,7 +452,7 @@ def x(self) -> NDArrayFloat: return self._x @x.setter - def x(self, value: ArrayLike): + def x(self, value: ArrayLike) -> None: """Setter for the **self.x** property.""" value = np.atleast_1d(value).astype(self._dtype) @@ -503,7 +503,7 @@ def y(self) -> NDArrayFloat: return self._y @y.setter - def y(self, value: ArrayLike): + def y(self, value: ArrayLike) -> None: """Setter for the **self.y** property.""" value = np.atleast_1d(value).astype(self._dtype) @@ -537,7 +537,7 @@ def window(self) -> float: return self._window @window.setter - def window(self, value: float): + def window(self, value: float) -> None: """Setter for the **self.window** property.""" attest(bool(value >= 1), '"window" must be equal to or greater than 1!') @@ -571,7 +571,7 @@ def kernel(self) -> Callable: return self._kernel @kernel.setter - def kernel(self, value: Callable): + def kernel(self, value: Callable) -> None: """Setter for the **self.kernel** property.""" attest( @@ -600,7 +600,7 @@ def kernel_kwargs(self) -> dict: return self._kernel_kwargs @kernel_kwargs.setter - def kernel_kwargs(self, value: dict): + def kernel_kwargs(self, value: dict) -> None: """Setter for the **self.kernel_kwargs** property.""" attest( @@ -629,7 +629,7 @@ def padding_kwargs(self) -> dict: return self._padding_kwargs @padding_kwargs.setter - def padding_kwargs(self, value: dict): + def padding_kwargs(self, value: dict) -> None: """Setter for the **self.padding_kwargs** property.""" attest( @@ -700,7 +700,7 @@ def _evaluate(self, x: NDArrayFloat) -> NDArrayFloat: axis=-1, ) - def _validate_dimensions(self): + def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): @@ -709,7 +709,7 @@ def _validate_dimensions(self): f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) - def _validate_interpolation_range(self, x: NDArrayFloat): + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" below_interpolation_range = x < self._x[0] @@ -838,7 +838,7 @@ def x(self) -> NDArrayFloat: return self._x @x.setter - def x(self, value: ArrayLike): + def x(self, value: ArrayLike) -> None: """Setter for the **self.x** property.""" value = cast(NDArrayFloat, np.atleast_1d(value).astype(self._dtype)) @@ -871,7 +871,7 @@ def y(self) -> NDArrayFloat: return self._y @y.setter - def y(self, value: ArrayLike): + def y(self, value: ArrayLike) -> None: """Setter for the **self.y** property.""" value = cast(NDArrayFloat, np.atleast_1d(value).astype(self._dtype)) @@ -925,7 +925,7 @@ def _evaluate(self, x: NDArrayFloat) -> NDArrayFloat: return np.interp(x, self._x, self._y) - def _validate_dimensions(self): + def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): @@ -934,7 +934,7 @@ def _validate_dimensions(self): f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) - def _validate_interpolation_range(self, x: NDArrayFloat): + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" below_interpolation_range = x < self._x[0] @@ -1061,7 +1061,7 @@ def x(self) -> NDArrayFloat: return self._x @x.setter - def x(self, value: ArrayLike): + def x(self, value: ArrayLike) -> None: """Setter for the **self.x** property.""" value = as_array(np.atleast_1d(value), self._dtype) @@ -1109,7 +1109,7 @@ def y(self) -> NDArrayFloat: return self._y @y.setter - def y(self, value: ArrayLike): + def y(self, value: ArrayLike) -> None: """Setter for the **self.y** property.""" value = as_array(np.atleast_1d(value), self._dtype) @@ -1209,7 +1209,7 @@ def _evaluate(self, x: NDArrayFloat) -> NDArrayFloat: return y[0] return y - def _validate_dimensions(self): + def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): @@ -1218,7 +1218,7 @@ def _validate_dimensions(self): f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) - def _validate_interpolation_range(self, x: NDArrayFloat): + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" below_interpolation_range = x < self._x[0] @@ -1294,7 +1294,7 @@ def y(self) -> NDArrayFloat: return self._y @y.setter - def y(self, value: ArrayLike): + def y(self, value: ArrayLike) -> None: """Setter for the **self.y** property.""" self._y = as_float_array(value) @@ -1397,7 +1397,7 @@ def x(self) -> NDArrayFloat: return self._x @x.setter - def x(self, value: ArrayLike): + def x(self, value: ArrayLike) -> None: """Setter for the **self.x** property.""" value = cast(NDArrayFloat, np.atleast_1d(value).astype(self._dtype)) @@ -1430,7 +1430,7 @@ def y(self) -> NDArrayFloat: return self._y @y.setter - def y(self, value: ArrayLike): + def y(self, value: ArrayLike) -> None: """Setter for the **self.y** property.""" value = cast(NDArrayFloat, np.atleast_1d(value).astype(self._dtype)) @@ -1461,7 +1461,7 @@ def relative_tolerance(self) -> float: return self._relative_tolerance @relative_tolerance.setter - def relative_tolerance(self, value: float): + def relative_tolerance(self, value: float) -> None: """Setter for the **self.relative_tolerance** property.""" attest( @@ -1490,7 +1490,7 @@ def absolute_tolerance(self) -> float: return self._absolute_tolerance @absolute_tolerance.setter - def absolute_tolerance(self, value: float): + def absolute_tolerance(self, value: float) -> None: """Setter for the **self.absolute_tolerance** property.""" attest( @@ -1520,7 +1520,7 @@ def default(self) -> float: return self._default @default.setter - def default(self, value: float): + def default(self, value: float) -> None: """Setter for the **self.default** property.""" attest(is_numeric(value), '"default" variable must be a "numeric"!') @@ -1580,7 +1580,7 @@ def _evaluate(self, x: NDArrayFloat) -> NDArrayFloat: return np.squeeze(values) - def _validate_dimensions(self): + def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): @@ -1589,7 +1589,7 @@ def _validate_dimensions(self): f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) - def _validate_interpolation_range(self, x: NDArrayFloat): + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" below_interpolation_range = x < self._x[0] diff --git a/colour/algebra/tests/test_common.py b/colour/algebra/tests/test_common.py index 1a7845ef9..d897296e4 100644 --- a/colour/algebra/tests/test_common.py +++ b/colour/algebra/tests/test_common.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.algebra.common` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -63,7 +65,7 @@ class TestGetSdivMode: methods. """ - def test_get_sdiv_mode(self): + def test_get_sdiv_mode(self) -> None: """Test :func:`colour.algebra.common.get_sdiv_mode` definition.""" with sdiv_mode("Numpy"): @@ -97,7 +99,7 @@ class TestSetSdivMode: methods. """ - def test_set_sdiv_mode(self): + def test_set_sdiv_mode(self) -> None: """Test :func:`colour.algebra.common.set_sdiv_mode` definition.""" with sdiv_mode(get_sdiv_mode()): @@ -132,7 +134,7 @@ class TestSdivMode: tests methods. """ - def test_sdiv_mode(self): + def test_sdiv_mode(self) -> None: """Test :func:`colour.algebra.common.sdiv_mode` definition.""" with sdiv_mode("Raise"): @@ -142,7 +144,7 @@ def test_sdiv_mode(self): assert get_sdiv_mode() == "ignore zero conversion" @sdiv_mode("Raise") - def fn_a(): + def fn_a() -> None: """:func:`sdiv_mode` unit tests :func:`fn_a` definition.""" assert get_sdiv_mode() == "raise" @@ -150,7 +152,7 @@ def fn_a(): fn_a() @sdiv_mode("Ignore Zero Conversion") - def fn_b(): + def fn_b() -> None: """:func:`sdiv_mode` unit tests :func:`fn_b` definition.""" assert get_sdiv_mode() == "ignore zero conversion" @@ -164,7 +166,7 @@ class TestSdiv: tests methods. """ - def test_sdiv(self): + def test_sdiv(self) -> None: """Test :func:`colour.algebra.common.sdiv` definition.""" a = np.array([0, 1, 2]) @@ -204,7 +206,7 @@ class TestIsSpowEnabled: tests methods. """ - def test_is_spow_enabled(self): + def test_is_spow_enabled(self) -> None: """Test :func:`colour.algebra.common.is_spow_enabled` definition.""" with spow_enable(True): @@ -220,7 +222,7 @@ class TestSetSpowEnabled: tests methods. """ - def test_set_spow_enable(self): + def test_set_spow_enable(self) -> None: """Test :func:`colour.algebra.common.set_spow_enable` definition.""" with spow_enable(is_spow_enabled()): @@ -238,7 +240,7 @@ class TestSpowEnable: tests methods. """ - def test_spow_enable(self): + def test_spow_enable(self) -> None: """Test :func:`colour.algebra.common.spow_enable` definition.""" with spow_enable(True): @@ -248,7 +250,7 @@ def test_spow_enable(self): assert not is_spow_enabled() @spow_enable(True) - def fn_a(): + def fn_a() -> None: """:func:`spow_enable` unit tests :func:`fn_a` definition.""" assert is_spow_enabled() @@ -256,7 +258,7 @@ def fn_a(): fn_a() @spow_enable(False) - def fn_b(): + def fn_b() -> None: """:func:`spow_enable` unit tests :func:`fn_b` definition.""" assert not is_spow_enabled() @@ -270,7 +272,7 @@ class TestSpow: tests methods. """ - def test_spow(self): + def test_spow(self) -> None: """Test :func:`colour.algebra.common.spow` definition.""" assert spow(2, 2) == 4.0 @@ -298,7 +300,7 @@ class TestNormaliseVector: tests methods. """ - def test_normalise_vector(self): + def test_normalise_vector(self) -> None: """Test :func:`colour.algebra.common.normalise_vector` definition.""" np.testing.assert_allclose( @@ -326,7 +328,7 @@ class TestNormaliseMaximum: tests methods. """ - def test_normalise_maximum(self): + def test_normalise_maximum(self) -> None: """Test :func:`colour.algebra.common.normalise_maximum` definition.""" np.testing.assert_allclose( @@ -405,7 +407,7 @@ class TestVectorDot: methods. """ - def test_vecmul(self): + def test_vecmul(self) -> None: """Test :func:`colour.algebra.common.vecmul` definition.""" m = np.array( @@ -442,7 +444,7 @@ class TestEuclideanDistance: tests methods. """ - def test_euclidean_distance(self): + def test_euclidean_distance(self) -> None: """Test :func:`colour.algebra.common.euclidean_distance` definition.""" np.testing.assert_allclose( @@ -472,7 +474,7 @@ def test_euclidean_distance(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_euclidean_distance(self): + def test_n_dimensional_euclidean_distance(self) -> None: """ Test :func:`colour.algebra.common.euclidean_distance` definition n-dimensional arrays support. @@ -497,7 +499,7 @@ def test_n_dimensional_euclidean_distance(self): ) @ignore_numpy_errors - def test_nan_euclidean_distance(self): + def test_nan_euclidean_distance(self) -> None: """ Test :func:`colour.algebra.common.euclidean_distance` definition nan support. @@ -514,7 +516,7 @@ class TestManhattanDistance: tests methods. """ - def test_manhattan_distance(self): + def test_manhattan_distance(self) -> None: """Test :func:`colour.algebra.common.manhattan_distance` definition.""" np.testing.assert_allclose( @@ -544,7 +546,7 @@ def test_manhattan_distance(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_manhattan_distance(self): + def test_n_dimensional_manhattan_distance(self) -> None: """ Test :func:`colour.algebra.common.manhattan_distance` definition n-dimensional arrays support. @@ -569,7 +571,7 @@ def test_n_dimensional_manhattan_distance(self): ) @ignore_numpy_errors - def test_nan_manhattan_distance(self): + def test_nan_manhattan_distance(self) -> None: """ Test :func:`colour.algebra.common.manhattan_distance` definition nan support. @@ -586,7 +588,7 @@ class TestLinearConversion: tests methods. """ - def test_linear_conversion(self): + def test_linear_conversion(self) -> None: """Test :func:`colour.algebra.common.linear_conversion` definition.""" np.testing.assert_allclose( @@ -617,7 +619,7 @@ class TestLinstepFunction: tests methods. """ - def test_linstep_function(self): + def test_linstep_function(self) -> None: """Test :func:`colour.algebra.common.linstep_function` definition.""" np.testing.assert_allclose( @@ -674,7 +676,7 @@ class TestSmoothstepFunction: tests methods. """ - def test_smoothstep_function(self): + def test_smoothstep_function(self) -> None: """Test :func:`colour.algebra.common.smoothstep_function` definition.""" assert smoothstep_function(0.5) == 0.5 @@ -700,7 +702,7 @@ class TestIsIdentity: methods. """ - def test_is_identity(self): + def test_is_identity(self) -> None: """Test :func:`colour.algebra.common.is_identity` definition.""" assert is_identity(np.reshape(np.array([1, 0, 0, 0, 1, 0, 0, 0, 1]), (3, 3))) @@ -720,7 +722,7 @@ class TestEigenDecomposition: tests methods. """ - def test_is_identity(self): + def test_is_identity(self) -> None: """Test :func:`colour.algebra.common.eigen_decomposition` definition.""" a = np.diag([1, 2, 3]) diff --git a/colour/algebra/tests/test_extrapolation.py b/colour/algebra/tests/test_extrapolation.py index a6affe869..16f1d066a 100644 --- a/colour/algebra/tests/test_extrapolation.py +++ b/colour/algebra/tests/test_extrapolation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.algebra.extrapolation` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -31,7 +33,7 @@ class TestExtrapolator: tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("interpolator",) @@ -39,7 +41,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Extrapolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__",) @@ -47,7 +49,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(Extrapolator) - def test_interpolator(self): + def test_interpolator(self) -> None: """ Test :attr:`colour.algebra.extrapolation.Extrapolator.interpolator` property. @@ -58,7 +60,7 @@ def test_interpolator(self): ) assert isinstance(extrapolator.interpolator, LinearInterpolator) - def test_method(self): + def test_method(self) -> None: """ Test :attr:`colour.algebra.extrapolation.Extrapolator.method` property. @@ -75,7 +77,7 @@ def test_method(self): ) assert extrapolator.method == "constant" - def test_left(self): + def test_left(self) -> None: """ Test :attr:`colour.algebra.extrapolation.Extrapolator.left` property. @@ -87,7 +89,7 @@ def test_left(self): ) assert extrapolator.left == 0 - def test_right(self): + def test_right(self) -> None: """ Test :attr:`colour.algebra.extrapolation.Extrapolator.right` property. @@ -99,7 +101,7 @@ def test_right(self): ) assert extrapolator.right == 0 - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.extrapolation.Extrapolator.__call__` method. @@ -155,7 +157,7 @@ def test__call__(self): assert extrapolator(9) == 7.0 @ignore_numpy_errors - def test_nan__call__(self): + def test_nan__call__(self) -> None: """ Test :method:`colour.algebra.extrapolation.Extrapolator.__call__` method nan support. diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index de0106389..7daf863df 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -506,7 +506,7 @@ class TestKernelNearestNeighbour: definition unit tests methods. """ - def test_kernel_nearest(self): + def test_kernel_nearest(self) -> None: """ Test :func:`colour.algebra.interpolation.kernel_nearest_neighbour` definition. @@ -553,7 +553,7 @@ class TestKernelLinear: unit tests methods. """ - def test_kernel_linear(self): + def test_kernel_linear(self) -> None: """Test :func:`colour.algebra.interpolation.kernel_linear` definition.""" np.testing.assert_allclose( @@ -597,7 +597,7 @@ class TestKernelSinc: unit tests methods. """ - def test_kernel_sinc(self): + def test_kernel_sinc(self) -> None: """Test :func:`colour.algebra.interpolation.kernel_sinc` definition.""" np.testing.assert_allclose( @@ -675,7 +675,7 @@ class TestKernelLanczos: unit tests methods. """ - def test_kernel_lanczos(self): + def test_kernel_lanczos(self) -> None: """Test :func:`colour.algebra.interpolation.kernel_lanczos` definition.""" np.testing.assert_allclose( @@ -753,7 +753,7 @@ class TestKernelCardinalSpline: definition unit tests methods. """ - def test_kernel_cardinal_spline(self): + def test_kernel_cardinal_spline(self) -> None: """ Test :func:`colour.algebra.interpolation.kernel_cardinal_spline` definition. @@ -834,7 +834,7 @@ class TestKernelInterpolator: tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -849,7 +849,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(KernelInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__call__") @@ -857,7 +857,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(KernelInterpolator) - def test_x(self): + def test_x(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.x` property. @@ -868,7 +868,7 @@ def test_x(self): np.testing.assert_equal(kernel_interpolator.x, x) - def test_y(self): + def test_y(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.y` property. @@ -879,7 +879,7 @@ def test_y(self): np.testing.assert_equal(kernel_interpolator.y, y) - def test_window(self): + def test_window(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.window` property. @@ -890,7 +890,7 @@ def test_window(self): assert kernel_interpolator.window == 3 - def test_kernel(self): + def test_kernel(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.kernel` property. @@ -901,7 +901,7 @@ def test_kernel(self): assert kernel_interpolator.kernel is kernel_linear - def test_kernel_kwargs(self): + def test_kernel_kwargs(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.\ kernel_kwargs` property. @@ -913,7 +913,7 @@ def test_kernel_kwargs(self): assert kernel_interpolator.kernel_kwargs == kernel_kwargs - def test_padding_kwargs(self): + def test_padding_kwargs(self) -> None: """ Test :attr:`colour.algebra.interpolation.KernelInterpolator.\ padding_kwargs` property. @@ -925,7 +925,7 @@ def test_padding_kwargs(self): assert kernel_interpolator.padding_kwargs == padding_kwargs - def test_raise_exception___init__(self): + def test_raise_exception___init__(self) -> None: """ Test :meth:`colour.algebra.interpolation.KernelInterpolator.__init__` method raised exception. @@ -938,7 +938,7 @@ def test_raise_exception___init__(self): np.linspace(0, 1, 15), ) - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.KernelInterpolator.__call__` method. @@ -1143,7 +1143,7 @@ def test__call__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception___call__(self): + def test_raise_exception___call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.KernelInterpolator.__call__` method raised exception. @@ -1157,7 +1157,7 @@ def test_raise_exception___call__(self): pytest.raises(ValueError, kernel_interpolator, 11) @ignore_numpy_errors - def test_nan__call__(self): + def test_nan__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.KernelInterpolator.__call__` method nan support. @@ -1175,7 +1175,7 @@ class TestNearestNeighbourInterpolator: class unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = () @@ -1183,7 +1183,7 @@ def test_required_attributes(self): for attribute in required_attributes: # pragma: no cover assert attribute in dir(NearestNeighbourInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__",) @@ -1191,7 +1191,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(NearestNeighbourInterpolator) - def test___init__(self): + def test___init__(self) -> None: """ Test :meth:`colour.algebra.interpolation.KernelInterpolator.__init__` method. @@ -1211,7 +1211,7 @@ class TestLinearInterpolator: tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("x", "y") @@ -1219,7 +1219,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(LinearInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__call__") @@ -1227,7 +1227,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(LinearInterpolator) - def test_raise_exception___init__(self): + def test_raise_exception___init__(self) -> None: """ Test :meth:`colour.algebra.interpolation.LinearInterpolator.__init__` method raised exception. @@ -1236,7 +1236,7 @@ def test_raise_exception___init__(self): x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) pytest.raises(ValueError, LinearInterpolator, x, y) - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.LinearInterpolator.__call__` method. @@ -1263,7 +1263,7 @@ def test__call__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception___call__(self): + def test_raise_exception___call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.LinearInterpolator.__call__` method raised exception. @@ -1277,7 +1277,7 @@ def test_raise_exception___call__(self): pytest.raises(ValueError, linear_interpolator, 11) @ignore_numpy_errors - def test_nan__call__(self): + def test_nan__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.LinearInterpolator.__call__` method nan support. @@ -1299,7 +1299,7 @@ class TestSpragueInterpolator: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("x", "y") @@ -1307,7 +1307,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(SpragueInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__call__") @@ -1315,7 +1315,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(SpragueInterpolator) - def test_raise_exception___init__(self): + def test_raise_exception___init__(self) -> None: """ Test :meth:`colour.algebra.interpolation.SpragueInterpolator.__init__` method raised exception. @@ -1324,7 +1324,7 @@ def test_raise_exception___init__(self): x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) pytest.raises(ValueError, SpragueInterpolator, x, y) - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.SpragueInterpolator.__call__` method. @@ -1351,7 +1351,7 @@ def test__call__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception___call__(self): + def test_raise_exception___call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.SpragueInterpolator.__call__` method raised exception. @@ -1365,7 +1365,7 @@ def test_raise_exception___call__(self): pytest.raises(ValueError, sprague_interpolator, 11) @ignore_numpy_errors - def test_nan__call__(self): + def test_nan__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.SpragueInterpolator.__call__` method nan support. @@ -1387,7 +1387,7 @@ class TestCubicSplineInterpolator: unit tests methods. """ - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.CubicSplineInterpolator.\ __call__` method. @@ -1413,7 +1413,7 @@ class TestPchipInterpolator: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("x", "y") @@ -1421,7 +1421,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(PchipInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__",) @@ -1429,7 +1429,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(PchipInterpolator) - def test_y(self): + def test_y(self) -> None: """ Test :attr:`colour.algebra.interpolation.PchipInterpolator.y` property. """ @@ -1447,7 +1447,7 @@ class TestNullInterpolator: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("x", "y") @@ -1455,7 +1455,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(NullInterpolator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__call__") @@ -1463,7 +1463,7 @@ def test_required_methods(self): for method in required_methods: # pragma: no cover assert method in dir(NullInterpolator) - def test_x(self): + def test_x(self) -> None: """ Test :attr:`colour.algebra.interpolation.NullInterpolator.x` property. @@ -1474,7 +1474,7 @@ def test_x(self): np.testing.assert_equal(null_interpolator.x, x) - def test_y(self): + def test_y(self) -> None: """ Test :attr:`colour.algebra.interpolation.NullInterpolator.y` property. @@ -1485,7 +1485,7 @@ def test_y(self): np.testing.assert_equal(null_interpolator.y, y) - def test_absolute_tolerance(self): + def test_absolute_tolerance(self) -> None: """ Test :attr:`colour.algebra.interpolation.NullInterpolator.\ absolute_tolerance` property. @@ -1496,7 +1496,7 @@ def test_absolute_tolerance(self): np.testing.assert_equal(null_interpolator.absolute_tolerance, 0.1) - def test_relative_tolerance(self): + def test_relative_tolerance(self) -> None: """ Test :attr:`colour.algebra.interpolation.NullInterpolator.\ relative_tolerance` property. @@ -1507,7 +1507,7 @@ def test_relative_tolerance(self): np.testing.assert_equal(null_interpolator.relative_tolerance, 0.1) - def test_default(self): + def test_default(self) -> None: """ Test :attr:`colour.algebra.interpolation.NullInterpolator.\ default` property. @@ -1518,7 +1518,7 @@ def test_default(self): np.testing.assert_equal(null_interpolator.default, 0) - def test_raise_exception___init__(self): + def test_raise_exception___init__(self) -> None: """ Test :meth:`colour.algebra.interpolation.NullInterpolator.__init__` method raised exception. @@ -1527,7 +1527,7 @@ def test_raise_exception___init__(self): x, y = np.linspace(0, 1, 10), np.linspace(0, 1, 15) pytest.raises(ValueError, NullInterpolator, x, y) - def test__call__(self): + def test__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.NullInterpolator.__call__` method. @@ -1548,7 +1548,7 @@ def test__call__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception___call__(self): + def test_raise_exception___call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.NullInterpolator.__call__` method raised exception. @@ -1562,7 +1562,7 @@ def test_raise_exception___call__(self): pytest.raises(ValueError, null_interpolator, 11) @ignore_numpy_errors - def test_nan__call__(self): + def test_nan__call__(self) -> None: """ Test :meth:`colour.algebra.interpolation.NullInterpolator.__call__` method nan support. @@ -1584,7 +1584,7 @@ class TestLagrangeCoefficients: definition unit tests methods. """ - def test_lagrange_coefficients(self): + def test_lagrange_coefficients(self) -> None: """ Test :func:`colour.algebra.interpolation.lagrange_coefficients` definition. @@ -1616,7 +1616,7 @@ class TestVerticesAndRelativeCoordinates: vertices_and_relative_coordinates` definition unit tests methods. """ - def test_vertices_and_relative_coordinates(self): + def test_vertices_and_relative_coordinates(self) -> None: """ Test :func:`colour.algebra.interpolation.\ vertices_and_relative_coordinates` definition. @@ -1704,7 +1704,7 @@ class TestTableInterpolationTrilinear: table_interpolation_trilinear` definition unit tests methods. """ - def test_interpolation_trilinear(self): + def test_interpolation_trilinear(self) -> None: """ Test :func:`colour.algebra.interpolation.\ table_interpolation_trilinear` definition. @@ -1746,7 +1746,7 @@ class TestTableInterpolationTetrahedral: table_interpolation_tetrahedral` definition unit tests methods. """ - def test_interpolation_tetrahedral(self): + def test_interpolation_tetrahedral(self) -> None: """ Test :func:`colour.algebra.interpolation.\ table_interpolation_tetrahedral` definition. diff --git a/colour/algebra/tests/test_prng.py b/colour/algebra/tests/test_prng.py index 1245218e5..86e98dbec 100644 --- a/colour/algebra/tests/test_prng.py +++ b/colour/algebra/tests/test_prng.py @@ -52,7 +52,7 @@ class TestRandomTripletGenerator: unit tests methods. """ - def test_random_triplet_generator(self): + def test_random_triplet_generator(self) -> None: """ Test :func:`colour.algebra.prng.random_triplet_generator` definition. diff --git a/colour/algebra/tests/test_regression.py b/colour/algebra/tests/test_regression.py index cbe2b7706..e9732aa03 100644 --- a/colour/algebra/tests/test_regression.py +++ b/colour/algebra/tests/test_regression.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.algebra.regression` module.""" +from __future__ import annotations + import numpy as np from colour.algebra import least_square_mapping_MoorePenrose @@ -23,7 +25,7 @@ class TestLeastSquareMappingMoorePenrose: least_square_mapping_MoorePenrose` definition unit tests methods. """ - def test_least_square_mapping_MoorePenrose(self): + def test_least_square_mapping_MoorePenrose(self) -> None: """ Test :func:`colour.algebra.regression.\ least_square_mapping_MoorePenrose` definition. diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 627cc6ae8..cf85d0a02 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -105,7 +105,13 @@ class InductionFactors_Hunt( :cite:`Fairchild2013u`, :cite:`Hunt2004b` """ - def __new__(cls, N_c, N_b, N_cb=None, N_bb=None): + def __new__( + cls, + N_c: float, + N_b: float, + N_cb: float | None = None, + N_bb: float | None = None, + ) -> InductionFactors_Hunt: """ Return a new instance of the :class:`colour.appearance.InductionFactors_Hunt` class. @@ -655,8 +661,8 @@ def chromatic_adaptation( XYZ: ArrayLike, XYZ_w: ArrayLike, XYZ_b: ArrayLike, - L_A, - F_L, + L_A: ArrayLike, + F_L: ArrayLike, XYZ_p: ArrayLike | None = None, p: ArrayLike | None = None, helson_judd_effect: bool = False, diff --git a/colour/appearance/kim2009.py b/colour/appearance/kim2009.py index 8c296c342..5e4e4622b 100644 --- a/colour/appearance/kim2009.py +++ b/colour/appearance/kim2009.py @@ -130,7 +130,7 @@ class MediaParameters_Kim2009(namedtuple("MediaParameters_Kim2009", ("E",))): :cite:`Kim2009` """ - def __new__(cls, E): + def __new__(cls, E: float) -> MediaParameters_Kim2009: """ Return a new instance of the :class:`colour.appearance.MediaParameters_Kim2009` class. diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index 556194913..4286d3fec 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.atd95` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestXYZ_to_ATD95: tests methods. """ - def test_XYZ_to_ATD95(self): + def test_XYZ_to_ATD95(self) -> None: """ Test :func:`colour.appearance.atd95.XYZ_to_ATD95` definition. @@ -126,7 +128,7 @@ def test_XYZ_to_ATD95(self): atol=0.01, ) - def test_n_dimensional_XYZ_to_ATD95(self): + def test_n_dimensional_XYZ_to_ATD95(self) -> None: """ Test :func:`colour.appearance.atd95.XYZ_to_ATD95` definition n-dimensional support. @@ -165,7 +167,7 @@ def test_n_dimensional_XYZ_to_ATD95(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_ATD95(self): + def test_domain_range_scale_XYZ_to_ATD95(self) -> None: """ Test :func:`colour.appearance.atd95.XYZ_to_ATD95` definition domain and range scale support. @@ -192,7 +194,7 @@ def test_domain_range_scale_XYZ_to_ATD95(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_ATD95(self): + def test_nan_XYZ_to_ATD95(self) -> None: """ Test :func:`colour.appearance.atd95.XYZ_to_ATD95` definition nan support. diff --git a/colour/appearance/tests/test_cam16.py b/colour/appearance/tests/test_cam16.py index c256901ca..db71d8d6b 100644 --- a/colour/appearance/tests/test_cam16.py +++ b/colour/appearance/tests/test_cam16.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.cam16` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -39,7 +41,7 @@ class TestXYZ_to_CAM16: tests methods. """ - def test_XYZ_to_CAM16(self): + def test_XYZ_to_CAM16(self) -> None: """Test :func:`colour.appearance.cam16.XYZ_to_CAM16` definition.""" XYZ = np.array([19.01, 20.00, 21.78]) @@ -142,7 +144,7 @@ def test_XYZ_to_CAM16(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_CAM16(self): + def test_n_dimensional_XYZ_to_CAM16(self) -> None: """ Test :func:`colour.appearance.cam16.XYZ_to_CAM16` definition n-dimensional support. @@ -180,7 +182,7 @@ def test_n_dimensional_XYZ_to_CAM16(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_CAM16(self): + def test_domain_range_scale_XYZ_to_CAM16(self) -> None: """ Test :func:`colour.appearance.cam16.XYZ_to_CAM16` definition domain and range scale support. @@ -226,7 +228,7 @@ def test_domain_range_scale_XYZ_to_CAM16(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CAM16(self): + def test_nan_XYZ_to_CAM16(self) -> None: """ Test :func:`colour.appearance.cam16.XYZ_to_CAM16` definition nan support. @@ -244,7 +246,7 @@ class TestCAM16_to_XYZ: methods. """ - def test_CAM16_to_XYZ(self): + def test_CAM16_to_XYZ(self) -> None: """Test :func:`colour.appearance.cam16.CAM16_to_XYZ` definition.""" specification = CAM_Specification_CAM16(41.73120791, 0.10335574, 217.06795977) @@ -292,7 +294,7 @@ def test_CAM16_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CAM16_to_XYZ(self): + def test_n_dimensional_CAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.cam16.CAM16_to_XYZ` definition n-dimensional support. @@ -307,7 +309,7 @@ def test_n_dimensional_CAM16_to_XYZ(self): XYZ = CAM16_to_XYZ(specification, XYZ_w, L_A, Y_b, surround) specification = CAM_Specification_CAM16( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -324,7 +326,7 @@ def test_n_dimensional_CAM16_to_XYZ(self): ) specification = CAM_Specification_CAM16( - *tsplit(np.reshape(specification, (2, 3, 8))).tolist() + *tsplit(np.reshape(specification, (2, 3, 8))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -335,7 +337,7 @@ def test_n_dimensional_CAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_CAM16_to_XYZ(self): + def test_domain_range_scale_CAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.cam16.CAM16_to_XYZ` definition domain and range scale support. @@ -388,7 +390,7 @@ def test_domain_range_scale_CAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_CAM16_to_XYZ(self): + def test_raise_exception_CAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.cam16.CAM16_to_XYZ` definition raised exception. @@ -405,7 +407,7 @@ def test_raise_exception_CAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_CAM16_to_XYZ(self): + def test_nan_CAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.cam16.CAM16_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_ciecam02.py b/colour/appearance/tests/test_ciecam02.py index f128973ef..befee836a 100644 --- a/colour/appearance/tests/test_ciecam02.py +++ b/colour/appearance/tests/test_ciecam02.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.ciecam02` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -39,7 +41,7 @@ class TestXYZ_to_CIECAM02: tests methods. """ - def test_XYZ_to_CIECAM02(self): + def test_XYZ_to_CIECAM02(self) -> None: """ Test :func:`colour.appearance.ciecam02.XYZ_to_CIECAM02` definition. @@ -106,7 +108,7 @@ def test_XYZ_to_CIECAM02(self): atol=0.05, ) - def test_n_dimensional_XYZ_to_CIECAM02(self): + def test_n_dimensional_XYZ_to_CIECAM02(self) -> None: """ Test :func:`colour.appearance.ciecam02.XYZ_to_CIECAM02` definition n-dimensional support. @@ -144,7 +146,7 @@ def test_n_dimensional_XYZ_to_CIECAM02(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_CIECAM02(self): + def test_domain_range_scale_XYZ_to_CIECAM02(self) -> None: """ Test :func:`colour.appearance.ciecam02.XYZ_to_CIECAM02` definition domain and range scale support. @@ -192,7 +194,7 @@ def test_domain_range_scale_XYZ_to_CIECAM02(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CIECAM02(self): + def test_nan_XYZ_to_CIECAM02(self) -> None: """ Test :func:`colour.appearance.ciecam02.XYZ_to_CIECAM02` definition nan support. @@ -210,7 +212,7 @@ class TestCIECAM02_to_XYZ: tests methods. """ - def test_CIECAM02_to_XYZ(self): + def test_CIECAM02_to_XYZ(self) -> None: """Test :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition.""" specification = CAM_Specification_CIECAM02( @@ -275,7 +277,7 @@ def test_CIECAM02_to_XYZ(self): atol=0.05, ) - def test_n_dimensional_CIECAM02_to_XYZ(self): + def test_n_dimensional_CIECAM02_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition n-dimensional support. @@ -290,7 +292,7 @@ def test_n_dimensional_CIECAM02_to_XYZ(self): XYZ = CIECAM02_to_XYZ(specification, XYZ_w, L_A, Y_b, surround) specification = CAM_Specification_CIECAM02( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -307,7 +309,7 @@ def test_n_dimensional_CIECAM02_to_XYZ(self): ) specification = CAM_Specification_CIECAM02( - *tsplit(np.reshape(specification, (2, 3, 8))).tolist() + *tsplit(np.reshape(specification, (2, 3, 8))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -318,7 +320,7 @@ def test_n_dimensional_CIECAM02_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_CIECAM02_to_XYZ(self): + def test_domain_range_scale_CIECAM02_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition domain and range scale support. @@ -371,7 +373,7 @@ def test_domain_range_scale_CIECAM02_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_CIECAM02_to_XYZ(self): + def test_raise_exception_CIECAM02_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition raised exception. @@ -388,7 +390,7 @@ def test_raise_exception_CIECAM02_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_CIECAM02_to_XYZ(self): + def test_nan_CIECAM02_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam02.CIECAM02_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_ciecam16.py b/colour/appearance/tests/test_ciecam16.py index da6d4ec10..21e95e161 100644 --- a/colour/appearance/tests/test_ciecam16.py +++ b/colour/appearance/tests/test_ciecam16.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.ciecam16` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -39,7 +41,7 @@ class TestXYZ_to_CIECAM16: tests methods. """ - def test_XYZ_to_CIECAM16(self): + def test_XYZ_to_CIECAM16(self) -> None: """ Test :func:`colour.appearance.ciecam16.XYZ_to_CIECAM16` definition. """ @@ -165,7 +167,7 @@ def test_XYZ_to_CIECAM16(self): atol=5e-5, ) - def test_n_dimensional_XYZ_to_CIECAM16(self): + def test_n_dimensional_XYZ_to_CIECAM16(self) -> None: """ Test :func:`colour.appearance.ciecam16.XYZ_to_CIECAM16` definition n-dimensional support. @@ -203,7 +205,7 @@ def test_n_dimensional_XYZ_to_CIECAM16(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_CIECAM16(self): + def test_domain_range_scale_XYZ_to_CIECAM16(self) -> None: """ Test :func:`colour.appearance.ciecam16.XYZ_to_CIECAM16` definition domain and range scale support. @@ -251,7 +253,7 @@ def test_domain_range_scale_XYZ_to_CIECAM16(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CIECAM16(self): + def test_nan_XYZ_to_CIECAM16(self) -> None: """ Test :func:`colour.appearance.ciecam16.XYZ_to_CIECAM16` definition nan support. @@ -269,7 +271,7 @@ class TestCIECAM16_to_XYZ: tests methods. """ - def test_CIECAM16_to_XYZ(self): + def test_CIECAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition. """ @@ -339,7 +341,7 @@ def test_CIECAM16_to_XYZ(self): atol=1e-4, ) - def test_n_dimensional_CIECAM16_to_XYZ(self): + def test_n_dimensional_CIECAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition n-dimensional support. @@ -354,7 +356,7 @@ def test_n_dimensional_CIECAM16_to_XYZ(self): XYZ = CIECAM16_to_XYZ(specification, XYZ_w, L_A, Y_b, surround) specification = CAM_Specification_CIECAM16( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -371,7 +373,7 @@ def test_n_dimensional_CIECAM16_to_XYZ(self): ) specification = CAM_Specification_CIECAM16( - *tsplit(np.reshape(specification, (2, 3, 8))).tolist() + *tsplit(np.reshape(specification, (2, 3, 8))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -382,7 +384,7 @@ def test_n_dimensional_CIECAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_CIECAM16_to_XYZ(self): + def test_domain_range_scale_CIECAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition domain and range scale support. @@ -435,7 +437,7 @@ def test_domain_range_scale_CIECAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_CIECAM16_to_XYZ(self): + def test_raise_exception_CIECAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition raised exception. @@ -452,7 +454,7 @@ def test_raise_exception_CIECAM16_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_CIECAM16_to_XYZ(self): + def test_nan_CIECAM16_to_XYZ(self) -> None: """ Test :func:`colour.appearance.ciecam16.CIECAM16_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_hellwig2022.py b/colour/appearance/tests/test_hellwig2022.py index 730bab5fc..288d8237e 100644 --- a/colour/appearance/tests/test_hellwig2022.py +++ b/colour/appearance/tests/test_hellwig2022.py @@ -7,6 +7,8 @@ Discussion with Mansencal, T. """ +from __future__ import annotations + from itertools import product import numpy as np @@ -46,7 +48,7 @@ class TestXYZ_to_Hellwig2022: unit tests methods. """ - def test_XYZ_to_Hellwig2022(self): + def test_XYZ_to_Hellwig2022(self) -> None: """ Test :func:`colour.appearance.hellwig2022.XYZ_to_Hellwig2022` definition. @@ -141,7 +143,7 @@ def test_XYZ_to_Hellwig2022(self): atol=0.01, ) - def test_n_dimensional_XYZ_to_Hellwig2022(self): + def test_n_dimensional_XYZ_to_Hellwig2022(self) -> None: """ Test :func:`colour.appearance.hellwig2022.XYZ_to_Hellwig2022` definition n-dimensional support. @@ -179,7 +181,7 @@ def test_n_dimensional_XYZ_to_Hellwig2022(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_Hellwig2022(self): + def test_domain_range_scale_XYZ_to_Hellwig2022(self) -> None: """ Test :func:`colour.appearance.hellwig2022.XYZ_to_Hellwig2022` definition domain and range scale support. @@ -229,7 +231,7 @@ def test_domain_range_scale_XYZ_to_Hellwig2022(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Hellwig2022(self): + def test_nan_XYZ_to_Hellwig2022(self) -> None: """ Test :func:`colour.appearance.hellwig2022.XYZ_to_Hellwig2022 definition nan support. @@ -247,7 +249,7 @@ class TestHellwig2022_to_XYZ: unit tests methods. """ - def test_Hellwig2022_to_XYZ(self): + def test_Hellwig2022_to_XYZ(self) -> None: """ Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition. @@ -310,7 +312,7 @@ def test_Hellwig2022_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Hellwig2022_to_XYZ(self): + def test_n_dimensional_Hellwig2022_to_XYZ(self) -> None: """ Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition n-dimensional support. @@ -325,7 +327,7 @@ def test_n_dimensional_Hellwig2022_to_XYZ(self): XYZ = Hellwig2022_to_XYZ(specification, XYZ_w, L_A, Y_b, surround) specification = CAM_Specification_Hellwig2022( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -342,7 +344,7 @@ def test_n_dimensional_Hellwig2022_to_XYZ(self): ) specification = CAM_Specification_Hellwig2022( - *tsplit(np.reshape(specification, (2, 3, 10))).tolist() + *tsplit(np.reshape(specification, (2, 3, 10))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -353,7 +355,7 @@ def test_n_dimensional_Hellwig2022_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_Hellwig2022_to_XYZ(self): + def test_domain_range_scale_Hellwig2022_to_XYZ(self) -> None: """ Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition domain and range scale support. @@ -408,7 +410,7 @@ def test_domain_range_scale_Hellwig2022_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_Hellwig2022_to_XYZ(self): + def test_raise_exception_Hellwig2022_to_XYZ(self) -> None: """ Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition raised exception. @@ -436,7 +438,7 @@ def test_raise_exception_Hellwig2022_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Hellwig2022_to_XYZ(self): + def test_nan_Hellwig2022_to_XYZ(self) -> None: """ Test :func:`colour.appearance.hellwig2022.Hellwig2022_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_hke.py b/colour/appearance/tests/test_hke.py index 2bd07867b..ae66d687f 100644 --- a/colour/appearance/tests/test_hke.py +++ b/colour/appearance/tests/test_hke.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.hke` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestHelmholtzKohlrauschEffectObjectNayatani1997: HelmholtzKohlrausch_effect_object_Nayatani1997` definition unit tests methods. """ - def test_HelmholtzKohlrausch_effect_object_Nayatani1997(self): + def test_HelmholtzKohlrausch_effect_object_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_object_Nayatani1997` definition. @@ -64,7 +66,7 @@ def test_HelmholtzKohlrausch_effect_object_Nayatani1997(self): def test_n_dimensional_HelmholtzKohlrausch_effect_object_Nayatani1997( self, - ): + ) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_object_Nayatani1997` definition n_dimensional @@ -125,7 +127,7 @@ def test_n_dimensional_HelmholtzKohlrausch_effect_object_Nayatani1997( ) @ignore_numpy_errors - def test_nan_HelmholtzKohlrausch_effect_object_Nayatani1997(self): + def test_nan_HelmholtzKohlrausch_effect_object_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_object_Nayatani1997` definition nan support. @@ -144,7 +146,7 @@ class TestHelmholtzKohlrauschEffectLuminousNayatani1997: methods. """ - def test_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self): + def test_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_luminous_Nayatani1997` definition. @@ -174,7 +176,7 @@ def test_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self): def test_n_dimensional_HelmholtzKohlrausch_effect_luminous_Nayatani1997( self, - ): + ) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_luminous_Nayatani1997` definition n_dimensional @@ -235,7 +237,7 @@ def test_n_dimensional_HelmholtzKohlrausch_effect_luminous_Nayatani1997( ) @ignore_numpy_errors - def test_nan_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self): + def test_nan_HelmholtzKohlrausch_effect_luminous_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.\ HelmholtzKohlrausch_effect_luminous_Nayatani1997` definition nan support. @@ -253,7 +255,7 @@ class TestCoefficient_K_Br_Nayatani1997: definition unit tests methods. """ - def test_coefficient_K_Br_Nayatani1997(self): + def test_coefficient_K_Br_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_K_Br_Nayatani1997` definition. @@ -283,7 +285,7 @@ def test_coefficient_K_Br_Nayatani1997(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_coefficient_K_Br_Nayatani1997(self): + def test_n_dimensional_coefficient_K_Br_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_K_Br_Nayatani1997` definition n_dimensional arrays support. @@ -317,7 +319,7 @@ def test_n_dimensional_coefficient_K_Br_Nayatani1997(self): ) @ignore_numpy_errors - def test_nan_coefficient_K_Br_Nayatani1997(self): + def test_nan_coefficient_K_Br_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_K_Br_Nayatani1997` definition nan support. @@ -333,7 +335,7 @@ class TestCoefficient_q_Nayatani1997: definition unit tests methods. """ - def test_coefficient_q_Nayatani1997(self): + def test_coefficient_q_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_q_Nayatani1997` definition. @@ -363,7 +365,7 @@ def test_coefficient_q_Nayatani1997(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_coefficient_q_Nayatani1997(self): + def test_n_dimensional_coefficient_q_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_q_Nayatani1997` definition n_dimensional arrays support. @@ -391,7 +393,7 @@ def test_n_dimensional_coefficient_q_Nayatani1997(self): ) @ignore_numpy_errors - def test_nan_coefficient_q_Nayatani1997(self): + def test_nan_coefficient_q_Nayatani1997(self) -> None: """ Test :func:`colour.appearance.hke.coefficient_q_Nayatani1997` definition nan support. diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index db909d06c..00dd6bdd4 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.hunt` module.""" +from __future__ import annotations + import contextlib from itertools import product @@ -35,7 +37,7 @@ class TestXYZ_to_Hunt: methods. """ - def test_XYZ_to_Hunt(self): + def test_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition. @@ -84,7 +86,7 @@ def test_XYZ_to_Hunt(self): atol=0.05, ) - def test_n_dimensional_XYZ_to_Hunt(self): + def test_n_dimensional_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition n-dimensional support. @@ -124,7 +126,7 @@ def test_n_dimensional_XYZ_to_Hunt(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Hunt(self): + def test_domain_range_scale_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition domain and range scale support. @@ -159,7 +161,7 @@ def test_domain_range_scale_XYZ_to_Hunt(self): ) @ignore_numpy_errors - def test_raise_exception_XYZ_to_Hunt(self): + def test_raise_exception_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition raised exception. @@ -183,7 +185,7 @@ def test_raise_exception_XYZ_to_Hunt(self): XYZ_to_Hunt(XYZ, XYZ_w, XYZ_b, L_A, surround, CCT_w=CCT_w, S_w=S_w) @ignore_numpy_errors - def test_XYZ_p_XYZ_to_Hunt(self): + def test_XYZ_p_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition *XYZ_p* argument handling. @@ -222,7 +224,7 @@ def test_XYZ_p_XYZ_to_Hunt(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Hunt(self): + def test_nan_XYZ_to_Hunt(self) -> None: """ Test :func:`colour.appearance.hunt.XYZ_to_Hunt` definition nan support. diff --git a/colour/appearance/tests/test_kim2009.py b/colour/appearance/tests/test_kim2009.py index 45dd85df1..a79a50c29 100644 --- a/colour/appearance/tests/test_kim2009.py +++ b/colour/appearance/tests/test_kim2009.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.kim2009` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -41,7 +43,7 @@ class TestXYZ_to_Kim2009: tests methods. """ - def test_XYZ_to_Kim2009(self): + def test_XYZ_to_Kim2009(self) -> None: """Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition.""" XYZ = np.array([19.01, 20.00, 21.78]) @@ -124,7 +126,7 @@ def test_XYZ_to_Kim2009(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Kim2009(self): + def test_n_dimensional_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition n-dimensional support. @@ -162,7 +164,7 @@ def test_n_dimensional_XYZ_to_Kim2009(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_Kim2009(self): + def test_domain_range_scale_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition domain and range scale support. @@ -210,7 +212,7 @@ def test_domain_range_scale_XYZ_to_Kim2009(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Kim2009(self): + def test_nan_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition nan support. @@ -229,7 +231,7 @@ class TestKim2009_to_XYZ: tests methods. """ - def test_Kim2009_to_XYZ(self): + def test_Kim2009_to_XYZ(self) -> None: """Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition.""" specification = CAM_Specification_Kim2009( @@ -304,7 +306,7 @@ def test_Kim2009_to_XYZ(self): atol=0.01, ) - def test_n_dimensional_Kim2009_to_XYZ(self): + def test_n_dimensional_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition n-dimensional support. @@ -319,7 +321,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): XYZ = Kim2009_to_XYZ(specification, XYZ_w, L_a, media, surround) specification = CAM_Specification_Kim2009( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -336,7 +338,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): ) specification = CAM_Specification_Kim2009( - *tsplit(np.reshape(specification, (2, 3, 8))).tolist() + *tsplit(np.reshape(specification, (2, 3, 8))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -347,7 +349,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_Kim2009_to_XYZ(self): + def test_domain_range_scale_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition domain and range scale support. @@ -400,7 +402,7 @@ def test_domain_range_scale_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_Kim2009_to_XYZ(self): + def test_raise_exception_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition raised exception. @@ -421,7 +423,7 @@ def test_raise_exception_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Kim2009_to_XYZ(self): + def test_nan_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_llab.py b/colour/appearance/tests/test_llab.py index 45dd85df1..a79a50c29 100644 --- a/colour/appearance/tests/test_llab.py +++ b/colour/appearance/tests/test_llab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.kim2009` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -41,7 +43,7 @@ class TestXYZ_to_Kim2009: tests methods. """ - def test_XYZ_to_Kim2009(self): + def test_XYZ_to_Kim2009(self) -> None: """Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition.""" XYZ = np.array([19.01, 20.00, 21.78]) @@ -124,7 +126,7 @@ def test_XYZ_to_Kim2009(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Kim2009(self): + def test_n_dimensional_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition n-dimensional support. @@ -162,7 +164,7 @@ def test_n_dimensional_XYZ_to_Kim2009(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_Kim2009(self): + def test_domain_range_scale_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition domain and range scale support. @@ -210,7 +212,7 @@ def test_domain_range_scale_XYZ_to_Kim2009(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Kim2009(self): + def test_nan_XYZ_to_Kim2009(self) -> None: """ Test :func:`colour.appearance.kim2009.XYZ_to_Kim2009` definition nan support. @@ -229,7 +231,7 @@ class TestKim2009_to_XYZ: tests methods. """ - def test_Kim2009_to_XYZ(self): + def test_Kim2009_to_XYZ(self) -> None: """Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition.""" specification = CAM_Specification_Kim2009( @@ -304,7 +306,7 @@ def test_Kim2009_to_XYZ(self): atol=0.01, ) - def test_n_dimensional_Kim2009_to_XYZ(self): + def test_n_dimensional_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition n-dimensional support. @@ -319,7 +321,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): XYZ = Kim2009_to_XYZ(specification, XYZ_w, L_a, media, surround) specification = CAM_Specification_Kim2009( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_allclose( @@ -336,7 +338,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): ) specification = CAM_Specification_Kim2009( - *tsplit(np.reshape(specification, (2, 3, 8))).tolist() + *tsplit(np.reshape(specification, (2, 3, 8))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -347,7 +349,7 @@ def test_n_dimensional_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_Kim2009_to_XYZ(self): + def test_domain_range_scale_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition domain and range scale support. @@ -400,7 +402,7 @@ def test_domain_range_scale_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_Kim2009_to_XYZ(self): + def test_raise_exception_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition raised exception. @@ -421,7 +423,7 @@ def test_raise_exception_Kim2009_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Kim2009_to_XYZ(self): + def test_nan_Kim2009_to_XYZ(self) -> None: """ Test :func:`colour.appearance.kim2009.Kim2009_to_XYZ` definition nan support. diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index b460492fb..470a087ca 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.nayatani95` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestXYZ_to_Nayatani95: unit tests methods. """ - def test_XYZ_to_Nayatani95(self): + def test_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition. @@ -78,7 +80,7 @@ def test_XYZ_to_Nayatani95(self): atol=0.05, ) - def test_n_dimensional_XYZ_to_Nayatani95(self): + def test_n_dimensional_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition n-dimensional support. @@ -115,7 +117,7 @@ def test_n_dimensional_XYZ_to_Nayatani95(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Nayatani95(self): + def test_domain_range_scale_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition domain and range scale support. @@ -146,7 +148,7 @@ def test_domain_range_scale_XYZ_to_Nayatani95(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Nayatani95(self): + def test_nan_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition nan support. diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index b460492fb..470a087ca 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.appearance.nayatani95` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestXYZ_to_Nayatani95: unit tests methods. """ - def test_XYZ_to_Nayatani95(self): + def test_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition. @@ -78,7 +80,7 @@ def test_XYZ_to_Nayatani95(self): atol=0.05, ) - def test_n_dimensional_XYZ_to_Nayatani95(self): + def test_n_dimensional_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition n-dimensional support. @@ -115,7 +117,7 @@ def test_n_dimensional_XYZ_to_Nayatani95(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Nayatani95(self): + def test_domain_range_scale_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition domain and range scale support. @@ -146,7 +148,7 @@ def test_domain_range_scale_XYZ_to_Nayatani95(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Nayatani95(self): + def test_nan_XYZ_to_Nayatani95(self) -> None: """ Test :func:`colour.appearance.nayatani95.XYZ_to_Nayatani95` definition nan support. diff --git a/colour/appearance/tests/test_zcam.py b/colour/appearance/tests/test_zcam.py index 2ba077f98..27f4bbe53 100644 --- a/colour/appearance/tests/test_zcam.py +++ b/colour/appearance/tests/test_zcam.py @@ -2,6 +2,8 @@ Define the unit tests for the :mod:`colour.appearance.zcam` module. """ +from __future__ import annotations + from itertools import permutations import numpy as np @@ -37,7 +39,7 @@ class TestXYZ_to_ZCAM: methods. """ - def test_XYZ_to_ZCAM(self): + def test_XYZ_to_ZCAM(self) -> None: """ Tests :func:`colour.appearance.zcam.XYZ_to_ZCAM` definition. """ @@ -168,7 +170,7 @@ def test_XYZ_to_ZCAM(self): atol=0.025, ) - def test_n_dimensional_XYZ_to_ZCAM(self): + def test_n_dimensional_XYZ_to_ZCAM(self) -> None: """ Tests :func:`colour.appearance.zcam.XYZ_to_ZCAM` definition n-dimensional support. @@ -200,7 +202,7 @@ def test_n_dimensional_XYZ_to_ZCAM(self): ) @ignore_numpy_errors - def test_domain_range_scale_XYZ_to_ZCAM(self): + def test_domain_range_scale_XYZ_to_ZCAM(self) -> None: """ Tests :func:`colour.appearance.zcam.XYZ_to_ZCAM` definition domain and range scale support. @@ -215,9 +217,9 @@ def test_domain_range_scale_XYZ_to_ZCAM(self): d_r = ( ("reference", 1, 1), - (1, 1, np.array([1, 1, 1 / 360, 1, 1, 1, 1 / 400, np.nan, 1, 1, 1])), + ("1", 1, np.array([1, 1, 1 / 360, 1, 1, 1, 1 / 400, np.nan, 1, 1, 1])), ( - 100, + "100", 100, np.array( [ @@ -245,7 +247,7 @@ def test_domain_range_scale_XYZ_to_ZCAM(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_ZCAM(self): + def test_nan_XYZ_to_ZCAM(self) -> None: """ Tests :func:`colour.appearance.zcam.XYZ_to_ZCAM` definition nan support. @@ -268,7 +270,7 @@ class TestZCAM_to_XYZ: tests methods. """ - def test_ZCAM_to_XYZ(self): + def test_ZCAM_to_XYZ(self) -> None: """ Tests :func:`colour.appearance.zcam.ZCAM_to_XYZ` definition. """ @@ -382,7 +384,7 @@ def test_ZCAM_to_XYZ(self): rtol=0.01, ) - def test_n_dimensional_ZCAM_to_XYZ(self): + def test_n_dimensional_ZCAM_to_XYZ(self) -> None: """ Tests :func:`colour.appearance.zcam.ZCAM_to_XYZ` definition n-dimensional support. @@ -397,7 +399,7 @@ def test_n_dimensional_ZCAM_to_XYZ(self): XYZ = ZCAM_to_XYZ(specification, XYZ_w, L_a, Y_b, surround) specification = CAM_Specification_ZCAM( - *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() + *np.transpose(np.tile(tsplit(specification), (6, 1))).tolist() # pyright: ignore ) XYZ = np.tile(XYZ, (6, 1)) np.testing.assert_almost_equal( @@ -410,7 +412,7 @@ def test_n_dimensional_ZCAM_to_XYZ(self): ) specification = CAM_Specification_ZCAM( - *tsplit(np.reshape(specification, (2, 3, 11))).tolist() + *tsplit(np.reshape(specification, (2, 3, 11))).tolist() # pyright: ignore ) XYZ_w = np.reshape(XYZ_w, (2, 3, 3)) XYZ = np.reshape(XYZ, (2, 3, 3)) @@ -419,7 +421,7 @@ def test_n_dimensional_ZCAM_to_XYZ(self): ) @ignore_numpy_errors - def test_domain_range_scale_ZCAM_to_XYZ(self): + def test_domain_range_scale_ZCAM_to_XYZ(self) -> None: """ Tests :func:`colour.appearance.zcam.ZCAM_to_XYZ` definition domain and range scale support. @@ -435,9 +437,9 @@ def test_domain_range_scale_ZCAM_to_XYZ(self): d_r = ( ("reference", 1, 1), - (1, np.array([1, 1, 1 / 360, 1, 1, 1, 1 / 400, np.nan, 1, 1, 1]), 1), + ("1", np.array([1, 1, 1 / 360, 1, 1, 1, 1 / 400, np.nan, 1, 1, 1]), 1), ( - 100, + "100", np.array( [ 100, @@ -467,7 +469,7 @@ def test_domain_range_scale_ZCAM_to_XYZ(self): ) @ignore_numpy_errors - def test_raise_exception_ZCAM_to_XYZ(self): + def test_raise_exception_ZCAM_to_XYZ(self) -> None: """ Tests :func:`colour.appearance.zcam.ZCAM_to_XYZ` definition raised exception. @@ -488,7 +490,7 @@ def test_raise_exception_ZCAM_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_ZCAM_to_XYZ(self): + def test_nan_ZCAM_to_XYZ(self) -> None: """ Tests :func:`colour.appearance.zcam.ZCAM_to_XYZ` definition nan support. diff --git a/colour/biochemistry/tests/test_michaelis_menten.py b/colour/biochemistry/tests/test_michaelis_menten.py index 755cced97..f69bc73fc 100644 --- a/colour/biochemistry/tests/test_michaelis_menten.py +++ b/colour/biochemistry/tests/test_michaelis_menten.py @@ -3,6 +3,8 @@ module. """ +from __future__ import annotations + from itertools import product import numpy as np @@ -37,7 +39,7 @@ class TestReactionRateMichaelisMentenMichaelis1913: reaction_rate_MichaelisMenten_Michaelis1913` definition unit tests methods. """ - def test_reaction_rate_MichaelisMenten_Michaelis1913(self): + def test_reaction_rate_MichaelisMenten_Michaelis1913(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Michaelis1913` definition. @@ -61,7 +63,7 @@ def test_reaction_rate_MichaelisMenten_Michaelis1913(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_reaction_rate_MichaelisMenten_Michaelis1913(self): + def test_n_dimensional_reaction_rate_MichaelisMenten_Michaelis1913(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Michaelis1913` definition n-dimensional arrays @@ -100,7 +102,7 @@ def test_n_dimensional_reaction_rate_MichaelisMenten_Michaelis1913(self): ) @ignore_numpy_errors - def test_nan_reaction_rate_MichaelisMenten_Michaelis1913(self): + def test_nan_reaction_rate_MichaelisMenten_Michaelis1913(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Michaelis1913` definition nan support. @@ -117,7 +119,7 @@ class TestSubstrateConcentrationMichaelisMentenMichaelis1913: reaction_rate_MichaelisMenten_Michaelis1913` definition unit tests methods. """ - def test_substrate_concentration_MichaelisMenten_Michaelis1913(self): + def test_substrate_concentration_MichaelisMenten_Michaelis1913(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Michaelis1913` definition. @@ -143,7 +145,7 @@ def test_substrate_concentration_MichaelisMenten_Michaelis1913(self): def test_n_dimensional_substrate_concentration_MichaelisMenten_Michaelis1913( self, - ): + ) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Michaelis1913` definition n-dimensional @@ -182,7 +184,7 @@ def test_n_dimensional_substrate_concentration_MichaelisMenten_Michaelis1913( ) @ignore_numpy_errors - def test_nan_substrate_concentration_MichaelisMenten_Michaelis1913(self): + def test_nan_substrate_concentration_MichaelisMenten_Michaelis1913(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Michaelis1913` definition nan support. @@ -199,7 +201,7 @@ class TestReactionRateMichaelisMentenAbebe2017: reaction_rate_MichaelisMenten_Abebe2017` definition unit tests methods. """ - def test_reaction_rate_MichaelisMenten_Abebe2017(self): + def test_reaction_rate_MichaelisMenten_Abebe2017(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Abebe2017` definition. @@ -223,7 +225,7 @@ def test_reaction_rate_MichaelisMenten_Abebe2017(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_reaction_rate_MichaelisMenten_Abebe2017(self): + def test_n_dimensional_reaction_rate_MichaelisMenten_Abebe2017(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Abebe2017` definition n-dimensional arrays @@ -265,7 +267,7 @@ def test_n_dimensional_reaction_rate_MichaelisMenten_Abebe2017(self): ) @ignore_numpy_errors - def test_nan_reaction_rate_MichaelisMenten_Abebe2017(self): + def test_nan_reaction_rate_MichaelisMenten_Abebe2017(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ reaction_rate_MichaelisMenten_Abebe2017` definition nan support. @@ -282,7 +284,7 @@ class TestSubstrateConcentrationMichaelisMentenAbebe2017: reaction_rate_MichaelisMenten_Abebe2017` definition unit tests methods. """ - def test_substrate_concentration_MichaelisMenten_Abebe2017(self): + def test_substrate_concentration_MichaelisMenten_Abebe2017(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Abebe2017` definition. @@ -314,7 +316,7 @@ def test_substrate_concentration_MichaelisMenten_Abebe2017(self): def test_n_dimensional_substrate_concentration_MichaelisMenten_Abebe2017( self, - ): + ) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Abebe2017` definition n-dimensional @@ -356,7 +358,7 @@ def test_n_dimensional_substrate_concentration_MichaelisMenten_Abebe2017( ) @ignore_numpy_errors - def test_nan_substrate_concentration_MichaelisMenten_Abebe2017(self): + def test_nan_substrate_concentration_MichaelisMenten_Abebe2017(self) -> None: """ Test :func:`colour.biochemistry.michaelis_menten.\ substrate_concentration_MichaelisMenten_Abebe2017` definition nan support. diff --git a/colour/blindness/tests/test_machado2009.py b/colour/blindness/tests/test_machado2009.py index 810c7d52d..07b745324 100644 --- a/colour/blindness/tests/test_machado2009.py +++ b/colour/blindness/tests/test_machado2009.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.blindness.machado2009` module.""" +from __future__ import annotations + import numpy as np from colour.blindness import ( @@ -33,13 +35,13 @@ class TestMsdsCmfsAnomalousTrichromacyMachado2009: msds_cmfs_anomalous_trichromacy_Machado2009` definition unit tests methods. """ - def test_msds_cmfs_anomalous_trichromacy_Machado2009(self): + def test_msds_cmfs_anomalous_trichromacy_Machado2009(self) -> None: """ Test :func:`colour.blindness.machado2009.\ msds_cmfs_anomalous_trichromacy_Machado2009` definition. """ - cmfs = MSDS_CMFS_LMS.get("Smith & Pokorny 1975 Normal Trichromats") + cmfs = MSDS_CMFS_LMS["Smith & Pokorny 1975 Normal Trichromats"] np.testing.assert_allclose( msds_cmfs_anomalous_trichromacy_Machado2009( cmfs, @@ -124,13 +126,13 @@ class TestMatrixAnomalousTrichromacyMachado2009: matrix_anomalous_trichromacy_Machado2009` definition unit tests methods. """ - def test_matrix_anomalous_trichromacy_Machado2009(self): + def test_matrix_anomalous_trichromacy_Machado2009(self) -> None: """ Test :func:`colour.blindness.machado2009.\ matrix_anomalous_trichromacy_Machado2009` definition. """ - cmfs = MSDS_CMFS_LMS.get("Smith & Pokorny 1975 Normal Trichromats") + cmfs = MSDS_CMFS_LMS["Smith & Pokorny 1975 Normal Trichromats"] primaries = MSDS_DISPLAY_PRIMARIES["Typical CRT Brainard 1997"] np.testing.assert_allclose( matrix_anomalous_trichromacy_Machado2009( @@ -144,7 +146,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([2, 0, 0]) ), - CVD_MATRICES_MACHADO2010.get("Protanomaly").get(0.1), + CVD_MATRICES_MACHADO2010["Protanomaly"][0.1], atol=0.0001, ) @@ -152,7 +154,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([10, 0, 0]) ), - CVD_MATRICES_MACHADO2010.get("Protanomaly").get(0.5), + CVD_MATRICES_MACHADO2010["Protanomaly"][0.5], atol=0.0001, ) @@ -160,7 +162,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([20, 0, 0]) ), - CVD_MATRICES_MACHADO2010.get("Protanomaly").get(1.0), + CVD_MATRICES_MACHADO2010["Protanomaly"][1.0], atol=0.0001, ) @@ -168,7 +170,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 2, 0]) ), - CVD_MATRICES_MACHADO2010.get("Deuteranomaly").get(0.1), + CVD_MATRICES_MACHADO2010["Deuteranomaly"][0.1], atol=0.0001, ) @@ -176,7 +178,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 10, 0]) ), - CVD_MATRICES_MACHADO2010.get("Deuteranomaly").get(0.5), + CVD_MATRICES_MACHADO2010["Deuteranomaly"][0.5], atol=0.0001, ) @@ -184,7 +186,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 20, 0]) ), - CVD_MATRICES_MACHADO2010.get("Deuteranomaly").get(1.0), + CVD_MATRICES_MACHADO2010["Deuteranomaly"][1.0], atol=0.0001, ) @@ -192,7 +194,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 0, 5.00056688094503]) ), - CVD_MATRICES_MACHADO2010.get("Tritanomaly").get(0.1), + CVD_MATRICES_MACHADO2010["Tritanomaly"][0.1], atol=0.0001, ) @@ -200,7 +202,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 0, 29.002939088780934]) ), - CVD_MATRICES_MACHADO2010.get("Tritanomaly").get(0.5), + CVD_MATRICES_MACHADO2010["Tritanomaly"][0.5], atol=0.0001, ) @@ -208,7 +210,7 @@ def test_matrix_anomalous_trichromacy_Machado2009(self): matrix_anomalous_trichromacy_Machado2009( cmfs, primaries, np.array([0, 0, 59.00590434857581]) ), - CVD_MATRICES_MACHADO2010.get("Tritanomaly").get(1.0), + CVD_MATRICES_MACHADO2010["Tritanomaly"][1.0], atol=0.001, ) @@ -219,7 +221,7 @@ class TestMatrixCvdMachado2009: definition unit tests methods. """ - def test_matrix_cvd_Machado2009(self): + def test_matrix_cvd_Machado2009(self) -> None: """ Test :func:`colour.blindness.machado2009.matrix_cvd_Machado2009` definition. @@ -274,7 +276,7 @@ def test_matrix_cvd_Machado2009(self): ) @ignore_numpy_errors - def test_nan_matrix_cvd_Machado2009(self): + def test_nan_matrix_cvd_Machado2009(self) -> None: """ Test :func:`colour.blindness.machado2009.matrix_cvd_Machado2009` definition nan support. diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 07fa32db3..e72abfe78 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -84,9 +84,9 @@ sds_and_msds_to_msds, ) from colour.hints import ( + Any, ArrayLike, Callable, - DTypeFloat, LiteralChromaticAdaptationTransform, Mapping, NDArrayFloat, @@ -112,6 +112,7 @@ CanonicalMapping, as_float, as_float_array, + as_float_scalar, from_range_1, ones, optional, @@ -163,7 +164,7 @@ def sd_to_aces_relative_exposure_values( chromatic_adaptation_transform: ( LiteralChromaticAdaptationTransform | str | None ) = "CAT02", - **kwargs, + **kwargs: Any, ) -> NDArrayFloat: """ Convert given spectral distribution to *ACES2065-1* colourspace relative @@ -246,10 +247,10 @@ def sd_to_aces_relative_exposure_values( r_bar, g_bar, b_bar = tsplit(MSDS_ACES_RICD.values) - def k(x: NDArrayFloat, y: NDArrayFloat) -> DTypeFloat: + def k(x: NDArrayFloat, y: NDArrayFloat) -> float: """Compute the :math:`K_r`, :math:`K_g` or :math:`K_b` scale factors.""" - return 1 / np.sum(x * y) + return as_float_scalar(1 / np.sum(x * y)) k_r = k(i_v, r_bar) k_g = k(i_v, g_bar) @@ -393,7 +394,7 @@ def generate_illuminants_rawtoaces_v1() -> CanonicalMapping: # Blackbody from 1000K to 4000K. for i in np.arange(1000, 4000, 500): - sd = sd_blackbody(i, SPECTRAL_SHAPE_RAWTOACES) + sd = sd_blackbody(cast(float, i), SPECTRAL_SHAPE_RAWTOACES) illuminants[sd.name] = sd # A.M.P.A.S. variant of ISO 7589 Studio Tungsten. diff --git a/colour/characterisation/cameras.py b/colour/characterisation/cameras.py index a56139d28..caca3d008 100644 --- a/colour/characterisation/cameras.py +++ b/colour/characterisation/cameras.py @@ -11,6 +11,8 @@ from __future__ import annotations +from collections.abc import KeysView, ValuesView + from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, @@ -97,9 +99,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, # noqa: ARG002 **kwargs: Any, ) -> None: diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 007a187a8..3b1b69839 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -118,8 +118,8 @@ def matrix_augmented_Cheung2004( RGB: ArrayLike, - terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] = 3, -) -> NDArrayFloat: + terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] | int = 3, +) -> NDArrayFloat: # pyright: ignore """ Perform polynomial expansion of given *RGB* colourspace array using *Cheung et al. (2004)* method. @@ -418,9 +418,9 @@ def matrix_augmented_Cheung2004( def polynomial_expansion_Finlayson2015( RGB: ArrayLike, - degree: Literal[1, 2, 3, 4] = 1, + degree: Literal[1, 2, 3, 4] | int = 1, root_polynomial_expansion: bool = True, -) -> NDArrayFloat: +) -> NDArrayFloat: # pyright: ignore """ Perform polynomial expansion of given *RGB* colourspace array using *Finlayson et al. (2015)* method. @@ -721,7 +721,7 @@ def polynomial_expansion( def matrix_colour_correction_Cheung2004( M_T: ArrayLike, M_R: ArrayLike, - terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] = 3, + terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] | int = 3, ) -> NDArrayFloat: """ Compute a colour correction matrix from given :math:`M_T` colour array to @@ -764,7 +764,7 @@ def matrix_colour_correction_Cheung2004( def matrix_colour_correction_Finlayson2015( M_T: ArrayLike, M_R: ArrayLike, - degree: Literal[1, 2, 3, 4] = 1, + degree: Literal[1, 2, 3, 4] | int = 1, root_polynomial_expansion: bool = True, ) -> NDArrayFloat: """ @@ -991,7 +991,7 @@ def matrix_colour_correction( def apply_matrix_colour_correction_Cheung2004( RGB: ArrayLike, CCM: ArrayLike, - terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] = 3, + terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] | int = 3, ) -> NDArrayFloat: """ Apply given colour correction matrix :math:`CCM` computed using @@ -1043,7 +1043,7 @@ def apply_matrix_colour_correction_Cheung2004( def apply_matrix_colour_correction_Finlayson2015( RGB: ArrayLike, CCM: ArrayLike, - degree: Literal[1, 2, 3, 4] = 1, + degree: Literal[1, 2, 3, 4] | int = 1, root_polynomial_expansion: bool = True, ) -> NDArrayFloat: """ @@ -1234,7 +1234,7 @@ def colour_correction_Cheung2004( RGB: ArrayLike, M_T: ArrayLike, M_R: ArrayLike, - terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] = 3, + terms: Literal[3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35] | int = 3, ) -> NDArrayFloat: """ Perform colour correction of given *RGB* colourspace array using the @@ -1280,7 +1280,7 @@ def colour_correction_Finlayson2015( RGB: ArrayLike, M_T: ArrayLike, M_R: ArrayLike, - degree: Literal[1, 2, 3, 4] = 1, + degree: Literal[1, 2, 3, 4] | int = 1, root_polynomial_expansion: bool = True, ) -> NDArrayFloat: """ diff --git a/colour/characterisation/displays.py b/colour/characterisation/displays.py index 89c19ebc2..6d6079728 100644 --- a/colour/characterisation/displays.py +++ b/colour/characterisation/displays.py @@ -12,6 +12,8 @@ from __future__ import annotations +from collections.abc import KeysView, ValuesView + from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, @@ -99,9 +101,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, # noqa: ARG002 **kwargs: Any, ) -> None: diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py index 0ee49a435..3a541c097 100644 --- a/colour/characterisation/tests/test_aces_it.py +++ b/colour/characterisation/tests/test_aces_it.py @@ -12,6 +12,7 @@ MSDS_ACES_RICD, MSDS_CAMERA_SENSITIVITIES, SDS_COLOURCHECKERS, + RGB_CameraSensitivities, best_illuminant, camera_RGB_to_ACES2065_1, generate_illuminants_rawtoaces_v1, @@ -31,7 +32,6 @@ from colour.colorimetry import ( MSDS_CMFS, SDS_ILLUMINANTS, - MultiSpectralDistributions, SpectralDistribution, SpectralShape, reshape_msds, @@ -69,14 +69,16 @@ "TestCamera_RGB_to_ACES2065_1", ] -MSDS_CANON_EOS_5DMARK_II: MultiSpectralDistributions = sds_and_msds_to_msds( - list( - read_sds_from_csv_file( - os.path.join( - ROOT_RESOURCES_RAWTOACES, - "CANON_EOS_5DMark_II_RGB_Sensitivities.csv", - ) - ).values() +MSDS_CANON_EOS_5DMARK_II: RGB_CameraSensitivities = RGB_CameraSensitivities( + sds_and_msds_to_msds( + list( + read_sds_from_csv_file( + os.path.join( + ROOT_RESOURCES_RAWTOACES, + "CANON_EOS_5DMark_II_RGB_Sensitivities.csv", + ) + ).values() + ) ) ) @@ -91,7 +93,7 @@ class TestSdToAcesRelativeExposureValues: sd_to_aces_relative_exposure_values` definition unit tests methods. """ - def test_sd_to_aces_relative_exposure_values(self): + def test_sd_to_aces_relative_exposure_values(self) -> None: """ Test :func:`colour.characterisation.aces_it.\ sd_to_aces_relative_exposure_values` definition. @@ -142,7 +144,7 @@ def test_sd_to_aces_relative_exposure_values(self): def test_domain_range_scale_spectral_to_aces_relative_exposure_values( self, - ): + ) -> None: """ Test :func:`colour.characterisation.aces_it. sd_to_aces_relative_exposure_values` definition domain and range scale @@ -169,7 +171,7 @@ class TestReadTrainingDataRawtoacesV1: read_training_data_rawtoaces_v1` definition unit tests methods. """ - def test_read_training_data_rawtoaces_v1(self): + def test_read_training_data_rawtoaces_v1(self) -> None: """ Test :func:`colour.characterisation.aces_it. read_training_data_rawtoaces_v1` definition. @@ -184,7 +186,7 @@ class TestGenerateIlluminantsRawtoacesV1: generate_illuminants_rawtoaces_v1` definition unit tests methods. """ - def test_generate_illuminants_rawtoaces_v1(self): + def test_generate_illuminants_rawtoaces_v1(self) -> None: """ Test :func:`colour.characterisation.aces_it. generate_illuminants_rawtoaces_v1` definition. @@ -250,7 +252,7 @@ class TestWhiteBalanceMultipliers: definition unit tests methods. """ - def test_white_balance_multipliers(self): + def test_white_balance_multipliers(self) -> None: """ Test :func:`colour.characterisation.aces_it.white_balance_multipliers` definition. @@ -278,7 +280,7 @@ class TestBestIlluminant: unit tests methods. """ - def test_best_illuminant(self): + def test_best_illuminant(self) -> None: """ Test :func:`colour.characterisation.aces_it.best_illuminant` definition. @@ -313,7 +315,7 @@ class TestNormaliseIlluminant: definition unit tests methods. """ - def test_normalise_illuminant(self): + def test_normalise_illuminant(self) -> None: """ Test :func:`colour.characterisation.aces_it.normalise_illuminant` definition. @@ -336,7 +338,7 @@ class TestTrainingDataSdsToRGB: definition unit tests methods. """ - def test_training_data_sds_to_RGB(self): + def test_training_data_sds_to_RGB(self) -> None: """ Test :func:`colour.characterisation.aces_it.training_data_sds_to_RGB` definition. @@ -604,7 +606,7 @@ class TestTrainingDataSdsToXYZ: definition unit tests methods. """ - def test_training_data_sds_to_XYZ(self): + def test_training_data_sds_to_XYZ(self) -> None: """ Test :func:`colour.characterisation.aces_it.training_data_sds_to_XYZ` definition. @@ -899,7 +901,7 @@ class TestWhitepointPreservingMatrix: definition unit tests methods. """ - def test_whitepoint_preserving_matrix(self): + def test_whitepoint_preserving_matrix(self) -> None: """ Test :func:`colour.characterisation.aces_it.\ whitepoint_preserving_matrix` definition. @@ -929,7 +931,7 @@ class TestOptimizationFactoryRawtoacesV1: optimisation_factory_rawtoaces_v1` definition unit tests methods. """ - def test_optimisation_factory_rawtoaces_v1(self): + def test_optimisation_factory_rawtoaces_v1(self) -> None: """ Test :func:`colour.characterisation.aces_it.\ optimisation_factory_rawtoaces_v1` definition. @@ -944,7 +946,7 @@ class TestOptimizationFactoryJzazbz: optimisation_factory_Jzazbz` definition unit tests methods. """ - def test_optimisation_factory_Jzazbz(self): + def test_optimisation_factory_Jzazbz(self) -> None: """ Test :func:`colour.characterisation.aces_it.\ optimisation_factory_Jzazbz` definition. @@ -959,7 +961,7 @@ class TestOptimizationFactoryOklab18: optimisation_factory_Oklab_15` definition unit tests methods. """ - def test_optimisation_factory_Oklab_18(self): + def test_optimisation_factory_Oklab_18(self) -> None: """ Test :func:`colour.characterisation.aces_it.\ optimisation_factory_Oklab_15` definition. @@ -974,7 +976,7 @@ class TestMatrixIdt: tests methods. """ - def test_matrix_idt(self): + def test_matrix_idt(self) -> None: """ Test :func:`colour.characterisation.aces_it.matrix_idt` definition. """ @@ -1015,7 +1017,7 @@ def test_matrix_idt(self): atol=0.0001, ) - M, RGB_w = matrix_idt( + M, RGB_w = matrix_idt( # pyright: ignore MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_factory=optimisation_factory_Jzazbz, @@ -1036,7 +1038,7 @@ def test_matrix_idt(self): np.array([2.34141541, 1.00000000, 1.51633759]), atol=0.0001, ) - M, RGB_w = matrix_idt( + M, RGB_w = matrix_idt( # pyright: ignore MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_factory=optimisation_factory_Oklab_15, @@ -1079,7 +1081,7 @@ def test_matrix_idt(self): atol=0.0001, ) - M, RGB_w = matrix_idt( + M, RGB_w = matrix_idt( # pyright: ignore MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_kwargs={"method": "Nelder-Mead"}, @@ -1126,7 +1128,7 @@ def test_matrix_idt(self): np.testing.assert_allclose( matrix_idt( - MSDS_CANON_EOS_5DMARK_II, + MSDS_CANON_EOS_5DMARK_II, # pyright: ignore SDS_ILLUMINANTS["D55"], chromatic_adaptation_transform="Bradford", )[0], @@ -1140,8 +1142,8 @@ def test_matrix_idt(self): atol=0.0001, ) - _M, RGB_w, XYZ, RGB = matrix_idt( - MSDS_CANON_EOS_5DMARK_II, + _M, RGB_w, XYZ, RGB = matrix_idt( # pyright: ignore + MSDS_CANON_EOS_5DMARK_II, # pyright: ignore SDS_ILLUMINANTS["D55"], additional_data=True, ) @@ -1185,13 +1187,13 @@ class TestCamera_RGB_to_ACES2065_1: definition unit tests methods. """ - def test_camera_RGB_to_ACES2065_1(self): + def test_camera_RGB_to_ACES2065_1(self) -> None: """ Test :func:`colour.characterisation.aces_it.camera_RGB_to_ACES2065_1` definition. """ - B, b = matrix_idt(MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"]) + B, b = matrix_idt(MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"]) # pyright: ignore np.testing.assert_allclose( camera_RGB_to_ACES2065_1(np.array([0.1, 0.2, 0.3]), B, b), np.array([0.27064400, 0.15614871, 0.50129650]), diff --git a/colour/characterisation/tests/test_correction.py b/colour/characterisation/tests/test_correction.py index 9c76bc242..2927658b0 100644 --- a/colour/characterisation/tests/test_correction.py +++ b/colour/characterisation/tests/test_correction.py @@ -120,7 +120,7 @@ class TestMatrixAugmentedCheung2004: matrix_augmented_Cheung2004` definition unit tests methods. """ - def test_matrix_augmented_Cheung2004(self): + def test_matrix_augmented_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_augmented_Cheung2004` definition. @@ -364,7 +364,7 @@ def test_matrix_augmented_Cheung2004(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_matrix_augmented_Cheung2004(self): + def test_raise_exception_matrix_augmented_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_augmented_Cheung2004` definition raised exception. @@ -378,7 +378,7 @@ def test_raise_exception_matrix_augmented_Cheung2004(self): ) @ignore_numpy_errors - def test_nan_matrix_augmented_Cheung2004(self): + def test_nan_matrix_augmented_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_augmented_Cheung2004` definition nan support. @@ -395,7 +395,7 @@ class TestPolynomialExpansionFinlayson2015: polynomial_expansion_Finlayson2015` definition unit tests methods. """ - def test_polynomial_expansion_Finlayson2015(self): + def test_polynomial_expansion_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ polynomial_expansion_Finlayson2015` definition. @@ -555,7 +555,7 @@ def test_polynomial_expansion_Finlayson2015(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_polynomial_expansion_Finlayson2015(self): + def test_raise_exception_polynomial_expansion_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ polynomial_expansion_Finlayson2015` definition raised exception. @@ -569,7 +569,7 @@ def test_raise_exception_polynomial_expansion_Finlayson2015(self): ) @ignore_numpy_errors - def test_nan_polynomial_expansion_Finlayson2015(self): + def test_nan_polynomial_expansion_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ polynomial_expansion_Finlayson2015` definition nan support. @@ -586,7 +586,7 @@ class TestPolynomialExpansionVandermonde: polynomial_expansion_Vandermonde` definition unit tests methods. """ - def test_polynomial_expansion_Vandermonde(self): + def test_polynomial_expansion_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ polynomial_expansion_Vandermonde` definition. @@ -648,7 +648,7 @@ def test_polynomial_expansion_Vandermonde(self): ) @ignore_numpy_errors - def test_nan_polynomial_expansion_Vandermonde(self): + def test_nan_polynomial_expansion_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ polynomial_expansion_Vandermonde` definition nan support. @@ -665,7 +665,7 @@ class TestMatrixColourCorrectionCheung2004: matrix_colour_correction_Cheung2004` definition unit tests methods. """ - def test_matrix_colour_correction_Cheung2004(self): + def test_matrix_colour_correction_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Cheung2004` definition. @@ -720,7 +720,7 @@ def test_matrix_colour_correction_Cheung2004(self): ) @ignore_numpy_errors - def test_nan_matrix_colour_correction_Cheung2004(self): # pragma: no cover + def test_nan_matrix_colour_correction_Cheung2004(self) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Cheung2004` definition nan support. @@ -746,7 +746,7 @@ class TestMatrixColourCorrectionFinlayson2015: matrix_colour_correction_Finlayson2015` definition unit tests methods. """ - def test_matrix_colour_correction_Finlayson2015(self): + def test_matrix_colour_correction_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Finlayson2015` definition. @@ -823,7 +823,7 @@ def test_matrix_colour_correction_Finlayson2015(self): @ignore_numpy_errors def test_nan_matrix_colour_correction_Finlayson2015( self, - ): # pragma: no cover + ) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Finlayson2015` definition nan support. @@ -849,7 +849,7 @@ class TestMatrixColourCorrectionVandermonde: matrix_colour_correction_Vandermonde` definition unit tests methods. """ - def test_matrix_colour_correction_Vandermonde(self): + def test_matrix_colour_correction_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Vandermonde` definition. @@ -917,7 +917,7 @@ def test_matrix_colour_correction_Vandermonde(self): @ignore_numpy_errors def test_nan_matrix_colour_correction_Vandermonde( self, - ): # pragma: no cover + ) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ matrix_colour_correction_Vandermonde` definition nan support. @@ -943,7 +943,7 @@ class TestApplyMatrixColourCorrectionCheung2004: apply_matrix_colour_correction_Cheung2004` definition unit tests methods. """ - def test_apply_matrix_colour_correction_Cheung2004(self): + def test_apply_matrix_colour_correction_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Cheung2004` definition. @@ -966,7 +966,7 @@ def test_apply_matrix_colour_correction_Cheung2004(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_apply_matrix_colour_correction_Cheung2004(self): + def test_n_dimensional_apply_matrix_colour_correction_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Cheung2004` definition n-dimensional support. @@ -1001,7 +1001,7 @@ def test_n_dimensional_apply_matrix_colour_correction_Cheung2004(self): @ignore_numpy_errors def test_nan_apply_matrix_colour_correction_Cheung2004( self, - ): # pragma: no cover + ) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Cheung2004` definition nan support. @@ -1027,7 +1027,7 @@ class TestApplyMatrixColourCorrectionFinlayson2015: apply_matrix_colour_correction_Finlayson2015` definition unit tests methods. """ - def test_apply_matrix_colour_correction_Finlayson2015(self): + def test_apply_matrix_colour_correction_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Finlayson2015` definition. @@ -1050,7 +1050,7 @@ def test_apply_matrix_colour_correction_Finlayson2015(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_apply_matrix_colour_correction_Finlayson2015(self): + def test_n_dimensional_apply_matrix_colour_correction_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Finlayson2015` definition n-dimensional support. @@ -1085,7 +1085,7 @@ def test_n_dimensional_apply_matrix_colour_correction_Finlayson2015(self): @ignore_numpy_errors def test_nan_apply_matrix_colour_correction_Finlayson2015( self, - ): # pragma: no cover + ) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction. apply_matrix_colour_correction_Finlayson2015` definition nan support. @@ -1111,7 +1111,7 @@ class TestApplyMatrixColourCorrectionVandermonde: apply_matrix_colour_correction_Vandermonde` definition unit tests methods. """ - def test_apply_matrix_colour_correction_Vandermonde(self): + def test_apply_matrix_colour_correction_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Vandermonde` definition. @@ -1134,7 +1134,7 @@ def test_apply_matrix_colour_correction_Vandermonde(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_apply_matrix_colour_correction_Vandermonde(self): + def test_n_dimensional_apply_matrix_colour_correction_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Vandermonde` definition n-dimensional support. @@ -1169,7 +1169,7 @@ def test_n_dimensional_apply_matrix_colour_correction_Vandermonde(self): @ignore_numpy_errors def test_nan_apply_matrix_colour_correction_Vandermonde( self, - ): # pragma: no cover + ) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ apply_matrix_colour_correction_Vandermonde` definition nan support. @@ -1195,7 +1195,7 @@ class TestColourCorrectionCheung2004: colour_correction_Cheung2004` definition unit tests methods. """ - def test_colour_correction_Cheung2004(self): + def test_colour_correction_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Cheung2004` definition. @@ -1215,7 +1215,7 @@ def test_colour_correction_Cheung2004(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_colour_correction_Cheung2004(self): + def test_n_dimensional_colour_correction_Cheung2004(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Cheung2004` definition n-dimensional support. @@ -1241,7 +1241,7 @@ def test_n_dimensional_colour_correction_Cheung2004(self): ) @ignore_numpy_errors - def test_nan_colour_correction_Cheung2004(self): # pragma: no cover + def test_nan_colour_correction_Cheung2004(self) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ colour_correction_Cheung2004` definition nan support. @@ -1268,7 +1268,7 @@ class TestColourCorrectionFinlayson2015: colour_correction_Finlayson2015` definition unit tests methods. """ - def test_colour_correction_Finlayson2015(self): + def test_colour_correction_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Finlayson2015` definition. @@ -1290,7 +1290,7 @@ def test_colour_correction_Finlayson2015(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_colour_correction_Finlayson2015(self): + def test_n_dimensional_colour_correction_Finlayson2015(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Finlayson2015` definition n-dimensional support. @@ -1316,7 +1316,7 @@ def test_n_dimensional_colour_correction_Finlayson2015(self): ) @ignore_numpy_errors - def test_nan_colour_correction_Finlayson2015(self): # pragma: no cover + def test_nan_colour_correction_Finlayson2015(self) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction. colour_correction_Finlayson2015` definition nan support. @@ -1343,7 +1343,7 @@ class TestColourCorrectionVandermonde: colour_correction_Vandermonde` definition unit tests methods. """ - def test_colour_correction_Vandermonde(self): + def test_colour_correction_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Vandermonde` definition. @@ -1363,7 +1363,7 @@ def test_colour_correction_Vandermonde(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_colour_correction_Vandermonde(self): + def test_n_dimensional_colour_correction_Vandermonde(self) -> None: """ Test :func:`colour.characterisation.correction.\ colour_correction_Vandermonde` definition n-dimensional support. @@ -1389,7 +1389,7 @@ def test_n_dimensional_colour_correction_Vandermonde(self): ) @ignore_numpy_errors - def test_nan_colour_correction_Vandermonde(self): # pragma: no cover + def test_nan_colour_correction_Vandermonde(self) -> None: # pragma: no cover """ Test :func:`colour.characterisation.correction.\ colour_correction_Vandermonde` definition nan support. diff --git a/colour/colorimetry/cmfs.py b/colour/colorimetry/cmfs.py index 5c37c5296..dc3ba3471 100644 --- a/colour/colorimetry/cmfs.py +++ b/colour/colorimetry/cmfs.py @@ -16,6 +16,8 @@ from __future__ import annotations +from collections.abc import KeysView, ValuesView + from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, @@ -105,9 +107,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, # noqa: ARG002 **kwargs: Any, ) -> None: @@ -172,9 +175,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, # noqa: ARG002 **kwargs: Any, ) -> None: @@ -240,9 +244,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, # noqa: ARG002 **kwargs: Any, ) -> None: diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index e217b7dde..5337bcbea 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -27,7 +27,7 @@ from __future__ import annotations -from collections.abc import Mapping +from collections.abc import KeysView, Mapping, ValuesView import numpy as np @@ -175,7 +175,7 @@ def start(self) -> Real: return self._start @start.setter - def start(self, value: Real): + def start(self, value: Real) -> None: """Setter for the **self.start** property.""" attest( @@ -209,7 +209,7 @@ def end(self) -> Real: return self._end @end.setter - def end(self, value: Real): + def end(self, value: Real) -> None: """Setter for the **self.end** property.""" attest( @@ -243,7 +243,7 @@ def interval(self) -> Real: return self._interval @interval.setter - def interval(self, value: Real): + def interval(self, value: Real) -> None: """Setter for the **self.interval** property.""" attest( @@ -272,7 +272,7 @@ def boundaries(self) -> tuple: return self._start, self._end @boundaries.setter - def boundaries(self, value: ArrayLike): + def boundaries(self, value: ArrayLike) -> None: """Setter for the **self.boundaries** property.""" value = np.asarray(value) @@ -673,8 +673,8 @@ class SpectralDistribution(Signal): def __init__( self, - data: ArrayLike | dict | Series | Signal | None = None, - domain: ArrayLike | SpectralShape | None = None, + data: ArrayLike | dict | Series | Signal | ValuesView | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, **kwargs: Any, ) -> None: domain = domain.wavelengths if isinstance(domain, SpectralShape) else domain @@ -708,8 +708,11 @@ def __init__( self.register_callback("_domain", "on_domain_changed", self._on_domain_changed) @staticmethod - def _on_domain_changed(sd, name: str, value: NDArrayFloat) -> NDArrayFloat: + def _on_domain_changed( + sd: SpectralDistribution, name: str, value: NDArrayFloat + ) -> NDArrayFloat: """Invalidate *sd._shape* when *sd._domain* is changed.""" + if name == "_domain": sd._shape = None @@ -734,7 +737,7 @@ def display_name(self) -> str: return self._display_name @display_name.setter - def display_name(self, value: str): + def display_name(self, value: str) -> None: """Setter for the **self.display_name** property.""" attest( @@ -765,7 +768,7 @@ def wavelengths(self) -> NDArrayFloat: return self.domain @wavelengths.setter - def wavelengths(self, value: ArrayLike): + def wavelengths(self, value: ArrayLike) -> None: """Setter for the **self.wavelengths** property.""" self.domain = as_float_array(value, self.dtype) @@ -789,7 +792,7 @@ def values(self) -> NDArrayFloat: return self.range @values.setter - def values(self, value: ArrayLike): + def values(self, value: ArrayLike) -> None: """Setter for the **self.values** property.""" self.range = as_float_array(value, self.dtype) @@ -1789,9 +1792,10 @@ def __init__( | Series | Signal | SpectralDistribution + | ValuesView | None ) = None, - domain: ArrayLike | SpectralShape | None = None, + domain: ArrayLike | SpectralShape | KeysView | None = None, labels: Sequence | None = None, **kwargs: Any, ) -> None: @@ -1842,7 +1846,7 @@ def display_name(self) -> str: return self._display_name @display_name.setter - def display_name(self, value: str): + def display_name(self, value: str) -> None: """Setter for the **self.display_name** property.""" attest( @@ -1872,7 +1876,7 @@ def display_labels(self) -> List[str]: return self._display_labels @display_labels.setter - def display_labels(self, value: Sequence): + def display_labels(self, value: Sequence) -> None: """Setter for the **self.display_labels** property.""" attest( @@ -1916,7 +1920,7 @@ def wavelengths(self) -> NDArrayFloat: return self.domain @wavelengths.setter - def wavelengths(self, value: ArrayLike): + def wavelengths(self, value: ArrayLike) -> None: """Setter for the **self.wavelengths** property.""" self.domain = as_float_array(value, self.dtype) @@ -1941,7 +1945,7 @@ def values(self) -> NDArrayFloat: return self.range @values.setter - def values(self, value: ArrayLike): + def values(self, value: ArrayLike) -> None: """Setter for the **self.values** property.""" self.range = as_float_array(value, self.dtype) @@ -2772,6 +2776,7 @@ def sds_and_msds_to_sds( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), ) -> List[SpectralDistribution]: """ @@ -2835,6 +2840,7 @@ def sds_and_msds_to_msds( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), ) -> MultiSpectralDistributions: """ diff --git a/colour/colorimetry/tests/test_blackbody.py b/colour/colorimetry/tests/test_blackbody.py index c4512c7e2..c0928f44e 100644 --- a/colour/colorimetry/tests/test_blackbody.py +++ b/colour/colorimetry/tests/test_blackbody.py @@ -1202,7 +1202,7 @@ class TestPlanckLaw: tests methods. """ - def test_planck_law(self): + def test_planck_law(self) -> None: """Test :func:`colour.colorimetry.blackbody.planck_law` definition.""" wavelengths = 2 ** np.arange(0, 16, 1) * 1e-9 @@ -1213,7 +1213,7 @@ def test_planck_law(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_planck_law(self): + def test_n_dimensional_planck_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.planck_law` definition n-dimensional arrays support. @@ -1260,7 +1260,7 @@ def test_n_dimensional_planck_law(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_planck_law(self): + def test_raise_exception_planck_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.planck_law` definition raised exception. @@ -1270,7 +1270,7 @@ def test_raise_exception_planck_law(self): pytest.raises(AssertionError, planck_law, wavelength, 5500) @ignore_numpy_errors - def test_nan_planck_law(self): + def test_nan_planck_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.planck_law` definition nan support. @@ -1288,7 +1288,7 @@ class TestSdBlackbody: tests methods. """ - def test_sd_blackbody(self): + def test_sd_blackbody(self) -> None: """Test :func:`colour.colorimetry.blackbody.sd_blackbody` definition.""" np.testing.assert_allclose( @@ -1304,7 +1304,7 @@ class TestRayleighJeansLaw: tests methods. """ - def test_rayleigh_jeans_law(self): + def test_rayleigh_jeans_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition. @@ -1318,7 +1318,7 @@ def test_rayleigh_jeans_law(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_rayleigh_jeans_law(self): + def test_n_dimensional_rayleigh_jeans_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition n-dimensional arrays support. @@ -1366,7 +1366,7 @@ def test_n_dimensional_rayleigh_jeans_law(self): ) @ignore_numpy_errors - def test_nan_rayleigh_jeans_law(self): + def test_nan_rayleigh_jeans_law(self) -> None: """ Test :func:`colour.colorimetry.blackbody.rayleigh_jeans_law` definition nan support. @@ -1383,7 +1383,7 @@ class TestSdRayleighJeans: tests methods. """ - def test_sd_rayleigh_jeans(self): + def test_sd_rayleigh_jeans(self) -> None: """ Test :func:`colour.colorimetry.blackbody.sd_rayleigh_jeans` definition. diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index 030961ae1..c46c5d7cf 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.correction` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -66,7 +68,7 @@ class TestBandpassCorrectionStearns1988: bandpass_correction_Stearns1988` definition unit tests methods. """ - def test_bandpass_correction_Stearns1988(self): + def test_bandpass_correction_Stearns1988(self) -> None: """ Test :func:`colour.colorimetry.correction.\ bandpass_correction_Stearns1988` definition. diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index ab3a5aade..7f7f92a1b 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.dominant` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -41,14 +43,14 @@ class TestClosestSpectralLocusWavelength: closest_spectral_locus_wavelength` definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._xy_s = XYZ_to_xy(MSDS_CMFS["CIE 1931 2 Degree Standard Observer"].values) self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def test_closest_spectral_locus_wavelength(self): + def test_closest_spectral_locus_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.\ closest_spectral_locus_wavelength` definition. @@ -75,7 +77,7 @@ def test_closest_spectral_locus_wavelength(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_closest_spectral_locus_wavelength(self): + def test_n_dimensional_closest_spectral_locus_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.\ closest_spectral_locus_wavelength` definition n-dimensional arrays support. @@ -105,7 +107,7 @@ def test_n_dimensional_closest_spectral_locus_wavelength(self): np.testing.assert_allclose(xy_wl, xy_wl_r, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_closest_spectral_locus_wavelength(self): + def test_nan_closest_spectral_locus_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.\ closest_spectral_locus_wavelength` definition nan support. @@ -123,12 +125,12 @@ class TestDominantWavelength: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def test_dominant_wavelength(self): + def test_dominant_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.dominant_wavelength` definition. @@ -165,7 +167,7 @@ def test_dominant_wavelength(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_dominant_wavelength(self): + def test_n_dimensional_dominant_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.dominant_wavelength` definition n-dimensional arrays support. @@ -204,7 +206,7 @@ def test_n_dimensional_dominant_wavelength(self): np.testing.assert_allclose(xy_cwl, xy_cwl_r, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_dominant_wavelength(self): + def test_nan_dominant_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.dominant_wavelength` definition nan support. @@ -222,12 +224,12 @@ class TestComplementaryWavelength: definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def test_complementary_wavelength(self): + def test_complementary_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.complementary_wavelength` definition. @@ -264,7 +266,7 @@ def test_complementary_wavelength(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_complementary_wavelength(self): + def test_n_dimensional_complementary_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.complementary_wavelength` definition n-dimensional arrays support. @@ -303,7 +305,7 @@ def test_n_dimensional_complementary_wavelength(self): np.testing.assert_allclose(xy_cwl, xy_cwl_r, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_complementary_wavelength(self): + def test_nan_complementary_wavelength(self) -> None: """ Test :func:`colour.colorimetry.dominant.complementary_wavelength` definition nan support. @@ -321,12 +323,12 @@ class TestExcitationPurity: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def test_excitation_purity(self): + def test_excitation_purity(self) -> None: """Test :func:`colour.colorimetry.dominant.excitation_purity` definition.""" xy = np.array([0.54369557, 0.32107944]) @@ -345,7 +347,7 @@ def test_excitation_purity(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_excitation_purity(self): + def test_n_dimensional_excitation_purity(self) -> None: """ Test :func:`colour.colorimetry.dominant.excitation_purity` definition n-dimensional arrays support. @@ -370,7 +372,7 @@ def test_n_dimensional_excitation_purity(self): ) @ignore_numpy_errors - def test_nan_excitation_purity(self): + def test_nan_excitation_purity(self) -> None: """ Test :func:`colour.colorimetry.dominant.excitation_purity` definition nan support. @@ -388,12 +390,12 @@ class TestColorimetricPurity: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def test_colorimetric_purity(self): + def test_colorimetric_purity(self) -> None: """ Test :func:`colour.colorimetry.dominant.colorimetric_purity` definition. @@ -415,7 +417,7 @@ def test_colorimetric_purity(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_colorimetric_purity(self): + def test_n_dimensional_colorimetric_purity(self) -> None: """ Test :func:`colour.colorimetry.dominant.colorimetric_purity` definition n-dimensional arrays support. @@ -440,7 +442,7 @@ def test_n_dimensional_colorimetric_purity(self): ) @ignore_numpy_errors - def test_nan_colorimetric_purity(self): + def test_nan_colorimetric_purity(self) -> None: """ Test :func:`colour.colorimetry.dominant.colorimetric_purity` definition nan support. diff --git a/colour/colorimetry/tests/test_generation.py b/colour/colorimetry/tests/test_generation.py index eda46d104..bdbc62a17 100644 --- a/colour/colorimetry/tests/test_generation.py +++ b/colour/colorimetry/tests/test_generation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.generation` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry.generation import ( @@ -43,7 +45,7 @@ class TestSdConstant: tests methods. """ - def test_sd_constant(self): + def test_sd_constant(self) -> None: """Test :func:`colour.colorimetry.generation.sd_constant` definition.""" sd = sd_constant(np.pi) @@ -61,7 +63,7 @@ class TestSdZeros: tests methods. """ - def test_sd_zeros(self): + def test_sd_zeros(self) -> None: """ Test :func:`colour.colorimetry.generation.sd_zeros` definition. @@ -82,7 +84,7 @@ class TestSdOnes: tests methods. """ - def test_sd_ones(self): + def test_sd_ones(self) -> None: """Test :func:`colour.colorimetry.generation.sd_ones` definition.""" sd = sd_ones() @@ -100,7 +102,7 @@ class TestMsdsConstant: tests methods. """ - def test_msds_constant(self): + def test_msds_constant(self) -> None: """Test :func:`colour.colorimetry.generation.msds_constant` definition.""" msds = msds_constant(np.pi, labels=["a", "b", "c"]) @@ -130,7 +132,7 @@ class TestMsdsZeros: tests methods. """ - def test_msds_zeros(self): + def test_msds_zeros(self) -> None: """ Test :func:`colour.colorimetry.generation.msds_zeros` definition. @@ -151,7 +153,7 @@ class TestMsdsOnes: tests methods. """ - def test_msds_ones(self): + def test_msds_ones(self) -> None: """Test :func:`colour.colorimetry.generation.msds_ones` definition.""" msds = msds_ones(labels=["a", "b", "c"]) @@ -169,7 +171,7 @@ class TestSdGaussianNormal: definition unit tests methods. """ - def test_sd_gaussian_normal(self): + def test_sd_gaussian_normal(self) -> None: """ Test :func:`colour.colorimetry.generation.sd_gaussian_normal` definition. @@ -194,7 +196,7 @@ class TestSdGaussianFwhm: unit tests methods. """ - def test_sd_gaussian_fwhm(self): + def test_sd_gaussian_fwhm(self) -> None: """ Test :func:`colour.colorimetry.generation.sd_gaussian_fwhm` definition. """ @@ -218,7 +220,7 @@ class TestSdSingleLedOhno2005: definition unit tests methods. """ - def test_sd_single_led_Ohno2005(self): + def test_sd_single_led_Ohno2005(self) -> None: """ Test :func:`colour.colorimetry.generation.sd_single_led_Ohno2005` definition. @@ -243,7 +245,7 @@ class TestSdMultiLedsOhno2005: definition unit tests methods. """ - def test_sd_multi_leds_Ohno2005(self): + def test_sd_multi_leds_Ohno2005(self) -> None: """ Test :func:`colour.colorimetry.generation.sd_multi_leds_Ohno2005` definition. diff --git a/colour/colorimetry/tests/test_illuminants.py b/colour/colorimetry/tests/test_illuminants.py index 5facff02f..a0e41735c 100644 --- a/colour/colorimetry/tests/test_illuminants.py +++ b/colour/colorimetry/tests/test_illuminants.py @@ -137,7 +137,7 @@ class TestSdCIEStandardIlluminantA: sd_CIE_standard_illuminant_A` definition unit tests methods. """ - def test_sd_CIE_standard_illuminant_A(self): + def test_sd_CIE_standard_illuminant_A(self) -> None: """ Test :func:`colour.colorimetry.illuminants.\ sd_CIE_standard_illuminant_A` definition. @@ -156,7 +156,7 @@ class TestSdCIEIlluminantDSeries: definition unit tests methods. """ - def test_sd_CIE_illuminant_D_series(self): + def test_sd_CIE_illuminant_D_series(self) -> None: """ Test :func:`colour.colorimetry.illuminants.\ sd_CIE_illuminant_D_series` definition. @@ -186,7 +186,7 @@ class TestDaylightLocusFunction: definition unit tests methods. """ - def test_daylight_locus_function(self): + def test_daylight_locus_function(self) -> None: """ Test :func:`colour.colorimetry.illuminants.daylight_locus_function` definition. @@ -210,7 +210,7 @@ def test_daylight_locus_function(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_daylight_locus_function(self): + def test_n_dimensional_daylight_locus_function(self) -> None: """ Test :func:`colour.colorimetry.illuminants.daylight_locus_function` definition n-dimensional support. @@ -232,7 +232,7 @@ def test_n_dimensional_daylight_locus_function(self): ) @ignore_numpy_errors - def test_nan_daylight_locus_function(self): + def test_nan_daylight_locus_function(self) -> None: """ Test :func:`colour.colorimetry.illuminants.daylight_locus_function` definition nan support. diff --git a/colour/colorimetry/tests/test_lefs.py b/colour/colorimetry/tests/test_lefs.py index 987eb1b9c..9345cbd72 100644 --- a/colour/colorimetry/tests/test_lefs.py +++ b/colour/colorimetry/tests/test_lefs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.lefs` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -433,7 +435,7 @@ class TestMesopicWeightingFunction: definition unit tests methods. """ - def test_mesopic_weighting_function(self): + def test_mesopic_weighting_function(self) -> None: """ Test :func:`colour.colorimetry.lefs.mesopic_weighting_function` definition. @@ -457,7 +459,7 @@ def test_mesopic_weighting_function(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_mesopic_weighting_function(self): + def test_n_dimensional_mesopic_weighting_function(self) -> None: """ Test :func:`colour.colorimetry.lefs.mesopic_weighting_function` definition n-dimensional arrays support. @@ -491,7 +493,7 @@ def test_n_dimensional_mesopic_weighting_function(self): ) @ignore_numpy_errors - def test_nan_mesopic_weighting_function(self): + def test_nan_mesopic_weighting_function(self) -> None: """ Test :func:`colour.colorimetry.lefs.mesopic_weighting_function` definition nan support. @@ -510,7 +512,7 @@ class TestSdMesopicLuminousEfficiencyFunction: sd_mesopic_luminous_efficiency_function` definition unit tests methods. """ - def test_sd_mesopic_luminous_efficiency_function(self): + def test_sd_mesopic_luminous_efficiency_function(self) -> None: """ Test :func:`colour.colorimetry.lefs.\ sd_mesopic_luminous_efficiency_function` definition. diff --git a/colour/colorimetry/tests/test_lightness.py b/colour/colorimetry/tests/test_lightness.py index 907ab7977..0449a6220 100644 --- a/colour/colorimetry/tests/test_lightness.py +++ b/colour/colorimetry/tests/test_lightness.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.lightness` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -40,7 +42,7 @@ class TestLightnessGlasser1958: definition unit tests methods. """ - def test_lightness_Glasser1958(self): + def test_lightness_Glasser1958(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Glasser1958` definition. @@ -64,7 +66,7 @@ def test_lightness_Glasser1958(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_Glasser1958(self): + def test_n_dimensional_lightness_Glasser1958(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Glasser1958` definition n-dimensional arrays support. @@ -91,7 +93,7 @@ def test_n_dimensional_lightness_Glasser1958(self): lightness_Glasser1958(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_Glasser1958(self): + def test_domain_range_scale_lightness_Glasser1958(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Glasser1958` definition domain and range scale support. @@ -109,7 +111,7 @@ def test_domain_range_scale_lightness_Glasser1958(self): ) @ignore_numpy_errors - def test_nan_lightness_Glasser1958(self): + def test_nan_lightness_Glasser1958(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Glasser1958` definition nan support. @@ -124,7 +126,7 @@ class TestLightnessWyszecki1963: definition unit tests methods. """ - def test_lightness_Wyszecki1963(self): + def test_lightness_Wyszecki1963(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963` definition. @@ -148,7 +150,7 @@ def test_lightness_Wyszecki1963(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_Wyszecki1963(self): + def test_n_dimensional_lightness_Wyszecki1963(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963` definition n-dimensional arrays support. @@ -175,7 +177,7 @@ def test_n_dimensional_lightness_Wyszecki1963(self): lightness_Wyszecki1963(Y), W, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_Wyszecki1963(self): + def test_domain_range_scale_lightness_Wyszecki1963(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963` definition domain and range scale support. @@ -193,7 +195,7 @@ def test_domain_range_scale_lightness_Wyszecki1963(self): ) @ignore_numpy_errors - def test_nan_lightness_Wyszecki1963(self): + def test_nan_lightness_Wyszecki1963(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Wyszecki1963` definition nan support. @@ -208,7 +210,7 @@ class TestIntermediateLightnessFunctionCIE1976: intermediate_lightness_function_CIE1976` definition unit tests methods. """ - def test_intermediate_lightness_function_CIE1976(self): + def test_intermediate_lightness_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.\ intermediate_lightness_function_CIE1976` definition. @@ -232,7 +234,7 @@ def test_intermediate_lightness_function_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_intermediate_lightness_function_CIE1976(self): + def test_n_dimensional_intermediate_lightness_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.\ intermediate_lightness_function_CIE1976` definition n-dimensional arrays @@ -266,7 +268,7 @@ def test_n_dimensional_intermediate_lightness_function_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_intermediate_lightness_function_CIE1976(self): + def test_domain_range_scale_intermediate_lightness_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.\ intermediate_lightness_function_CIE1976` definition domain and range scale @@ -284,7 +286,7 @@ def test_domain_range_scale_intermediate_lightness_function_CIE1976(self): ) @ignore_numpy_errors - def test_nan_intermediate_lightness_function_CIE1976(self): + def test_nan_intermediate_lightness_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.\ intermediate_lightness_function_CIE1976` definition nan support. @@ -301,7 +303,7 @@ class TestLightnessCIE1976: unit tests methods. """ - def test_lightness_CIE1976(self): + def test_lightness_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_CIE1976` definition. @@ -343,7 +345,7 @@ def test_lightness_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_CIE1976(self): + def test_n_dimensional_lightness_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_CIE1976` definition n-dimensional arrays support. @@ -370,7 +372,7 @@ def test_n_dimensional_lightness_CIE1976(self): lightness_CIE1976(Y), L_star, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_CIE1976(self): + def test_domain_range_scale_lightness_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_CIE1976` definition domain and range scale support. @@ -388,7 +390,7 @@ def test_domain_range_scale_lightness_CIE1976(self): ) @ignore_numpy_errors - def test_nan_lightness_CIE1976(self): + def test_nan_lightness_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_CIE1976` definition nan support. @@ -403,7 +405,7 @@ class TestLightnessFairchild2010: definition unit tests methods. """ - def test_lightness_Fairchild2010(self): + def test_lightness_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010` definition. @@ -445,7 +447,7 @@ def test_lightness_Fairchild2010(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_Fairchild2010(self): + def test_n_dimensional_lightness_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010` definition n-dimensional arrays support. @@ -472,7 +474,7 @@ def test_n_dimensional_lightness_Fairchild2010(self): lightness_Fairchild2010(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_Fairchild2010(self): + def test_domain_range_scale_lightness_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010` definition domain and range scale support. @@ -490,7 +492,7 @@ def test_domain_range_scale_lightness_Fairchild2010(self): ) @ignore_numpy_errors - def test_nan_lightness_Fairchild2010(self): + def test_nan_lightness_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2010` definition nan support. @@ -505,7 +507,7 @@ class TestLightnessFairchild2011: definition unit tests methods. """ - def test_lightness_Fairchild2011(self): + def test_lightness_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011` definition. @@ -547,7 +549,7 @@ def test_lightness_Fairchild2011(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_Fairchild2011(self): + def test_n_dimensional_lightness_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011` definition n-dimensional arrays support. @@ -574,7 +576,7 @@ def test_n_dimensional_lightness_Fairchild2011(self): lightness_Fairchild2011(Y), L_hdr, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_Fairchild2011(self): + def test_domain_range_scale_lightness_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011` definition domain and range scale support. @@ -592,7 +594,7 @@ def test_domain_range_scale_lightness_Fairchild2011(self): ) @ignore_numpy_errors - def test_nan_lightness_Fairchild2011(self): + def test_nan_lightness_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Fairchild2011` definition nan support. @@ -607,7 +609,7 @@ class TestLightnessAbebe2017: definition unit tests methods. """ - def test_lightness_Abebe2017(self): + def test_lightness_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Abebe2017` definition. @@ -643,7 +645,7 @@ def test_lightness_Abebe2017(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_lightness_Abebe2017(self): + def test_n_dimensional_lightness_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Abebe2017` definition n-dimensional arrays support. @@ -670,7 +672,7 @@ def test_n_dimensional_lightness_Abebe2017(self): lightness_Abebe2017(Y), L, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_lightness_Abebe2017(self): + def test_domain_range_scale_lightness_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Abebe2017` definition domain and range scale support. @@ -688,13 +690,14 @@ def test_domain_range_scale_lightness_Abebe2017(self): ) @ignore_numpy_errors - def test_nan_lightness_Abebe2017(self): + def test_nan_lightness_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness_Abebe2017` definition nan support. """ - lightness_Abebe2017(*[np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])] * 2) + cases = np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) + lightness_Abebe2017(cases, cases) class TestLightness: @@ -703,7 +706,7 @@ class TestLightness: tests methods. """ - def test_domain_range_scale_lightness(self): + def test_domain_range_scale_lightness(self) -> None: """ Test :func:`colour.colorimetry.lightness.lightness` definition domain and range scale support. diff --git a/colour/colorimetry/tests/test_luminance.py b/colour/colorimetry/tests/test_luminance.py index da0a8456b..4bb9b03e4 100644 --- a/colour/colorimetry/tests/test_luminance.py +++ b/colour/colorimetry/tests/test_luminance.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.luminance` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -40,7 +42,7 @@ class TestLuminanceNewhall1943: definition unit tests methods. """ - def test_luminance_Newhall1943(self): + def test_luminance_Newhall1943(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Newhall1943` definition. @@ -64,7 +66,7 @@ def test_luminance_Newhall1943(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_Newhall1943(self): + def test_n_dimensional_luminance_Newhall1943(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Newhall1943` definition n-dimensional arrays support. @@ -91,7 +93,7 @@ def test_n_dimensional_luminance_Newhall1943(self): luminance_Newhall1943(V), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_Newhall1943(self): + def test_domain_range_scale_luminance_Newhall1943(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Newhall1943` definition domain and range scale support. @@ -109,7 +111,7 @@ def test_domain_range_scale_luminance_Newhall1943(self): ) @ignore_numpy_errors - def test_nan_luminance_Newhall1943(self): + def test_nan_luminance_Newhall1943(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Newhall1943` definition nan support. @@ -124,7 +126,7 @@ class TestLuminanceASTMD1535: definition unit tests methods. """ - def test_luminance_ASTMD1535(self): + def test_luminance_ASTMD1535(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_ASTMD1535` definition. @@ -148,7 +150,7 @@ def test_luminance_ASTMD1535(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_ASTMD1535(self): + def test_n_dimensional_luminance_ASTMD1535(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_ASTMD1535` definition n-dimensional arrays support. @@ -175,7 +177,7 @@ def test_n_dimensional_luminance_ASTMD1535(self): luminance_ASTMD1535(V), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_ASTMD1535(self): + def test_domain_range_scale_luminance_ASTMD1535(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_ASTMD1535` definition domain and range scale support. @@ -193,7 +195,7 @@ def test_domain_range_scale_luminance_ASTMD1535(self): ) @ignore_numpy_errors - def test_nan_luminance_ASTMD1535(self): + def test_nan_luminance_ASTMD1535(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_ASTMD1535` definition nan support. @@ -208,7 +210,7 @@ class TestIntermediateLuminanceFunctionCIE1976: intermediate_luminance_function_CIE1976` definition unit tests methods. """ - def test_intermediate_luminance_function_CIE1976(self): + def test_intermediate_luminance_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition. @@ -232,7 +234,7 @@ def test_intermediate_luminance_function_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_intermediate_luminance_function_CIE1976(self): + def test_n_dimensional_intermediate_luminance_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition n-dimensional arrays @@ -266,7 +268,7 @@ def test_n_dimensional_intermediate_luminance_function_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): + def test_domain_range_scale_intermediate_luminance_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition domain and range scale @@ -284,7 +286,7 @@ def test_domain_range_scale_intermediate_luminance_function_CIE1976(self): ) @ignore_numpy_errors - def test_nan_intermediate_luminance_function_CIE1976(self): + def test_nan_intermediate_luminance_function_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.\ intermediate_luminance_function_CIE1976` definition nan support. @@ -301,7 +303,7 @@ class TestLuminanceCIE1976: unit tests methods. """ - def test_luminance_CIE1976(self): + def test_luminance_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition. @@ -343,7 +345,7 @@ def test_luminance_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_CIE1976(self): + def test_n_dimensional_luminance_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition n-dimensional arrays support. @@ -370,7 +372,7 @@ def test_n_dimensional_luminance_CIE1976(self): luminance_CIE1976(L_star), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_CIE1976(self): + def test_domain_range_scale_luminance_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition domain and range scale support. @@ -388,7 +390,7 @@ def test_domain_range_scale_luminance_CIE1976(self): ) @ignore_numpy_errors - def test_nan_luminance_CIE1976(self): + def test_nan_luminance_CIE1976(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_CIE1976` definition nan support. @@ -403,7 +405,7 @@ class TestLuminanceFairchild2010: definition unit tests methods. """ - def test_luminance_Fairchild2010(self): + def test_luminance_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2010` definition. @@ -445,7 +447,7 @@ def test_luminance_Fairchild2010(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_Fairchild2010(self): + def test_n_dimensional_luminance_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2010` definition n-dimensional arrays support. @@ -472,7 +474,7 @@ def test_n_dimensional_luminance_Fairchild2010(self): luminance_Fairchild2010(L_hdr), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_Fairchild2010(self): + def test_domain_range_scale_luminance_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2010` definition domain and range scale support. @@ -490,7 +492,7 @@ def test_domain_range_scale_luminance_Fairchild2010(self): ) @ignore_numpy_errors - def test_nan_luminance_Fairchild2010(self): + def test_nan_luminance_Fairchild2010(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2010` definition nan support. @@ -505,7 +507,7 @@ class TestLuminanceFairchild2011: definition unit tests methods. """ - def test_luminance_Fairchild2011(self): + def test_luminance_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2011` definition. @@ -547,7 +549,7 @@ def test_luminance_Fairchild2011(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_Fairchild2011(self): + def test_n_dimensional_luminance_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2011` definition n-dimensional arrays support. @@ -574,7 +576,7 @@ def test_n_dimensional_luminance_Fairchild2011(self): luminance_Fairchild2011(L_hdr), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_Fairchild2011(self): + def test_domain_range_scale_luminance_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2011` definition domain and range scale support. @@ -592,7 +594,7 @@ def test_domain_range_scale_luminance_Fairchild2011(self): ) @ignore_numpy_errors - def test_nan_luminance_Fairchild2011(self): + def test_nan_luminance_Fairchild2011(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Fairchild2011` definition nan support. @@ -607,7 +609,7 @@ class TestLuminanceAbebe2017: definition unit tests methods. """ - def test_luminance_Abebe2017(self): + def test_luminance_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Abebe2017` definition. @@ -643,7 +645,7 @@ def test_luminance_Abebe2017(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_luminance_Abebe2017(self): + def test_n_dimensional_luminance_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Abebe2017` definition n-dimensional arrays support. @@ -670,7 +672,7 @@ def test_n_dimensional_luminance_Abebe2017(self): luminance_Abebe2017(L), Y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_luminance_Abebe2017(self): + def test_domain_range_scale_luminance_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Abebe2017` definition domain and range scale support. @@ -688,13 +690,14 @@ def test_domain_range_scale_luminance_Abebe2017(self): ) @ignore_numpy_errors - def test_nan_luminance_Abebe2017(self): + def test_nan_luminance_Abebe2017(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance_Abebe2017` definition nan support. """ - luminance_Abebe2017(*[np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan])] * 2) + cases = np.array([-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]) + luminance_Abebe2017(cases, cases) class TestLuminance: @@ -703,7 +706,7 @@ class TestLuminance: tests methods. """ - def test_domain_range_scale_luminance(self): + def test_domain_range_scale_luminance(self) -> None: """ Test :func:`colour.colorimetry.luminance.luminance` definition domain and range scale support. diff --git a/colour/colorimetry/tests/test_photometry.py b/colour/colorimetry/tests/test_photometry.py index c4e9abfc9..cae9fcf3f 100644 --- a/colour/colorimetry/tests/test_photometry.py +++ b/colour/colorimetry/tests/test_photometry.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.photometry` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -32,7 +34,7 @@ class TestLuminousFlux: tests methods. """ - def test_luminous_flux(self): + def test_luminous_flux(self) -> None: """Test :func:`colour.colorimetry.photometry.luminous_flux` definition.""" np.testing.assert_allclose( @@ -60,7 +62,7 @@ class TestLuminousEfficiency: definition unit tests methods. """ - def test_luminous_efficiency(self): + def test_luminous_efficiency(self) -> None: """ Test :func:`colour.colorimetry.photometry.luminous_efficiency` definition. @@ -91,7 +93,7 @@ class TestLuminousEfficacy: definition unit tests methods. """ - def test_luminous_efficacy(self): + def test_luminous_efficacy(self) -> None: """ Test :func:`colour.colorimetry.photometry.luminous_efficacy` definition. diff --git a/colour/colorimetry/tests/test_spectrum.py b/colour/colorimetry/tests/test_spectrum.py index 3838a40ec..3bafe34ad 100644 --- a/colour/colorimetry/tests/test_spectrum.py +++ b/colour/colorimetry/tests/test_spectrum.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.spectrum` module.""" +from __future__ import annotations + import pickle import numpy as np @@ -1253,7 +1255,7 @@ class TestSpectralShape: methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -1267,7 +1269,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(SpectralShape) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -1286,7 +1288,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(SpectralShape) - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether the :class:`colour.colorimetry.spectrum.SpectralShape` class can be pickled. @@ -1297,7 +1299,7 @@ class can be pickled. data = pickle.loads(data) # noqa: S301 assert shape == data - def test_start(self): + def test_start(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.start` attribute. @@ -1309,7 +1311,7 @@ def test_start(self): pytest.raises(AssertionError, lambda: SpectralShape(360, 0, 1)) - def test_end(self): + def test_end(self) -> None: """Test :attr:`colour.colorimetry.spectrum.SpectralShape.end` property.""" assert SpectralShape(360, 830, 1).end == 830 @@ -1318,7 +1320,7 @@ def test_end(self): pytest.raises(AssertionError, lambda: SpectralShape(830, 0, 1)) - def test_interval(self): + def test_interval(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.interval` property. @@ -1326,7 +1328,7 @@ def test_interval(self): assert SpectralShape(360, 830, 1).interval == 1 - def test_boundaries(self): + def test_boundaries(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.boundaries` property. @@ -1338,7 +1340,7 @@ def test_boundaries(self): assert shape.start == 360 assert shape.end == 830 - def test_wavelengths(self): + def test_wavelengths(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralShape.wavelengths` property. @@ -1349,7 +1351,7 @@ def test_wavelengths(self): np.arange(0, 10 + 0.1, 0.1), ) - def test__hash__(self): + def test__hash__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__hash__` method. @@ -1357,7 +1359,7 @@ def test__hash__(self): assert isinstance(hash(SpectralShape(0, 10, 0.1)), int) - def test__iter__(self): + def test__iter__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__iter__` method. @@ -1368,7 +1370,7 @@ def test__iter__(self): np.arange(0, 10 + 0.1, 0.1), ) - def test__contains__(self): + def test__contains__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__contains__` method. @@ -1382,7 +1384,7 @@ def test__contains__(self): assert np.array([0.5, 0.61]) not in SpectralShape(0, 10, 0.1) - def test__len__(self): + def test__len__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__len__` method. @@ -1390,7 +1392,7 @@ def test__len__(self): assert len(SpectralShape(0, 10, 0.1)) == 101 - def test__eq__(self): + def test__eq__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__eq__` method. @@ -1399,7 +1401,7 @@ def test__eq__(self): assert SpectralShape(0, 10, 0.1) == SpectralShape(0, 10, 0.1) assert SpectralShape(0, 10, 0.1) != () - def test__ne__(self): + def test__ne__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralShape.__ne__` method. @@ -1407,7 +1409,7 @@ def test__ne__(self): assert SpectralShape(0, 10, 0.1) != SpectralShape(1, 10, 0.1) - def test_range(self): + def test_range(self) -> None: """Test :func:`colour.colorimetry.spectrum.SpectralShape.range` method.""" np.testing.assert_array_equal( @@ -1422,7 +1424,7 @@ class TestSpectralDistribution: class unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._sd = SpectralDistribution(DATA_SAMPLE, name="Sample") @@ -1435,7 +1437,7 @@ def setup_method(self): self._phi = (1 + np.sqrt(5)) / 2 - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -1448,7 +1450,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(SpectralDistribution) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -1463,7 +1465,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(SpectralDistribution) - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether the :class:`colour.colorimetry.spectrum.\ SpectralDistribution` class can be pickled. @@ -1473,7 +1475,7 @@ def test_pickling(self): data = pickle.loads(data) # noqa: S301 assert self._sd == data - def test_display_name(self): + def test_display_name(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.display_name` property. @@ -1482,7 +1484,7 @@ def test_display_name(self): assert self._sd.display_name == "Sample" assert self._non_uniform_sd.display_name == "Display Non Uniform Sample" - def test_wavelengths(self): + def test_wavelengths(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.wavelengths` property. @@ -1494,7 +1496,7 @@ def test_wavelengths(self): sd.wavelengths = sd.wavelengths + 10 np.testing.assert_array_equal(sd.wavelengths, sd.domain) - def test_values(self): + def test_values(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.values` property. @@ -1506,7 +1508,7 @@ def test_values(self): sd.values = sd.values + 10 np.testing.assert_array_equal(sd.values, sd.range) - def test_shape(self): + def test_shape(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.SpectralDistribution.shape` property. @@ -1514,7 +1516,7 @@ def test_shape(self): assert self._sd.shape == SpectralShape(340, 820, 20) - def test__init__(self): + def test__init__(self) -> None: """ Test :meth:`colour.colorimetry.spectrum.SpectralDistribution.__init__` method. @@ -1529,7 +1531,7 @@ def test__init__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_interpolate(self): + def test_interpolate(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.interpolate` method. @@ -1559,7 +1561,7 @@ def test_interpolate(self): 1, ) - def test_extrapolate(self): + def test_extrapolate(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.extrapolate` method. @@ -1590,7 +1592,7 @@ def test_extrapolate(self): sd[50], 2.4999999999999964, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_align(self): + def test_align(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.align` method. @@ -1602,7 +1604,7 @@ def test_align(self): shape = SpectralShape(600, 650, 1) assert self._sd.copy().align(shape).shape == shape - def test_trim(self): + def test_trim(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.trim` method. @@ -1614,7 +1616,7 @@ def test_trim(self): shape = SpectralShape(200, 900, 1) assert self._sd.copy().trim(shape).shape == self._sd.shape - def test_normalise(self): + def test_normalise(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ SpectralDistribution.normalise` method. @@ -1626,7 +1628,7 @@ def test_normalise(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_callback_on_domain_changed(self): + def test_callback_on_domain_changed(self) -> None: """ Test :class:`colour.colorimetry.spectrum.\ SpectralDistribution` *on_domain_changed* callback. @@ -1644,7 +1646,7 @@ class TestMultiSpectralDistributions: class unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._labels = ("x_bar", "y_bar", "z_bar") @@ -1684,7 +1686,7 @@ def setup_method(self): self._phi = (1 + np.sqrt(5)) / 2 - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -1698,7 +1700,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(MultiSpectralDistributions) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -1714,7 +1716,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MultiSpectralDistributions) - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether the :class:`colour.colorimetry.spectrum.\ MultiSpectralDistributions` class can be pickled. @@ -1724,7 +1726,7 @@ def test_pickling(self): data = pickle.loads(data) # noqa: S301 assert self._msds == data - def test_display_name(self): + def test_display_name(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.display_name` property. @@ -1736,7 +1738,7 @@ def test_display_name(self): == "Display Non Uniform Sample Observer" ) - def test_wavelengths(self): + def test_wavelengths(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.wavelengths` property. @@ -1748,7 +1750,7 @@ def test_wavelengths(self): msds.wavelengths = msds.wavelengths + 10 np.testing.assert_array_equal(msds.wavelengths, msds.domain) - def test_values(self): + def test_values(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.values` property. @@ -1760,7 +1762,7 @@ def test_values(self): msds.values = msds.values + 10 np.testing.assert_array_equal(msds.values, msds.range) - def test_display_labels(self): + def test_display_labels(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.\ display_labels` property. @@ -1773,7 +1775,7 @@ def test_display_labels(self): "Display z_bar", ) - def test_shape(self): + def test_shape(self) -> None: """ Test :attr:`colour.colorimetry.spectrum.MultiSpectralDistributions.shape` property. @@ -1781,7 +1783,7 @@ def test_shape(self): assert self._msds.shape == SpectralShape(380, 780, 5) - def test__init__(self): + def test__init__(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.__init__` method. @@ -1796,7 +1798,7 @@ def test__init__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_interpolate(self): + def test_interpolate(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.interpolate` method. @@ -1808,7 +1810,7 @@ def test_interpolate(self): msds = reshape_msds(self._sample_msds, shape, "Interpolate") for signal in msds.signals.values(): np.testing.assert_allclose( - signal.values, + signal.values, # pyright: ignore DATA_SAMPLE_INTERPOLATED, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -1826,7 +1828,7 @@ def test_interpolate(self): ) for signal in msds.signals.values(): np.testing.assert_allclose( - signal.values, + signal.values, # pyright: ignore DATA_SAMPLE_INTERPOLATED_NON_UNIFORM, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -1836,7 +1838,7 @@ def test_interpolate(self): 1, ) - def test_extrapolate(self): + def test_extrapolate(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.extrapolate` method. @@ -1873,7 +1875,7 @@ def test_extrapolate(self): msds[50], np.array([2.5, 2.5, 2.5]), atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_align(self): + def test_align(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.align` method. @@ -1887,7 +1889,7 @@ def test_align(self): shape = SpectralShape(600, 650, 1) assert msds.align(shape).shape == shape - def test_trim(self): + def test_trim(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.trim` method. @@ -1899,7 +1901,7 @@ def test_trim(self): shape = SpectralShape(200, 900, 1) assert self._msds.copy().trim(shape).shape == self._msds.shape - def test_normalise(self): + def test_normalise(self) -> None: """ Test :func:`colour.colorimetry.spectrum. MultiSpectralDistributions.normalise` method. @@ -1911,7 +1913,7 @@ def test_normalise(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_to_sds(self): + def test_to_sds(self) -> None: """ Test :func:`colour.colorimetry.spectrum.\ MultiSpectralDistributions.to_sds` method. @@ -1924,7 +1926,7 @@ def test_to_sds(self): assert sd.name == self._labels[i] assert sd.display_name == self._display_labels[i] - def test_callback_on_domain_changed(self): + def test_callback_on_domain_changed(self) -> None: """ Test underlying :class:`colour.colorimetry.spectrum.\ SpectralDistribution` *on_domain_changed* callback when used with @@ -1943,7 +1945,7 @@ class TestReshapeSd: tests methods. """ - def test_reshape_sd(self): + def test_reshape_sd(self) -> None: """Test :func:`colour.colorimetry.spectrum.reshape_sd` definition.""" sd = SpectralDistribution(DATA_SAMPLE_ABRIDGED) @@ -1997,7 +1999,7 @@ class TestSdsAndMdsToSds: unit tests methods. """ - def test_sds_and_msds_to_sds(self): + def test_sds_and_msds_to_sds(self) -> None: """ Test :func:`colour.colorimetry.spectrum.sds_and_msds_to_sds` definition. @@ -2032,7 +2034,7 @@ class TestSdsAndMsdsToMsds: definition unit tests methods. """ - def test_sds_and_msds_to_msds(self): + def test_sds_and_msds_to_msds(self) -> None: """ Test :func:`colour.colorimetry.spectrum.sds_and_msds_to_msds` definition. diff --git a/colour/colorimetry/tests/test_transformations.py b/colour/colorimetry/tests/test_transformations.py index d8d3ce38d..99292f6c2 100644 --- a/colour/colorimetry/tests/test_transformations.py +++ b/colour/colorimetry/tests/test_transformations.py @@ -3,6 +3,8 @@ module. """ +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -38,7 +40,7 @@ class TestRGB_2_degree_cmfs_to_XYZ_2_degree_cmfs: RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition unit tests methods. """ - def test_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition. @@ -57,7 +59,7 @@ def test_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(700), cmfs[700], atol=0.0025 ) - def test_n_dimensional_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_n_dimensional_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition n-dimensional arrays @@ -92,7 +94,7 @@ def test_n_dimensional_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): ) @ignore_numpy_errors - def test_nan_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_nan_RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition nan support. @@ -109,7 +111,7 @@ class TestRGB_10_degree_cmfs_to_XYZ_10_degree_cmfs: RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition unit tests methods. """ - def test_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition. @@ -134,7 +136,7 @@ def test_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): atol=0.025, ) - def test_n_dimensional_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_n_dimensional_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition n-dimensional arrays @@ -169,7 +171,7 @@ def test_n_dimensional_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): ) @ignore_numpy_errors - def test_nan_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_nan_RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition nan support. @@ -186,7 +188,7 @@ class TestRGB_10_degree_cmfs_to_LMS_10_degree_cmfs: RGB_10_degree_cmfs_to_LMS_10_degree_cmfs` definition unit tests methods. """ - def test_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): + def test_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_LMS_10_degree_cmfs` definition. @@ -211,7 +213,7 @@ def test_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): atol=0.0025, ) - def test_n_dimensional_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): + def test_n_dimensional_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_LMS_10_degree_cmfs` definition n-dimensional arrays @@ -246,7 +248,7 @@ def test_n_dimensional_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): ) @ignore_numpy_errors - def test_nan_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self): + def test_nan_RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ RGB_10_degree_cmfs_to_LMS_10_degree_cmfs` definition nan support. @@ -263,7 +265,7 @@ class TestLMS_2_degree_cmfs_to_XYZ_2_degree_cmfs: LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition unit tests methods. """ - def test_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition. @@ -288,7 +290,7 @@ def test_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): atol=0.00015, ) - def test_n_dimensional_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_n_dimensional_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition n-dimensional arrays @@ -323,7 +325,7 @@ def test_n_dimensional_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): ) @ignore_numpy_errors - def test_nan_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self): + def test_nan_LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs` definition nan support. @@ -340,7 +342,7 @@ class TestLMS_10_degree_cmfs_to_XYZ_10_degree_cmfs: LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition unit tests methods. """ - def test_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition. @@ -365,7 +367,7 @@ def test_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): atol=0.00015, ) - def test_n_dimensional_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_n_dimensional_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition n-dimensional arrays @@ -400,7 +402,7 @@ def test_n_dimensional_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): ) @ignore_numpy_errors - def test_nan_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self): + def test_nan_LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(self) -> None: """ Test :func:`colour.colorimetry.transformations.\ LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs` definition nan support. diff --git a/colour/colorimetry/tests/test_tristimulus_values.py b/colour/colorimetry/tests/test_tristimulus_values.py index 61ad451b1..7dda05dca 100644 --- a/colour/colorimetry/tests/test_tristimulus_values.py +++ b/colour/colorimetry/tests/test_tristimulus_values.py @@ -584,7 +584,7 @@ class TestHandleSpectralArguments: handle_spectral_arguments` definition unit tests methods. """ - def test_handle_spectral_arguments(self): + def test_handle_spectral_arguments(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ handle_spectral_arguments` definition. @@ -616,7 +616,7 @@ class TestLagrangeCoefficientsASTME2022: lagrange_coefficients_ASTME2022` definition unit tests methods. """ - def test_lagrange_coefficients_ASTME2022(self): + def test_lagrange_coefficients_ASTME2022(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ lagrange_coefficients_ASTME2022` definition. @@ -658,7 +658,7 @@ class TestTristimulusWeightingFactorsASTME2022: tristimulus_weighting_factors_ASTME2022` definition unit tests methods. """ - def test_tristimulus_weighting_factors_ASTME2022(self): + def test_tristimulus_weighting_factors_ASTME2022(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ tristimulus_weighting_factors_ASTME2022` definition. @@ -729,7 +729,7 @@ def test_tristimulus_weighting_factors_ASTME2022(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self): + def test_raise_exception_tristimulus_weighting_factors_ASTME2022(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ tristimulus_weighting_factors_ASTME2022` definition raised exception. @@ -764,7 +764,7 @@ class TestAdjustTristimulusWeightingFactorsASTME308: adjust_tristimulus_weighting_factors_ASTME308` definition unit tests methods. """ - def test_adjust_tristimulus_weighting_factors_ASTME308(self): + def test_adjust_tristimulus_weighting_factors_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ adjust_tristimulus_weighting_factors_ASTME308` definition. @@ -787,7 +787,7 @@ class TestSd_to_XYZ_integration: definition unit tests methods. """ - def test_sd_to_XYZ_integration(self): + def test_sd_to_XYZ_integration(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ sd_to_XYZ_integration` definition. @@ -841,7 +841,7 @@ def test_sd_to_XYZ_integration(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_sd_to_XYZ_integration(self): + def test_domain_range_scale_sd_to_XYZ_integration(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ sd_to_XYZ_integration` definition domain and range scale support. @@ -867,7 +867,7 @@ class TestSd_to_XYZ_tristimulus_weighting_factors_ASTME308: definition unit tests methods. """ - def test_sd_to_XYZ_tristimulus_weighting_factors_ASTME308(self): + def test_sd_to_XYZ_tristimulus_weighting_factors_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ sd_to_XYZ_tristimulus_weighting_factors_ASTME308` @@ -941,7 +941,7 @@ def test_sd_to_XYZ_tristimulus_weighting_factors_ASTME308(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_sd_to_XYZ_twf_ASTME308(self): + def test_domain_range_scale_sd_to_XYZ_twf_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ sd_to_XYZ_tristimulus_weighting_factors_ASTME308` definition domain and @@ -971,14 +971,14 @@ class TestSd_to_XYZ_ASTME308: definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._sd = SD_SAMPLE.copy() self._cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] self._A = sd_CIE_standard_illuminant_A(self._cmfs.shape) - def test_sd_to_XYZ_ASTME308_mi_1nm(self): + def test_sd_to_XYZ_ASTME308_mi_1nm(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition for 1 nm measurement intervals. @@ -1035,7 +1035,7 @@ def test_sd_to_XYZ_ASTME308_mi_1nm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_sd_to_XYZ_ASTME308_mi_5nm(self): + def test_sd_to_XYZ_ASTME308_mi_5nm(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition for 5 nm measurement intervals. @@ -1140,7 +1140,7 @@ def test_sd_to_XYZ_ASTME308_mi_5nm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_sd_to_XYZ_ASTME308_mi_10nm(self): + def test_sd_to_XYZ_ASTME308_mi_10nm(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition for 10 nm measurement intervals. @@ -1210,7 +1210,7 @@ def test_sd_to_XYZ_ASTME308_mi_10nm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_sd_to_XYZ_ASTME308_mi_20nm(self): + def test_sd_to_XYZ_ASTME308_mi_20nm(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition for 20 nm measurement intervals. @@ -1325,7 +1325,7 @@ def test_sd_to_XYZ_ASTME308_mi_20nm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_sd_to_XYZ_ASTME308(self): + def test_raise_exception_sd_to_XYZ_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ_ASTME308` definition raised exception. @@ -1344,14 +1344,14 @@ class TestSd_to_XYZ: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"] self._A = sd_CIE_standard_illuminant_A(self._cmfs.shape) self._sd = reshape_sd(SD_SAMPLE, self._cmfs.shape) - def test_sd_to_XYZ(self): + def test_sd_to_XYZ(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.sd_to_XYZ` definition. @@ -1428,7 +1428,7 @@ class TestMsds_to_XYZ_integration: msds_to_XYZ_integration` definition unit tests methods. """ - def test_msds_to_XYZ_integration(self): + def test_msds_to_XYZ_integration(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_integration` definition. @@ -1464,7 +1464,7 @@ def test_msds_to_XYZ_integration(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_msds_to_XYZ_integration(self): + def test_domain_range_scale_msds_to_XYZ_integration(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_integration` definition domain and range scale support. @@ -1492,7 +1492,7 @@ class TestMsds_to_XYZ_ASTME308: definition unit tests methods. """ - def test_msds_to_XYZ_ASTME308(self): + def test_msds_to_XYZ_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_ASTME308` definition. @@ -1512,7 +1512,7 @@ def test_msds_to_XYZ_ASTME308(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_msds_to_XYZ_ASTME308(self): + def test_domain_range_scale_msds_to_XYZ_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_ASTME308` definition domain and range scale support. @@ -1532,7 +1532,7 @@ def test_domain_range_scale_msds_to_XYZ_ASTME308(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_msds_to_XYZ_ASTME308(self): + def test_raise_exception_msds_to_XYZ_ASTME308(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.\ msds_to_XYZ_ASTME308` definition raise exception. @@ -1546,7 +1546,7 @@ class TestAbsoluteIntegrationToXYZ: Test the absolute integration to tristimulus values for :math:`k = 683` """ - def test_absolute_integration_to_TVS_1nm(self): + def test_absolute_integration_to_TVS_1nm(self) -> None: """ Test the absolute, i.e., user given :math:`k` value, integration to tristimulus values for 1nm interval. @@ -1592,7 +1592,7 @@ def test_absolute_integration_to_TVS_1nm(self): ), ) - def test_absolute_integration_to_TVS_5nm(self): + def test_absolute_integration_to_TVS_5nm(self) -> None: """ Test the absolute, i.e., user given :math:`k` value, integration to tristimulus values for 5nm interval by ensuring that the *Riemann Sum* @@ -1648,7 +1648,7 @@ class TestWavelength_to_XYZ: definition unit tests methods. """ - def test_wavelength_to_XYZ(self): + def test_wavelength_to_XYZ(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.wavelength_to_XYZ` definition. @@ -1672,7 +1672,7 @@ def test_wavelength_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_wavelength_to_XYZ(self): + def test_raise_exception_wavelength_to_XYZ(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.wavelength_to_XYZ` definition raised exception. @@ -1682,7 +1682,7 @@ def test_raise_exception_wavelength_to_XYZ(self): pytest.raises(ValueError, wavelength_to_XYZ, 1000) - def test_n_dimensional_wavelength_to_XYZ(self): + def test_n_dimensional_wavelength_to_XYZ(self) -> None: """ Test :func:`colour.colorimetry.tristimulus_values.wavelength_to_XYZ` definition n-dimensional arrays support. diff --git a/colour/colorimetry/tests/test_uniformity.py b/colour/colorimetry/tests/test_uniformity.py index e9bd5ea19..7384d35af 100644 --- a/colour/colorimetry/tests/test_uniformity.py +++ b/colour/colorimetry/tests/test_uniformity.py @@ -227,7 +227,7 @@ class TestSpectralUniformity: definition unit tests methods. """ - def test_spectral_uniformity(self): + def test_spectral_uniformity(self) -> None: """ Test :func:`colour.colorimetry.uniformity.spectral_uniformity` definition. diff --git a/colour/colorimetry/tests/test_whiteness.py b/colour/colorimetry/tests/test_whiteness.py index df51083ad..a6e86d9aa 100644 --- a/colour/colorimetry/tests/test_whiteness.py +++ b/colour/colorimetry/tests/test_whiteness.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.whiteness` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -40,7 +42,7 @@ class TestWhitenessBerger1959: definition unit tests methods. """ - def test_whiteness_Berger1959(self): + def test_whiteness_Berger1959(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition. @@ -73,7 +75,7 @@ def test_whiteness_Berger1959(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_Berger1959(self): + def test_n_dimensional_whiteness_Berger1959(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition n_dimensional arrays support. @@ -97,7 +99,7 @@ def test_n_dimensional_whiteness_Berger1959(self): whiteness_Berger1959(XYZ, XYZ_0), W, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_Berger1959(self): + def test_domain_range_scale_whiteness_Berger1959(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition domain and range scale support. @@ -117,7 +119,7 @@ def test_domain_range_scale_whiteness_Berger1959(self): ) @ignore_numpy_errors - def test_nan_whiteness_Berger1959(self): + def test_nan_whiteness_Berger1959(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition nan support. @@ -134,7 +136,7 @@ class TestWhitenessTaube1960: definition unit tests methods. """ - def test_whiteness_Taube1960(self): + def test_whiteness_Taube1960(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Taube1960` definition. @@ -167,7 +169,7 @@ def test_whiteness_Taube1960(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_Taube1960(self): + def test_n_dimensional_whiteness_Taube1960(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Taube1960` definition n_dimensional arrays support. @@ -191,7 +193,7 @@ def test_n_dimensional_whiteness_Taube1960(self): whiteness_Taube1960(XYZ, XYZ_0), WI, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_Taube1960(self): + def test_domain_range_scale_whiteness_Taube1960(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Taube1960` definition domain and range scale support. @@ -211,7 +213,7 @@ def test_domain_range_scale_whiteness_Taube1960(self): ) @ignore_numpy_errors - def test_nan_whiteness_Berger1959(self): + def test_nan_whiteness_Berger1959(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Berger1959` definition nan support. @@ -228,7 +230,7 @@ class TestWhitenessStensby1968: definition unit tests methods. """ - def test_whiteness_Stensby1968(self): + def test_whiteness_Stensby1968(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Stensby1968` definition. @@ -252,7 +254,7 @@ def test_whiteness_Stensby1968(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_Stensby1968(self): + def test_n_dimensional_whiteness_Stensby1968(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Stensby1968` definition n_dimensional arrays support. @@ -273,7 +275,7 @@ def test_n_dimensional_whiteness_Stensby1968(self): whiteness_Stensby1968(Lab), WI, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_Stensby1968(self): + def test_domain_range_scale_whiteness_Stensby1968(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Stensby1968` definition domain and range scale support. @@ -292,7 +294,7 @@ def test_domain_range_scale_whiteness_Stensby1968(self): ) @ignore_numpy_errors - def test_nan_whiteness_Stensby1968(self): + def test_nan_whiteness_Stensby1968(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Stensby1968` definition nan support. @@ -309,7 +311,7 @@ class TestWhitenessASTM313: definition unit tests methods. """ - def test_whiteness_ASTME313(self): + def test_whiteness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_ASTME313` definition. @@ -333,7 +335,7 @@ def test_whiteness_ASTME313(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_ASTME313(self): + def test_n_dimensional_whiteness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_ASTME313` definition n_dimensional arrays support. @@ -354,7 +356,7 @@ def test_n_dimensional_whiteness_ASTME313(self): whiteness_ASTME313(XYZ), WI, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_ASTME313(self): + def test_domain_range_scale_whiteness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_ASTME313` definition domain and range scale support. @@ -373,7 +375,7 @@ def test_domain_range_scale_whiteness_ASTME313(self): ) @ignore_numpy_errors - def test_nan_whiteness_ASTME313(self): + def test_nan_whiteness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_ASTME313` definition nan support. @@ -390,7 +392,7 @@ class TestWhitenessGanz1979: definition unit tests methods. """ - def test_whiteness_Ganz1979(self): + def test_whiteness_Ganz1979(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Ganz1979` definition. @@ -414,7 +416,7 @@ def test_whiteness_Ganz1979(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_Ganz1979(self): + def test_n_dimensional_whiteness_Ganz1979(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Ganz1979` definition n_dimensional arrays support. @@ -442,7 +444,7 @@ def test_n_dimensional_whiteness_Ganz1979(self): whiteness_Ganz1979(xy, Y), WT, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_Ganz1979(self): + def test_domain_range_scale_whiteness_Ganz1979(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Ganz1979` definition domain and range scale support. @@ -462,7 +464,7 @@ def test_domain_range_scale_whiteness_Ganz1979(self): ) @ignore_numpy_errors - def test_nan_whiteness_Ganz1979(self): + def test_nan_whiteness_Ganz1979(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_Ganz1979` definition nan support. @@ -479,7 +481,7 @@ class TestWhitenessCIE2004: definition unit tests methods. """ - def test_whiteness_CIE2004(self): + def test_whiteness_CIE2004(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition. @@ -509,7 +511,7 @@ def test_whiteness_CIE2004(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_whiteness_CIE2004(self): + def test_n_dimensional_whiteness_CIE2004(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition n_dimensional arrays support. @@ -540,7 +542,7 @@ def test_n_dimensional_whiteness_CIE2004(self): whiteness_CIE2004(xy, Y, xy_n), WT, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_whiteness_CIE2004(self): + def test_domain_range_scale_whiteness_CIE2004(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition domain and range scale support. @@ -561,7 +563,7 @@ def test_domain_range_scale_whiteness_CIE2004(self): ) @ignore_numpy_errors - def test_nan_whiteness_CIE2004(self): + def test_nan_whiteness_CIE2004(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness_CIE2004` definition nan support. @@ -578,7 +580,7 @@ class TestWhiteness: tests methods. """ - def test_domain_range_scale_whiteness(self): + def test_domain_range_scale_whiteness(self) -> None: """ Test :func:`colour.colorimetry.whiteness.whiteness` definition domain and range scale support. diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index e3f15b06b..fce52f93f 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.colorimetry.yellowness` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -37,7 +39,7 @@ class TestYellownessASTMD1925: definition unit tests methods. """ - def test_yellowness_ASTMD1925(self): + def test_yellowness_ASTMD1925(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTMD1925` definition. @@ -61,7 +63,7 @@ def test_yellowness_ASTMD1925(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_yellowness_ASTMD1925(self): + def test_n_dimensional_yellowness_ASTMD1925(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTMD1925` definition n_dimensional arrays support. @@ -82,7 +84,7 @@ def test_n_dimensional_yellowness_ASTMD1925(self): yellowness_ASTMD1925(XYZ), YI, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_yellowness_ASTMD1925(self): + def test_domain_range_scale_yellowness_ASTMD1925(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTMD1925` definition domain and range scale support. @@ -101,7 +103,7 @@ def test_domain_range_scale_yellowness_ASTMD1925(self): ) @ignore_numpy_errors - def test_nan_yellowness_ASTMD1925(self): + def test_nan_yellowness_ASTMD1925(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTMD1925` definition nan support. @@ -118,7 +120,7 @@ class TestYellownessASTM313Alternative: yellowness_ASTME313_alternative` definition unit tests methods. """ - def test_yellowness_ASTME313_alternative(self): + def test_yellowness_ASTME313_alternative(self) -> None: """ Test :func:`colour.colorimetry.yellowness.\ yellowness_ASTME313_alternative` definition. @@ -148,7 +150,7 @@ def test_yellowness_ASTME313_alternative(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_yellowness_ASTME313_alternative(self): + def test_n_dimensional_yellowness_ASTME313_alternative(self) -> None: """ Test :func:`colour.colorimetry.yellowness.\ yellowness_ASTME313_alternative` definition n_dimensional arrays support. @@ -173,7 +175,7 @@ def test_n_dimensional_yellowness_ASTME313_alternative(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_yellowness_ASTME313_alternative(self): + def test_domain_range_scale_yellowness_ASTME313_alternative(self) -> None: """ Test :func:`colour.colorimetry.yellowness.\ yellowness_ASTME313_alternative` definition domain and range scale support. @@ -192,7 +194,7 @@ def test_domain_range_scale_yellowness_ASTME313_alternative(self): ) @ignore_numpy_errors - def test_nan_yellowness_ASTME313_alternative(self): + def test_nan_yellowness_ASTME313_alternative(self) -> None: """ Test :func:`colour.colorimetry.yellowness.\ yellowness_ASTME313_alternative` definition nan support. @@ -209,7 +211,7 @@ class TestYellownessASTM313: definition unit tests methods. """ - def test_yellowness_ASTME313(self): + def test_yellowness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTME313` definition. @@ -244,7 +246,7 @@ def test_yellowness_ASTME313(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_yellowness_ASTME313(self): + def test_n_dimensional_yellowness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTME313` definition n_dimensional arrays support. @@ -265,7 +267,7 @@ def test_n_dimensional_yellowness_ASTME313(self): yellowness_ASTME313(XYZ), YI, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_yellowness_ASTME313(self): + def test_domain_range_scale_yellowness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTME313` definition domain and range scale support. @@ -284,7 +286,7 @@ def test_domain_range_scale_yellowness_ASTME313(self): ) @ignore_numpy_errors - def test_nan_yellowness_ASTME313(self): + def test_nan_yellowness_ASTME313(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness_ASTME313` definition nan support. @@ -301,7 +303,7 @@ class TestYellowness: tests methods. """ - def test_domain_range_scale_yellowness(self): + def test_domain_range_scale_yellowness(self) -> None: """ Test :func:`colour.colorimetry.yellowness.yellowness` definition domain and range scale support. diff --git a/colour/colorimetry/uniformity.py b/colour/colorimetry/uniformity.py index 25c75f141..b6b959881 100644 --- a/colour/colorimetry/uniformity.py +++ b/colour/colorimetry/uniformity.py @@ -15,6 +15,8 @@ from __future__ import annotations +from collections.abc import ValuesView + import numpy as np from colour.colorimetry import ( @@ -41,6 +43,7 @@ def spectral_uniformity( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), use_second_order_derivatives: bool = False, ) -> NDArrayFloat: diff --git a/colour/continuous/abstract.py b/colour/continuous/abstract.py index 6787edc3c..962564bfe 100644 --- a/colour/continuous/abstract.py +++ b/colour/continuous/abstract.py @@ -143,7 +143,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -175,7 +175,7 @@ def dtype(self) -> Type[DTypeFloat]: @dtype.setter @abstractmethod - def dtype(self, value: Type[DTypeFloat]): + def dtype(self, value: Type[DTypeFloat]) -> None: """ Setter for the **self.dtype** property, must be reimplemented by sub-classes. @@ -207,7 +207,7 @@ def domain(self) -> NDArrayFloat: @domain.setter @abstractmethod - def domain(self, value: ArrayLike): + def domain(self, value: ArrayLike) -> None: """ Setter for the **self.domain** property, must be reimplemented by sub-classes. @@ -240,7 +240,7 @@ def range(self) -> NDArrayFloat: @range.setter @abstractmethod - def range(self, value: ArrayLike): + def range(self, value: ArrayLike) -> None: """ Setter for the **self.range** property, must be reimplemented by sub-classes. @@ -271,7 +271,7 @@ def interpolator(self) -> Type[ProtocolInterpolator]: @interpolator.setter @abstractmethod - def interpolator(self, value: Type[ProtocolInterpolator]): + def interpolator(self, value: Type[ProtocolInterpolator]) -> None: """ Setter for the **self.interpolator** property, must be reimplemented by sub-classes. @@ -304,7 +304,7 @@ def interpolator_kwargs(self) -> dict: @interpolator_kwargs.setter @abstractmethod - def interpolator_kwargs(self, value: dict): + def interpolator_kwargs(self, value: dict) -> None: """ Setter for the **self.interpolator_kwargs** property, must be reimplemented by sub-classes. @@ -335,7 +335,7 @@ def extrapolator(self) -> Type[ProtocolExtrapolator]: @extrapolator.setter @abstractmethod - def extrapolator(self, value: Type[ProtocolExtrapolator]): + def extrapolator(self, value: Type[ProtocolExtrapolator]) -> None: """ Setter for the **self.extrapolator** property, must be reimplemented by sub-classes. @@ -368,7 +368,7 @@ def extrapolator_kwargs(self) -> dict: @extrapolator_kwargs.setter @abstractmethod - def extrapolator_kwargs(self, value: dict): + def extrapolator_kwargs(self, value: dict) -> None: """ Setter for the **self.extrapolator_kwargs** property, must be reimplemented by sub-classes. @@ -452,7 +452,7 @@ def __getitem__(self, x: ArrayLike | slice) -> NDArrayFloat: ... # pragma: no cover @abstractmethod - def __setitem__(self, x: ArrayLike | slice, y: ArrayLike): + def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: """ Set the corresponding range variable :math:`y` for independent domain variable :math:`x`, must be reimplemented by sub-classes. diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 1eb92f496..0f3f7d95f 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -9,7 +9,7 @@ from __future__ import annotations -from collections.abc import Iterator, Mapping, ValuesView +from collections.abc import Iterator, KeysView, Mapping, ValuesView import numpy as np @@ -300,9 +300,17 @@ class MultiSignals(AbstractContinuousFunction): def __init__( self, data: ( - ArrayLike | DataFrame | dict | Self | Sequence | Series | Signal | None + ArrayLike + | DataFrame + | dict + | Self + | Sequence + | Series + | Signal + | ValuesView + | None ) = None, - domain: ArrayLike | None = None, + domain: ArrayLike | KeysView | None = None, labels: Sequence | None = None, **kwargs: Any, ) -> None: @@ -333,7 +341,7 @@ def dtype(self) -> Type[DTypeFloat]: return first_item(self._signals.values()).dtype @dtype.setter - def dtype(self, value: Type[DTypeFloat]): + def dtype(self, value: Type[DTypeFloat]) -> None: """Setter for the **self.dtype** property.""" for signal in self._signals.values(): @@ -361,7 +369,7 @@ def domain(self) -> NDArrayFloat: return first_item(self._signals.values()).domain @domain.setter - def domain(self, value: ArrayLike): + def domain(self, value: ArrayLike) -> None: """Setter for the **self.domain** property.""" for signal in self._signals.values(): @@ -389,7 +397,7 @@ def range(self) -> NDArrayFloat: return tstack([signal.range for signal in self._signals.values()]) @range.setter - def range(self, value: ArrayLike): + def range(self, value: ArrayLike) -> None: """Setter for the **self.range** property.""" value = as_float_array(value) @@ -429,7 +437,7 @@ def interpolator(self) -> Type[ProtocolInterpolator]: return first_item(self._signals.values()).interpolator @interpolator.setter - def interpolator(self, value: Type[ProtocolInterpolator]): + def interpolator(self, value: Type[ProtocolInterpolator]) -> None: """Setter for the **self.interpolator** property.""" if value is not None: @@ -458,7 +466,7 @@ def interpolator_kwargs(self) -> dict: return first_item(self._signals.values()).interpolator_kwargs @interpolator_kwargs.setter - def interpolator_kwargs(self, value: dict): + def interpolator_kwargs(self, value: dict) -> None: """Setter for the **self.interpolator_kwargs** property.""" for signal in self._signals.values(): @@ -486,7 +494,7 @@ def extrapolator(self) -> Type[ProtocolExtrapolator]: return first_item(self._signals.values()).extrapolator @extrapolator.setter - def extrapolator(self, value: Type[ProtocolExtrapolator]): + def extrapolator(self, value: Type[ProtocolExtrapolator]) -> None: """Setter for the **self.extrapolator** property.""" for signal in self._signals.values(): @@ -514,7 +522,7 @@ def extrapolator_kwargs(self) -> dict: return first_item(self._signals.values()).extrapolator_kwargs @extrapolator_kwargs.setter - def extrapolator_kwargs(self, value: dict): + def extrapolator_kwargs(self, value: dict) -> None: """Setter for the **self.extrapolator_kwargs** property.""" for signal in self._signals.values(): @@ -557,7 +565,7 @@ def signals(self) -> Dict[str, Signal]: def signals( self, value: ArrayLike | DataFrame | dict | Self | Series | Signal | None, - ): + ) -> None: """Setter for the **self.signals** property.""" self._signals = self.multi_signals_unpack_data( @@ -585,7 +593,7 @@ def labels(self) -> List[str]: return [str(key) for key in self._signals] @labels.setter - def labels(self, value: Sequence): + def labels(self, value: Sequence) -> None: """Setter for the **self.labels** property.""" attest( @@ -800,7 +808,7 @@ def __getitem__(self, x: ArrayLike | slice) -> NDArrayFloat: return values[..., x_c] # pyright: ignore - def __setitem__(self, x: ArrayLike | slice, y: ArrayLike): + def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: """ Set the corresponding range variable :math:`y` for independent domain variable :math:`x`. @@ -1207,9 +1215,10 @@ def multi_signals_unpack_data( | Sequence | Series | Signal + | ValuesView | None ) = None, - domain: ArrayLike | None = None, + domain: ArrayLike | KeysView | None = None, labels: Sequence | None = None, dtype: Type[DTypeFloat] | None = None, signal_type: Type[Signal] = Signal, @@ -1477,7 +1486,7 @@ def multi_signals_unpack_data( if isinstance(data, Series): signals["0"] = signal_type(data, **settings) elif isinstance(data, DataFrame): - domain_unpacked = cast(NDArrayFloat, data.index.values) + domain_unpacked = as_float_array(data.index.values, dtype) # pyright: ignore signals = { label: signal_type( data[label], @@ -1488,6 +1497,9 @@ def multi_signals_unpack_data( } if domain is not None: + if isinstance(domain, KeysView): + domain = list(domain) + domain_array = as_float_array(domain, dtype) for signal in signals.values(): diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index e176643f2..5340b8c79 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -9,7 +9,7 @@ from __future__ import annotations -from collections.abc import Iterator, Mapping, Sequence, ValuesView +from collections.abc import Iterator, KeysView, Mapping, Sequence, ValuesView from operator import pow # noqa: A004 from operator import ( add, @@ -242,8 +242,8 @@ class Signal(AbstractContinuousFunction): def __init__( self, - data: ArrayLike | dict | Self | Series | None = None, - domain: ArrayLike | None = None, + data: ArrayLike | dict | Self | Series | ValuesView | None = None, + domain: ArrayLike | KeysView | None = None, **kwargs: Any, ) -> None: super().__init__(kwargs.get("name")) @@ -294,7 +294,7 @@ def dtype(self) -> Type[DTypeFloat]: return self._dtype @dtype.setter - def dtype(self, value: Type[DTypeFloat]): + def dtype(self, value: Type[DTypeFloat]) -> None: """Setter for the **self.dtype** property.""" attest( @@ -331,7 +331,7 @@ def domain(self) -> NDArrayFloat: return ndarray_copy(self._domain) @domain.setter - def domain(self, value: ArrayLike): + def domain(self, value: ArrayLike) -> None: """Setter for the **self.domain** property.""" value = as_float_array(value, self.dtype) @@ -374,7 +374,7 @@ def range(self) -> NDArrayFloat: return ndarray_copy(self._range) @range.setter - def range(self, value: ArrayLike): + def range(self, value: ArrayLike) -> None: """Setter for the **self.range** property.""" value = as_float_array(value, self.dtype) @@ -414,7 +414,7 @@ def interpolator(self) -> Type[ProtocolInterpolator]: return self._interpolator @interpolator.setter - def interpolator(self, value: Type[ProtocolInterpolator]): + def interpolator(self, value: Type[ProtocolInterpolator]) -> None: """Setter for the **self.interpolator** property.""" # TODO: Check for interpolator compatibility. @@ -443,7 +443,7 @@ def interpolator_kwargs(self) -> dict: return self._interpolator_kwargs @interpolator_kwargs.setter - def interpolator_kwargs(self, value: dict): + def interpolator_kwargs(self, value: dict) -> None: """Setter for the **self.interpolator_kwargs** property.""" attest( @@ -474,7 +474,7 @@ def extrapolator(self) -> Type[ProtocolExtrapolator]: return self._extrapolator @extrapolator.setter - def extrapolator(self, value: Type[ProtocolExtrapolator]): + def extrapolator(self, value: Type[ProtocolExtrapolator]) -> None: """Setter for the **self.extrapolator** property.""" # TODO: Check for extrapolator compatibility. @@ -503,7 +503,7 @@ def extrapolator_kwargs(self) -> dict: return self._extrapolator_kwargs @extrapolator_kwargs.setter - def extrapolator_kwargs(self, value: dict): + def extrapolator_kwargs(self, value: dict) -> None: """Setter for the **self.extrapolator_kwargs** property.""" attest( @@ -541,7 +541,7 @@ def function(self) -> Callable: def _undefined_function( *args: Any, # noqa: ARG001 **kwargs: Any, # noqa: ARG001 - ): + ) -> None: """ Raise a :class:`ValueError` exception. @@ -717,7 +717,7 @@ def __getitem__(self, x: ArrayLike | slice) -> NDArrayFloat: else: return self.function(x) - def __setitem__(self, x: ArrayLike | slice, y: ArrayLike): + def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: """ Set the corresponding range variable :math:`y` for independent domain variable :math:`x`. @@ -938,7 +938,7 @@ def _fill_domain_nan( self, method: Literal["Constant", "Interpolation"] | str = "Interpolation", default: Real = 0, - ): + ) -> None: """ Fill NaNs in independent domain variable :math:`x` using given method. @@ -964,7 +964,7 @@ def _fill_range_nan( self, method: Literal["Constant", "Interpolation"] | str = "Interpolation", default: Real = 0, - ): + ) -> None: """ Fill NaNs in corresponding range variable :math:`y` using given method. @@ -1095,8 +1095,8 @@ def arithmetical_operation( @staticmethod @ndarray_copy_enable(True) def signal_unpack_data( - data=ArrayLike | dict | Series | "Signal" | None, - domain: ArrayLike | None = None, + data: ArrayLike | dict | Series | Signal | ValuesView | None, + domain: ArrayLike | KeysView | None = None, dtype: Type[DTypeFloat] | None = None, ) -> tuple: """ @@ -1199,10 +1199,13 @@ def signal_unpack_data( sorted(cast(Mapping, data).items()) ) elif is_pandas_installed() and isinstance(data, Series): - domain_unpacked = data.index.values - range_unpacked = data.values + domain_unpacked = as_float_array(data.index.values, dtype) # pyright: ignore + range_unpacked = as_float_array(data.values, dtype) if domain is not None: + if isinstance(domain, KeysView): + domain = list(domain) + domain_array = as_float_array(domain, dtype) attest( diff --git a/colour/continuous/tests/test_abstract.py b/colour/continuous/tests/test_abstract.py index 4923ef235..917ea653a 100644 --- a/colour/continuous/tests/test_abstract.py +++ b/colour/continuous/tests/test_abstract.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.continuous.abstract` module.""" +from __future__ import annotations + from colour.continuous import AbstractContinuousFunction __author__ = "Colour Developers" @@ -20,7 +22,7 @@ class TestAbstractContinuousFunction: class unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -37,7 +39,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(AbstractContinuousFunction) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index 262785107..26efec2b5 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.continuous.multi_signals` module.""" +from __future__ import annotations + import pickle import textwrap @@ -39,7 +41,7 @@ class TestMultiSignals: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._range_1 = np.linspace(10, 100, 10) @@ -49,7 +51,7 @@ def setup_method(self): self._multi_signals = MultiSignals(self._range_2) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -69,7 +71,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(MultiSignals) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -93,7 +95,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MultiSignals) - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether the :class:``colour.continuous.signal.MultiSignals` class can be pickled. @@ -103,7 +105,7 @@ def test_pickling(self): data = pickle.loads(data) # noqa: S301 assert self._multi_signals == data - def test_dtype(self): + def test_dtype(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.dtype` property. @@ -115,7 +117,7 @@ def test_dtype(self): multi_signals.dtype = np.float32 assert multi_signals.dtype == np.float32 - def test_domain(self): + def test_domain(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.domain` property. @@ -142,14 +144,14 @@ def test_domain(self): domain = np.linspace(0, 1, 10) domain[0] = -np.inf - def assert_warns(): + def assert_warns() -> None: """Help to test the runtime warning.""" multi_signals.domain = domain pytest.warns(ColourRuntimeWarning, assert_warns) - def test_range(self): + def test_range(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.range` property. @@ -185,7 +187,7 @@ def test_range(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_interpolator(self): + def test_interpolator(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.interpolator` property. @@ -223,7 +225,7 @@ def test_interpolator(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_interpolator_kwargs(self): + def test_interpolator_kwargs(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.\ interpolator_kwargs` property. @@ -264,7 +266,7 @@ def test_interpolator_kwargs(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_extrapolator(self): + def test_extrapolator(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.extrapolator` property. @@ -272,7 +274,7 @@ def test_extrapolator(self): assert isinstance(self._multi_signals.extrapolator(), Extrapolator) - def test_extrapolator_kwargs(self): + def test_extrapolator_kwargs(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.\ extrapolator_kwargs` property. @@ -292,7 +294,7 @@ def test_extrapolator_kwargs(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_function(self): + def test_function(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.function` property. @@ -300,7 +302,7 @@ def test_function(self): attest(callable(self._multi_signals.function)) - def test_raise_exception_function(self): + def test_raise_exception_function(self) -> None: """ Test :func:`colour.continuous.signal.multi_signals.MultiSignals.\ function` property raised exception. @@ -308,7 +310,7 @@ def test_raise_exception_function(self): pytest.raises((ValueError, TypeError), MultiSignals().function, 0) - def test_signals(self): + def test_signals(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.signals` property. @@ -320,7 +322,7 @@ def test_signals(self): np.testing.assert_array_equal(multi_signals.domain, self._domain_1) np.testing.assert_array_equal(multi_signals.range, self._range_1[:, None]) - def test_labels(self): + def test_labels(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.labels` property. @@ -334,7 +336,7 @@ def test_labels(self): assert multi_signals.labels == ["a", "b", "c"] - def test_signal_type(self): + def test_signal_type(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.signal_type` property. @@ -344,7 +346,7 @@ def test_signal_type(self): assert multi_signals.signal_type == Signal - def test__init__(self): + def test__init__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__init__` method. @@ -392,7 +394,7 @@ class NotSignal(Signal): np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_2) - def test__hash__(self): + def test__hash__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__hash__` method. @@ -400,7 +402,7 @@ def test__hash__(self): assert isinstance(hash(self._multi_signals), int) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__str__` method. @@ -427,7 +429,7 @@ def test__str__(self): assert isinstance(str(MultiSignals()), str) - def test__repr__(self): + def test__repr__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__repr__` method. @@ -457,7 +459,7 @@ def test__repr__(self): assert isinstance(repr(MultiSignals()), str) - def test__getitem__(self): + def test__getitem__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__getitem__` method. @@ -504,7 +506,7 @@ def test__getitem__(self): ) np.testing.assert_allclose( - self._multi_signals[:, :], + self._multi_signals[:, :], # pyright: ignore self._multi_signals.range, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -522,7 +524,7 @@ def test__getitem__(self): ) np.testing.assert_allclose( - self._multi_signals[:, 0:2], + self._multi_signals[:, 0:2], # pyright: ignore np.array( [ [10.0, 20.0], @@ -564,7 +566,7 @@ def test__getitem__(self): np.array([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0]]), ) - def test__setitem__(self): + def test__setitem__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__setitem__` method. @@ -687,7 +689,7 @@ def test__setitem__(self): multi_signals.range, 40, atol=TOLERANCE_ABSOLUTE_TESTS ) - multi_signals[:, :] = 50 + multi_signals[:, :] = 50 # pyright: ignore np.testing.assert_allclose( multi_signals.range, 50, atol=TOLERANCE_ABSOLUTE_TESTS ) @@ -706,7 +708,7 @@ def test__setitem__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - multi_signals[:, 0:2] = 50 + multi_signals[:, 0:2] = 50 # pyright: ignore np.testing.assert_allclose( multi_signals.range, np.array( @@ -726,7 +728,7 @@ def test__setitem__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test__contains__(self): + def test__contains__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__contains__` method. @@ -736,7 +738,7 @@ def test__contains__(self): assert 0.5 in self._multi_signals assert 1000 not in self._multi_signals - def test__iter__(self): + def test__iter__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__iter__` method.""" domain = np.arange(0, 10) @@ -744,7 +746,7 @@ def test__iter__(self): np.testing.assert_array_equal(domain_range_value[0], domain[i]) np.testing.assert_array_equal(domain_range_value[1:], self._range_2[i]) - def test__len__(self): + def test__len__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__len__` method. @@ -752,7 +754,7 @@ def test__len__(self): assert len(self._multi_signals) == 10 - def test__eq__(self): + def test__eq__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__eq__` method. @@ -765,7 +767,7 @@ def test__eq__(self): assert signal_1 != () - def test__ne__(self): + def test__ne__(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.__ne__` method. @@ -811,7 +813,7 @@ class NotExtrapolator(Extrapolator): } assert multi_signals_1 == multi_signals_2 - def test_arithmetical_operation(self): + def test_arithmetical_operation(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.\ arithmetical_operation` method. @@ -922,7 +924,7 @@ def test_arithmetical_operation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_is_uniform(self): + def test_is_uniform(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.is_uniform` method. @@ -934,13 +936,13 @@ def test_is_uniform(self): multi_signals[0.5] = 1.0 assert not multi_signals.is_uniform() - def test_copy(self): + def test_copy(self) -> None: """Test :func:`colour.continuous.multi_signals.MultiSignals.copy` method.""" assert self._multi_signals is not self._multi_signals.copy() assert self._multi_signals == self._multi_signals.copy() - def test_multi_signals_unpack_data(self): + def test_multi_signals_unpack_data(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.\ multi_signals_unpack_data` method. @@ -1029,7 +1031,7 @@ def test_multi_signals_unpack_data(self): np.testing.assert_array_equal(signals["b"].range, self._range_1 + 10) np.testing.assert_array_equal(signals["c"].range, self._range_1 + 20) - def test_fill_nan(self): + def test_fill_nan(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.fill_nan` method. @@ -1079,7 +1081,7 @@ def test_fill_nan(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_distance(self): + def test_domain_distance(self) -> None: """ Test :func:`colour.continuous.multi_signals.MultiSignals.\ domain_distance` method. @@ -1097,7 +1099,7 @@ def test_domain_distance(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_to_dataframe(self): + def test_to_dataframe(self) -> None: """ Test :meth:`colour.continuous.multi_signals.MultiSignals.to_dataframe` method. diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index d2399cbb6..c0ba40d3d 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.continuous.signal` module.""" +from __future__ import annotations + import pickle import textwrap @@ -30,7 +32,7 @@ class TestSignal: """Define :class:`colour.continuous.signal.Signal` class unit tests methods.""" - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._range = np.linspace(10, 100, 10) @@ -38,7 +40,7 @@ def setup_method(self): self._signal = Signal(self._range) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -55,7 +57,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Signal) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -79,7 +81,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Signal) - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether the :class:``colour.continuous.signal.Signal` class can be pickled. @@ -89,7 +91,7 @@ def test_pickling(self): data = pickle.loads(data) # noqa: S301 assert self._signal == data - def test_dtype(self): + def test_dtype(self) -> None: """Test :func:`colour.continuous.signal.Signal.dtype` property.""" assert self._signal.dtype == DTYPE_FLOAT_DEFAULT @@ -98,7 +100,7 @@ def test_dtype(self): signal.dtype = np.float32 assert signal.dtype == np.float32 - def test_domain(self): + def test_domain(self) -> None: """Test :func:`colour.continuous.signal.Signal.domain` property.""" signal = self._signal.copy() @@ -122,14 +124,14 @@ def test_domain(self): domain = np.linspace(0, 1, 10) domain[0] = -np.inf - def assert_warns(): + def assert_warns() -> None: """Help to test the runtime warning.""" signal.domain = domain pytest.warns(ColourRuntimeWarning, assert_warns) - def test_range(self): + def test_range(self) -> None: """Test :func:`colour.continuous.signal.Signal.range` property.""" signal = self._signal.copy() @@ -150,14 +152,14 @@ def test_range(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def assert_warns(): + def assert_warns() -> None: """Help to test the runtime warning.""" signal.range = self._range * np.inf pytest.warns(ColourRuntimeWarning, assert_warns) - def test_interpolator(self): + def test_interpolator(self) -> None: """Test :func:`colour.continuous.signal.Signal.interpolator` property.""" signal = self._signal.copy() @@ -184,7 +186,7 @@ def test_interpolator(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_interpolator_kwargs(self): + def test_interpolator_kwargs(self) -> None: """ Test :func:`colour.continuous.signal.Signal.interpolator_kwargs` property. @@ -222,12 +224,12 @@ def test_interpolator_kwargs(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_extrapolator(self): + def test_extrapolator(self) -> None: """Test :func:`colour.continuous.signal.Signal.extrapolator` property.""" assert isinstance(self._signal.extrapolator(), Extrapolator) - def test_extrapolator_kwargs(self): + def test_extrapolator_kwargs(self) -> None: """ Test :func:`colour.continuous.signal.Signal.extrapolator_kwargs` property. @@ -247,12 +249,12 @@ def test_extrapolator_kwargs(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_function(self): + def test_function(self) -> None: """Test :func:`colour.continuous.signal.Signal.function` property.""" attest(callable(self._signal.function)) - def test_raise_exception_function(self): + def test_raise_exception_function(self) -> None: """ Test :func:`colour.continuous.signal.Signal.function` property raised exception. @@ -260,7 +262,7 @@ def test_raise_exception_function(self): pytest.raises(ValueError, Signal().function, 0) - def test__init__(self): + def test__init__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__init__` method.""" signal = Signal(self._range) @@ -286,12 +288,12 @@ def test__init__(self): np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) - def test__hash__(self): + def test__hash__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__hash__` method.""" assert isinstance(hash(self._signal), int) - def test__str__(self): + def test__str__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__str__` method.""" assert ( @@ -315,7 +317,7 @@ def test__str__(self): assert isinstance(str(Signal()), str) - def test__repr__(self): + def test__repr__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__repr__` method.""" assert repr(self._signal) == ( @@ -341,7 +343,7 @@ def test__repr__(self): assert isinstance(repr(Signal()), str) - def test__getitem__(self): + def test__getitem__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__getitem__` method.""" assert self._signal[0] == 10.0 @@ -385,7 +387,7 @@ def test__getitem__(self): signal[np.array([-1000, 1000])], np.array([0.0, 1.0]) ) - def test__setitem__(self): + def test__setitem__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__setitem__` method.""" signal = self._signal.copy() @@ -477,14 +479,14 @@ def test__setitem__(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test__contains__(self): + def test__contains__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__contains__` method.""" assert 0 in self._signal assert 0.5 in self._signal assert 1000 not in self._signal - def test__iter__(self): + def test__iter__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__iter__` method.""" domain = np.arange(0, 10) @@ -492,12 +494,12 @@ def test__iter__(self): np.testing.assert_array_equal(domain_value, domain[i]) np.testing.assert_array_equal(range_value, self._range[i]) - def test__len__(self): + def test__len__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__len__` method.""" assert len(self._signal) == 10 - def test__eq__(self): + def test__eq__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__eq__` method.""" signal_1 = self._signal.copy() @@ -505,7 +507,7 @@ def test__eq__(self): assert signal_1 == signal_2 - def test__ne__(self): + def test__ne__(self) -> None: """Test :func:`colour.continuous.signal.Signal.__ne__` method.""" signal_1 = self._signal.copy() @@ -548,7 +550,7 @@ class NotExtrapolator(Extrapolator): } assert signal_1 == signal_2 - def test_arithmetical_operation(self): + def test_arithmetical_operation(self) -> None: """ Test :meth:`colour.continuous.signal.Signal.arithmetical_operation` method. @@ -660,7 +662,7 @@ def test_arithmetical_operation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_is_uniform(self): + def test_is_uniform(self) -> None: """Test :func:`colour.continuous.signal.Signal.is_uniform` method.""" assert self._signal.is_uniform() @@ -669,13 +671,13 @@ def test_is_uniform(self): signal[0.5] = 1.0 assert not signal.is_uniform() - def test_copy(self): + def test_copy(self) -> None: """Test :func:`colour.continuous.signal.Signal.copy` method.""" assert self._signal is not self._signal.copy() assert self._signal == self._signal.copy() - def test_signal_unpack_data(self): + def test_signal_unpack_data(self) -> None: """ Test :meth:`colour.continuous.signal.Signal.signal_unpack_data` method. @@ -711,7 +713,7 @@ def test_signal_unpack_data(self): np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) - def test_fill_nan(self): + def test_fill_nan(self) -> None: """Test :func:`colour.continuous.signal.Signal.fill_nan` method.""" signal = self._signal.copy() @@ -732,7 +734,7 @@ def test_fill_nan(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_distance(self): + def test_domain_distance(self) -> None: """Test :func:`colour.continuous.signal.Signal.domain_distance` method.""" np.testing.assert_allclose( @@ -747,7 +749,7 @@ def test_domain_distance(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_to_series(self): + def test_to_series(self) -> None: """Test :func:`colour.continuous.signal.Signal.to_series` method.""" if is_pandas_installed(): diff --git a/colour/contrast/__init__.py b/colour/contrast/__init__.py index 109d88684..bd3cedba8 100644 --- a/colour/contrast/__init__.py +++ b/colour/contrast/__init__.py @@ -20,7 +20,7 @@ from __future__ import annotations -from colour.hints import NDArrayFloat, Literal +from colour.hints import Any, NDArrayFloat, Literal from colour.utilities import ( CanonicalMapping, filter_kwargs, @@ -61,7 +61,7 @@ def contrast_sensitivity_function( - method: Literal["Barten 1999"] | str = "Barten 1999", **kwargs + method: Literal["Barten 1999"] | str = "Barten 1999", **kwargs: Any ) -> NDArrayFloat: """ Return the contrast sensitivity :math:`S` of the human eye according to diff --git a/colour/contrast/tests/test_barten1999.py b/colour/contrast/tests/test_barten1999.py index fdc976e31..cbb46fa82 100644 --- a/colour/contrast/tests/test_barten1999.py +++ b/colour/contrast/tests/test_barten1999.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.contrast.barten1999` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -38,7 +40,7 @@ class TestOpticalMTFBarten1999: definition unit tests methods. """ - def test_optical_MTF_Barten1999(self): + def test_optical_MTF_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.optical_MTF_Barten1999` definition. @@ -62,7 +64,7 @@ def test_optical_MTF_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_optical_MTF_Barten1999(self): + def test_n_dimensional_optical_MTF_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.optical_MTF_Barten1999` definition n-dimensional support. @@ -91,7 +93,7 @@ def test_n_dimensional_optical_MTF_Barten1999(self): ) @ignore_numpy_errors - def test_nan_optical_MTF_Barten1999(self): + def test_nan_optical_MTF_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.optical_MTF_Barten1999` definition nan support. @@ -108,7 +110,7 @@ class TestPupilDiameterBarten1999: definition unit tests methods. """ - def test_pupil_diameter_Barten1999(self): + def test_pupil_diameter_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.pupil_diameter_Barten1999` definition. @@ -132,7 +134,7 @@ def test_pupil_diameter_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_pupil_diameter_Barten1999(self): + def test_n_dimensional_pupil_diameter_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.pupil_diameter_Barten1999` definition n-dimensional support. @@ -162,7 +164,7 @@ def test_n_dimensional_pupil_diameter_Barten1999(self): ) @ignore_numpy_errors - def test_nan_pupil_diameter_Barten1999(self): + def test_nan_pupil_diameter_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.pupil_diameter_Barten1999` definition nan support. @@ -179,7 +181,7 @@ class TestSigmaBarten1999: tests methods. """ - def test_sigma_Barten1999(self): + def test_sigma_Barten1999(self) -> None: """Test :func:`colour.contrast.barten1999.sigma_Barten1999` definition.""" np.testing.assert_allclose( @@ -206,7 +208,7 @@ def test_sigma_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_sigma_Barten1999(self): + def test_n_dimensional_sigma_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.sigma_Barten1999` definition n-dimensional support. @@ -236,7 +238,7 @@ def test_n_dimensional_sigma_Barten1999(self): ) @ignore_numpy_errors - def test_nan_sigma_Barten1999(self): + def test_nan_sigma_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.sigma_Barten1999` definition nan support. @@ -253,7 +255,7 @@ class TestRetinalIlluminanceBarten1999: definition unit tests methods. """ - def test_retinal_illuminance_Barten1999(self): + def test_retinal_illuminance_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.retinal_illuminance_Barten1999` definition. @@ -277,7 +279,7 @@ def test_retinal_illuminance_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_retinal_illuminance_Barten1999(self): + def test_n_dimensional_retinal_illuminance_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.retinal_illuminance_Barten1999` definition n-dimensional support. @@ -306,7 +308,7 @@ def test_n_dimensional_retinal_illuminance_Barten1999(self): ) @ignore_numpy_errors - def test_nan_retinal_illuminance_Barten1999(self): + def test_nan_retinal_illuminance_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.retinal_illuminance_Barten1999` definition nan support. @@ -323,7 +325,7 @@ class TestMaximumAngularSizeBarten1999: definition unit tests methods. """ - def test_maximum_angular_size_Barten1999(self): + def test_maximum_angular_size_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ maximum_angular_size_Barten1999` definition. @@ -359,7 +361,7 @@ def test_maximum_angular_size_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_maximum_angular_size_Barten1999(self): + def test_n_dimensional_maximum_angular_size_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ maximum_angular_size_Barten1999` definition n-dimensional support. @@ -390,7 +392,7 @@ def test_n_dimensional_maximum_angular_size_Barten1999(self): ) @ignore_numpy_errors - def test_nan_maximum_angular_size_Barten1999(self): + def test_nan_maximum_angular_size_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ maximum_angular_size_Barten1999` definition nan support. @@ -407,7 +409,7 @@ class TestContrastSensitivityFunctionBarten1999: contrast_sensitivity_function_Barten1999` definition unit tests methods. """ - def test_contrast_sensitivity_function_Barten1999(self): + def test_contrast_sensitivity_function_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ contrast_sensitivity_function_Barten1999` definition. @@ -542,7 +544,7 @@ def test_contrast_sensitivity_function_Barten1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_contrast_sensitivity_function_Barten1999(self): + def test_n_dimensional_contrast_sensitivity_function_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ contrast_sensitivity_function_Barten1999` definition n-dimensional support. @@ -573,7 +575,7 @@ def test_n_dimensional_contrast_sensitivity_function_Barten1999(self): ) @ignore_numpy_errors - def test_nan_contrast_sensitivity_function_Barten1999(self): + def test_nan_contrast_sensitivity_function_Barten1999(self) -> None: """ Test :func:`colour.contrast.barten1999.\ contrast_sensitivity_function_Barten1999` definition nan support. diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index 75a19a1cb..5bfa7fd2f 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -13,10 +13,13 @@ doi:10.1364/JOSAA.4.001115 """ +from __future__ import annotations + from collections import namedtuple import numpy as np +from colour.hints import ArrayLike, Literal from colour.utilities.documentation import ( DocstringDict, is_documentation_building, @@ -76,7 +79,15 @@ class BrenemanExperimentResult( :math:`\\delta_uv_g^p`. """ - def __new__(cls, name, uv_t, uv_m, s_uv=None, d_uv_i=None, d_uv_g=None): + def __new__( + cls, + name: str, + uv_t: ArrayLike, + uv_m: ArrayLike, + s_uv: ArrayLike | None = None, + d_uv_i: ArrayLike | None = None, + d_uv_g: ArrayLike | None = None, + ) -> BrenemanExperimentResult: """ Return a new instance of the :class:`colour.corresponding.datasets.corresponding_chromaticities.\ @@ -119,7 +130,15 @@ class PrimariesChromaticityCoordinates( Chromaticity coordinates :math:`uv^p` of primary :math:`T`. """ - def __new__(cls, experiment, illuminants, Y, P_uvp=None, D_uvp=None, T_uvp=None): + def __new__( + cls, + experiment: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], + illuminants: ArrayLike, + Y: ArrayLike, + P_uvp: ArrayLike | None = None, + D_uvp: ArrayLike | None = None, + T_uvp: ArrayLike | None = None, + ) -> PrimariesChromaticityCoordinates: """ Return a new instance of the :class:`colour.corresponding.datasets.corresponding_chromaticities.\ diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index e4b9eb4a1..d8dc12141 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -223,7 +223,7 @@ class TestConvertExperimentResultsBreneman1987: methods. """ - def test_convert_experiment_results_Breneman1987(self): + def test_convert_experiment_results_Breneman1987(self) -> None: """ Test :func:`colour.corresponding.prediction.\ convert_experiment_results_Breneman1987` definition. @@ -275,7 +275,7 @@ class TestCorrespondingChromaticitiesPredictionFairchild1990: methods. """ - def test_corresponding_chromaticities_prediction_Fairchild1990(self): + def test_corresponding_chromaticities_prediction_Fairchild1990(self) -> None: """ Test :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_Fairchild1990` definition. @@ -299,7 +299,7 @@ class TestCorrespondingChromaticitiesPredictionCIE1994: corresponding_chromaticities_prediction_CIE1994` definition unit tests methods. """ - def test_corresponding_chromaticities_prediction_CIE1994(self): + def test_corresponding_chromaticities_prediction_CIE1994(self) -> None: """ Test :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_CIE1994` definition. @@ -324,7 +324,7 @@ class TestCorrespondingChromaticitiesPredictionCMCCAT2000: methods. """ - def test_corresponding_chromaticities_prediction_CMCCAT2000(self): + def test_corresponding_chromaticities_prediction_CMCCAT2000(self) -> None: """ Test :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_CMCCAT2000` definition. @@ -349,7 +349,7 @@ class TestCorrespondingChromaticitiesPredictionVonKries: methods. """ - def test_corresponding_chromaticities_prediction_VonKries(self): + def test_corresponding_chromaticities_prediction_VonKries(self) -> None: """ Test :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_VonKries` definition. @@ -374,7 +374,7 @@ class TestCorrespondingChromaticitiesPredictionZhai2018: methods. """ - def test_corresponding_chromaticities_prediction_Zhai2018(self): + def test_corresponding_chromaticities_prediction_Zhai2018(self) -> None: """ Test :func:`colour.corresponding.prediction.\ corresponding_chromaticities_prediction_Zhai2018` definition. diff --git a/colour/difference/tests/test__init__.py b/colour/difference/tests/test__init__.py index 76231a564..a4a248e23 100644 --- a/colour/difference/tests/test__init__.py +++ b/colour/difference/tests/test__init__.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -21,7 +23,7 @@ class TestDelta_E: """Define :func:`colour.difference.delta_E` definition unit tests methods.""" - def test_domain_range_scale_delta_E(self): + def test_domain_range_scale_delta_E(self) -> None: """ Test :func:`colour.difference.delta_E` definition domain and range scale support. diff --git a/colour/difference/tests/test_cam02_ucs.py b/colour/difference/tests/test_cam02_ucs.py index e43ff5119..7e99c2ca7 100644 --- a/colour/difference/tests/test_cam02_ucs.py +++ b/colour/difference/tests/test_cam02_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference.cam02_ucs` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -32,7 +34,7 @@ class TestDelta_E_Luo2006: tests methods. """ - def test_delta_E_Luo2006(self): + def test_delta_E_Luo2006(self) -> None: """Test :func:`colour.difference.cam02_ucs.delta_E_Luo2006` definition.""" np.testing.assert_allclose( @@ -84,7 +86,7 @@ def test_delta_E_Luo2006(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_Luo2006(self): + def test_n_dimensional_delta_E_Luo2006(self) -> None: """ Test :func:`colour.difference.cam02_ucs.delta_E_Luo2006` definition n-dimensional arrays support. @@ -115,7 +117,7 @@ def test_n_dimensional_delta_E_Luo2006(self): ) @ignore_numpy_errors - def test_nan_delta_E_Luo2006(self): + def test_nan_delta_E_Luo2006(self) -> None: """ Test :func:`colour.difference.cam02_ucs.delta_E_Luo2006` definition nan support. diff --git a/colour/difference/tests/test_cam16_ucs.py b/colour/difference/tests/test_cam16_ucs.py index fc428572e..c74483691 100644 --- a/colour/difference/tests/test_cam16_ucs.py +++ b/colour/difference/tests/test_cam16_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference.cam16_ucs` module.""" +from __future__ import annotations + from colour.difference.tests.test_cam02_ucs import TestDelta_E_Luo2006 __author__ = "Colour Developers" diff --git a/colour/difference/tests/test_delta_e.py b/colour/difference/tests/test_delta_e.py index e282b33d6..4cd99bf9d 100644 --- a/colour/difference/tests/test_delta_e.py +++ b/colour/difference/tests/test_delta_e.py @@ -9,6 +9,8 @@ 30(1), 21-30. doi:10.1002/col.20070 """ +from __future__ import annotations + from itertools import product import numpy as np @@ -57,7 +59,7 @@ class TestDelta_E_CIE1976: definition, thus unit tests are not entirely implemented. """ - def test_delta_E_CIE1976(self): + def test_delta_E_CIE1976(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_CIE1976` definition.""" Lab_1 = np.array([48.99183622, -0.10561667, 400.65619925]) @@ -71,13 +73,13 @@ def test_delta_E_CIE1976(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_CIE1976(self): + def test_n_dimensional_delta_E_CIE1976(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1976` definition n-dimensional arrays support. """ - def test_domain_range_scale_delta_E_CIE1976(self): + def test_domain_range_scale_delta_E_CIE1976(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1976` definition domain and range scale support. @@ -96,7 +98,7 @@ def test_domain_range_scale_delta_E_CIE1976(self): ) @ignore_numpy_errors - def test_nan_delta_E_CIE1976(self): + def test_nan_delta_E_CIE1976(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1976` definition nan support. @@ -109,7 +111,7 @@ class TestDelta_E_CIE1994: tests methods. """ - def test_delta_E_CIE1994(self): + def test_delta_E_CIE1994(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_CIE1994` definition.""" np.testing.assert_allclose( @@ -169,7 +171,7 @@ def test_delta_E_CIE1994(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_CIE1994(self): + def test_n_dimensional_delta_E_CIE1994(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1994` definition n-dimensional arrays support. @@ -197,7 +199,7 @@ def test_n_dimensional_delta_E_CIE1994(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_delta_E_CIE1994(self): + def test_domain_range_scale_delta_E_CIE1994(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1994` definition domain and range scale support. @@ -217,7 +219,7 @@ def test_domain_range_scale_delta_E_CIE1994(self): ) @ignore_numpy_errors - def test_nan_delta_E_CIE1994(self): + def test_nan_delta_E_CIE1994(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE1994` definition nan support. @@ -234,7 +236,7 @@ class TestIntermediateAttributes_CIE2000: definition unit tests methods. """ - def test_intermediate_attributes_CIE2000(self): + def test_intermediate_attributes_CIE2000(self) -> None: """ Test :func:`colour.difference.delta_e.intermediate_attributes_CIE2000` definition. @@ -266,7 +268,7 @@ class TestDelta_E_CIE2000: tests methods. """ - def test_delta_E_CIE2000(self): + def test_delta_E_CIE2000(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_CIE2000` definition.""" np.testing.assert_allclose( @@ -326,7 +328,7 @@ def test_delta_E_CIE2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_CIE2000(self): + def test_n_dimensional_delta_E_CIE2000(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE2000` definition n-dimensional arrays support. @@ -354,7 +356,7 @@ def test_n_dimensional_delta_E_CIE2000(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_delta_E_CIE2000(self): + def test_domain_range_scale_delta_E_CIE2000(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE2000` definition domain and range scale support. @@ -374,7 +376,7 @@ def test_domain_range_scale_delta_E_CIE2000(self): ) @ignore_numpy_errors - def test_nan_delta_E_CIE2000(self): + def test_nan_delta_E_CIE2000(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE2000` definition nan support. @@ -384,7 +386,7 @@ def test_nan_delta_E_CIE2000(self): cases = np.array(list(set(product(cases, repeat=3)))) delta_E_CIE2000(cases, cases) - def test_delta_E_CIE2000_Sharma2004(self): + def test_delta_E_CIE2000_Sharma2004(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CIE2000` definition using Sharma (2004) dataset. @@ -558,7 +560,7 @@ class TestDelta_E_CMC: methods. """ - def test_delta_E_CMC(self): + def test_delta_E_CMC(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_CMC` definition.""" np.testing.assert_allclose( @@ -618,7 +620,7 @@ def test_delta_E_CMC(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_CMC(self): + def test_n_dimensional_delta_E_CMC(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CMC` definition n-dimensional arrays support. @@ -642,7 +644,7 @@ def test_n_dimensional_delta_E_CMC(self): delta_E_CMC(Lab_1, Lab_2), delta_E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_delta_E_CMC(self): + def test_domain_range_scale_delta_E_CMC(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CMC` definition domain and range scale support. @@ -662,7 +664,7 @@ def test_domain_range_scale_delta_E_CMC(self): ) @ignore_numpy_errors - def test_nan_delta_E_CMC(self): + def test_nan_delta_E_CMC(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_CMC` definition nan support. @@ -679,7 +681,7 @@ class TestDelta_E_ITP: methods. """ - def test_delta_E_ITP(self): + def test_delta_E_ITP(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_ITP` definition.""" np.testing.assert_allclose( @@ -772,7 +774,7 @@ def test_delta_E_ITP(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_ITP(self): + def test_n_dimensional_delta_E_ITP(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_ITP` definition n-dimensional arrays support. @@ -796,7 +798,7 @@ def test_n_dimensional_delta_E_ITP(self): delta_E_ITP(ICtCp_1, ICtCp_2), delta_E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_delta_E_ITP(self): + def test_domain_range_scale_delta_E_ITP(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_ITP` definition domain and range scale support. @@ -816,7 +818,7 @@ def test_domain_range_scale_delta_E_ITP(self): ) @ignore_numpy_errors - def test_nan_delta_E_ITP(self): + def test_nan_delta_E_ITP(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_ITP` definition nan support. @@ -833,7 +835,7 @@ class TestDelta_E_HyAB: tests methods. """ - def test_delta_E_HyAB(self): + def test_delta_E_HyAB(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_HyAB` definition.""" np.testing.assert_allclose( @@ -863,7 +865,7 @@ def test_delta_E_HyAB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_HyAB(self): + def test_n_dimensional_delta_E_HyAB(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyAB` definition n-dimensional arrays support. @@ -891,7 +893,7 @@ def test_n_dimensional_delta_E_HyAB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_delta_E_HyAB(self): + def test_domain_range_scale_delta_E_HyAB(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyAB` definition domain and range scale support. @@ -911,7 +913,7 @@ def test_domain_range_scale_delta_E_HyAB(self): ) @ignore_numpy_errors - def test_nan_delta_E_HyAB(self): + def test_nan_delta_E_HyAB(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyAB` definition nan support. @@ -928,7 +930,7 @@ class TestDelta_E_HyCH: tests methods. """ - def test_delta_E_HyCH(self): + def test_delta_E_HyCH(self) -> None: """Test :func:`colour.difference.delta_e.delta_E_HyCH` definition.""" np.testing.assert_allclose( @@ -958,7 +960,7 @@ def test_delta_E_HyCH(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_HyCH(self): + def test_n_dimensional_delta_E_HyCH(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyCH` definition n-dimensional arrays support. @@ -986,7 +988,7 @@ def test_n_dimensional_delta_E_HyCH(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_delta_E_HyCH(self): + def test_domain_range_scale_delta_E_HyCH(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyCH` definition domain and range scale support. @@ -1006,7 +1008,7 @@ def test_domain_range_scale_delta_E_HyCH(self): ) @ignore_numpy_errors - def test_nan_delta_E_HyCH(self): + def test_nan_delta_E_HyCH(self) -> None: """ Test :func:`colour.difference.delta_e.delta_E_HyCH` definition nan support. diff --git a/colour/difference/tests/test_din99.py b/colour/difference/tests/test_din99.py index b71d680fd..b5ee2ddb5 100644 --- a/colour/difference/tests/test_din99.py +++ b/colour/difference/tests/test_din99.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference.din99` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -26,7 +28,7 @@ class TestDelta_E_DIN99: tests methods. """ - def test_delta_E_DIN99(self): + def test_delta_E_DIN99(self) -> None: """Test :func:`colour.difference.din99.delta_E_DIN99` definition.""" np.testing.assert_allclose( @@ -86,7 +88,7 @@ def test_delta_E_DIN99(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_delta_E_DIN99(self): + def test_n_dimensional_delta_E_DIN99(self) -> None: """ Test :func:`colour.difference.din99.delta_E_DIN99` definition n-dimensional arrays support. @@ -110,7 +112,7 @@ def test_n_dimensional_delta_E_DIN99(self): delta_E_DIN99(Lab_1, Lab_2), delta_E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_delta_E_DIN99(self): + def test_domain_range_scale_delta_E_DIN99(self) -> None: """ Test :func:`colour.difference.din99.delta_E_DIN99` definition domain and range scale support. @@ -130,7 +132,7 @@ def test_domain_range_scale_delta_E_DIN99(self): ) @ignore_numpy_errors - def test_nan_delta_E_DIN99(self): + def test_nan_delta_E_DIN99(self) -> None: """ Test :func:`colour.difference.din99.delta_E_DIN99` definition nan support. diff --git a/colour/difference/tests/test_huang2015.py b/colour/difference/tests/test_huang2015.py index cfb6fdf15..34feed9ad 100644 --- a/colour/difference/tests/test_huang2015.py +++ b/colour/difference/tests/test_huang2015.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference.huang2015` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -23,7 +25,7 @@ class TestPowerFunctionHuang2015: definition unit tests methods. """ - def test_power_function_Huang2015(self): + def test_power_function_Huang2015(self) -> None: """ Test :func:`colour.difference.huang2015.power_function_Huang2015` definition. diff --git a/colour/difference/tests/test_stress.py b/colour/difference/tests/test_stress.py index dd9ad00b7..657616819 100644 --- a/colour/difference/tests/test_stress.py +++ b/colour/difference/tests/test_stress.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.difference.stress` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -23,7 +25,7 @@ class TestIndexStress: unit tests methods. """ - def test_index_stress(self): + def test_index_stress(self) -> None: """ Test :func:`colour.difference.stress.index_stress_Garcia2007` definition. diff --git a/colour/examples/io/examples_ctl.py b/colour/examples/io/examples_ctl.py index cdbddae3f..5f2e7d6e4 100644 --- a/colour/examples/io/examples_ctl.py +++ b/colour/examples/io/examples_ctl.py @@ -193,8 +193,9 @@ 'Running the "aces-dev" "Y_2_linCV" "CTL" function to transform an array.' ) - def format_imports(imports): + def format_imports(imports: list[str]) -> list[str]: """Format given imports.""" + return [f'import "{i}";' for i in imports] ctl_Y_2_linCV_float = colour.io.template_ctl_transform_float( diff --git a/colour/examples/plotting/examples_section_plots.py b/colour/examples/plotting/examples_section_plots.py index 8b9909bf8..d3bdfb67a 100644 --- a/colour/examples/plotting/examples_section_plots.py +++ b/colour/examples/plotting/examples_section_plots.py @@ -120,7 +120,7 @@ plot_RGB_colourspace_section( colourspace="sRGB", model="DIN99", - origin=i, + origin=i, # pyright: ignore section_colours=RGB, section_opacity=0.15, contour_colours=RGB, diff --git a/colour/geometry/section.py b/colour/geometry/section.py index 33af5b916..0663d4327 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -13,7 +13,7 @@ from colour.algebra import linear_conversion from colour.constants import DTYPE_FLOAT_DEFAULT -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat, cast +from colour.hints import Any, ArrayLike, List, Literal, NDArrayFloat, cast from colour.utilities import ( as_float_array, as_float_scalar, @@ -85,7 +85,7 @@ def edges_to_chord(edges: ArrayLike, index: int = 0) -> NDArrayFloat: [-0. , -0.5, 0. ]]) """ - edge_list = as_float_array(edges).tolist() + edge_list = cast(List[List[float]], as_float_array(edges).tolist()) edges_ordered = [edge_list.pop(index)] segment = np.array(edges_ordered[0][1]) diff --git a/colour/geometry/tests/test_ellipse.py b/colour/geometry/tests/test_ellipse.py index 9a2903fd9..1aa5b7686 100644 --- a/colour/geometry/tests/test_ellipse.py +++ b/colour/geometry/tests/test_ellipse.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.geometry.ellipse` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -31,7 +33,7 @@ class TestEllipseCoefficientsCanonicalForm: definition unit tests methods. """ - def test_ellipse_coefficients_canonical_form(self): + def test_ellipse_coefficients_canonical_form(self) -> None: """ Test :func:`colour.geometry.ellipse.\ ellipse_coefficients_canonical_form` definition. @@ -60,7 +62,7 @@ class TestEllipseCoefficientsGeneralForm: definition unit tests methods. """ - def test_ellipse_coefficients_general_form(self): + def test_ellipse_coefficients_general_form(self) -> None: """ Test :func:`colour.geometry.ellipse.ellipse_coefficients_general_form` definition. @@ -85,7 +87,7 @@ class TestPointAtAngleOnEllipse: definition unit tests methods. """ - def test_point_at_angle_on_ellipse(self): + def test_point_at_angle_on_ellipse(self) -> None: """ Test :func:`colour.geometry.ellipse.point_at_angle_on_ellipse` definition. @@ -127,7 +129,7 @@ class TestEllipseFittingHalir1998: definition unit tests methods. """ - def test_ellipse_fitting_Halir1998(self): + def test_ellipse_fitting_Halir1998(self) -> None: """ Test :func:`colour.geometry.ellipse.ellipse_fitting_Halir1998` definition. diff --git a/colour/geometry/tests/test_intersection.py b/colour/geometry/tests/test_intersection.py index 0a809f195..18a0ede76 100644 --- a/colour/geometry/tests/test_intersection.py +++ b/colour/geometry/tests/test_intersection.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.geometry.intersection` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -27,7 +29,7 @@ class TestExtendLineSegment: tests methods. """ - def test_extend_line_segment(self): + def test_extend_line_segment(self) -> None: """Test :func:`colour.geometry.intersection.extend_line_segment` definition.""" np.testing.assert_allclose( @@ -66,7 +68,7 @@ class TestIntersectLineSegments: definition unit tests methods. """ - def test_intersect_line_segments(self): + def test_intersect_line_segments(self) -> None: """ Test :func:`colour.geometry.intersection.intersect_line_segments` definition. diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index 1af5b7fe8..749803670 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.geometry.primitives` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -28,7 +30,7 @@ class TestPrimitiveGrid: definition unit tests methods. """ - def test_primitive_grid(self): + def test_primitive_grid(self) -> None: """ Test :func:`colour.geometry.primitives.primitive_grid` definition. @@ -187,7 +189,7 @@ class TestPrimitiveCube: definition unit tests methods. """ - def test_primitive_cube(self): + def test_primitive_cube(self) -> None: """ Test :func:`colour.geometry.primitives.primitive_cube` definition. @@ -781,7 +783,7 @@ def test_primitive_cube(self): for plane in MAPPING_PLANE_TO_AXIS: np.testing.assert_allclose( - primitive_cube(planes=[plane])[0]["position"], - primitive_cube(planes=[MAPPING_PLANE_TO_AXIS[plane]])[0]["position"], + primitive_cube(planes=[plane])[0]["position"], # pyright: ignore + primitive_cube(planes=[MAPPING_PLANE_TO_AXIS[plane]])[0]["position"], # pyright: ignore atol=TOLERANCE_ABSOLUTE_TESTS, ) diff --git a/colour/geometry/tests/test_section.py b/colour/geometry/tests/test_section.py index ae7f66176..67a30fbe1 100644 --- a/colour/geometry/tests/test_section.py +++ b/colour/geometry/tests/test_section.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.geometry.section` module.""" +from __future__ import annotations + import numpy as np import pytest @@ -33,7 +35,7 @@ class TestEdgesToChord: tests methods. """ - def test_edges_to_chord(self): + def test_edges_to_chord(self) -> None: """Test :func:`colour.geometry.section.edges_to_chord` definition.""" edges = np.array( @@ -106,7 +108,7 @@ class TestCloseChord: methods. """ - def test_close_chord(self): + def test_close_chord(self) -> None: """Test :func:`colour.geometry.section.close_chord` definition.""" np.testing.assert_allclose( @@ -122,7 +124,7 @@ class TestUniqueVertices: tests methods. """ - def test_unique_vertices(self): + def test_unique_vertices(self) -> None: """Test :func:`colour.geometry.section.unique_vertices` definition.""" np.testing.assert_allclose( @@ -149,7 +151,7 @@ class TestHullSection: methods. """ - def test_hull_section(self): + def test_hull_section(self) -> None: """Test :func:`colour.geometry.section.hull_section` definition.""" if not is_trimesh_installed(): # pragma: no cover diff --git a/colour/geometry/tests/test_vertices.py b/colour/geometry/tests/test_vertices.py index 1289c935f..23321020e 100644 --- a/colour/geometry/tests/test_vertices.py +++ b/colour/geometry/tests/test_vertices.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.geometry.vertices` module.""" +from __future__ import annotations + import numpy as np import pytest @@ -33,7 +35,7 @@ class TestPrimitiveVerticesQuadMpl: definition unit tests methods. """ - def test_primitive_vertices_quad_mpl(self): + def test_primitive_vertices_quad_mpl(self) -> None: """ Test :func:`colour.geometry.vertices.primitive_vertices_quad_mpl` definition. @@ -111,7 +113,7 @@ class TestPrimitiveVerticesGridMpl: definition unit tests methods. """ - def test_primitive_vertices_grid_mpl(self): + def test_primitive_vertices_grid_mpl(self) -> None: """ Test :func:`colour.geometry.vertices.primitive_vertices_grid_mpl` definition. @@ -200,7 +202,7 @@ class TestPrimitiveVerticesCubeMpl: definition unit tests methods. """ - def test_primitive_vertices_cube_mpl(self): + def test_primitive_vertices_cube_mpl(self) -> None: """ Test :func:`colour.geometry.vertices.primitive_vertices_cube_mpl` definition. @@ -599,7 +601,7 @@ class TestPrimitiveVerticesSphere: definition unit tests methods. """ - def test_primitive_vertices_sphere(self): + def test_primitive_vertices_sphere(self) -> None: """ Test :func:`colour.geometry.vertices.primitive_vertices_sphere` definition. diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 389a773a6..995d67853 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -18,7 +18,7 @@ from colour.algebra import spherical_to_cartesian from colour.geometry import MAPPING_PLANE_TO_AXIS -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat +from colour.hints import Any, ArrayLike, Literal, NDArrayFloat, Sequence from colour.utilities import ( CanonicalMapping, as_float_array, @@ -205,19 +205,21 @@ def primitive_vertices_cube_mpl( depth_segments: int = 1, origin: ArrayLike = np.array([0, 0, 0]), planes: ( - Literal[ - "-x", - "+x", - "-y", - "+y", - "-z", - "+z", - "xy", - "xz", - "yz", - "yx", - "zx", - "zy", + Sequence[ + Literal[ + "-x", + "+x", + "-y", + "+y", + "-z", + "+z", + "xy", + "xz", + "yz", + "yx", + "zx", + "zy", + ] ] | None ) = None, diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index 3be520dc3..b791f14cb 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -243,7 +243,9 @@ class Conversion_Specification( Callable converting from the ``source`` node to the ``target`` node. """ - def __new__(cls, source: str, target: str, conversion_function: Callable): + def __new__( + cls, source: str, target: str, conversion_function: Callable + ) -> Conversion_Specification: """ Return a new instance of the :class:`colour.graph.conversion.Conversion_Specification` class. @@ -316,7 +318,7 @@ def JMh_CIECAM02_to_CIECAM02(JMh: ArrayLike) -> CAM_Specification_CIECAM02: return CAM_Specification_CIECAM02(J=J, M=M, h=h) -def CAM16_to_JMh_CAM16(specification) -> NDArrayFloat: +def CAM16_to_JMh_CAM16(specification: CAM_Specification_CAM16) -> NDArrayFloat: """ Convert from *CAM16* specification to *CAM16* :math:`JMh` correlates. @@ -339,7 +341,7 @@ def CAM16_to_JMh_CAM16(specification) -> NDArrayFloat: array([ 4.1731207...e+01, 1.0743677...e-01, 2.1706796...e+02]) """ - return tstack([specification.J, specification.M, specification.h]) + return tstack([specification.J, specification.M, specification.h]) # pyright: ignore def JMh_CAM16_to_CAM16(JMh: ArrayLike) -> CAM_Specification_CAM16: @@ -370,7 +372,7 @@ def JMh_CAM16_to_CAM16(JMh: ArrayLike) -> CAM_Specification_CAM16: return CAM_Specification_CAM16(J=J, M=M, h=h) -def CIECAM16_to_JMh_CIECAM16(specification) -> NDArrayFloat: +def CIECAM16_to_JMh_CIECAM16(specification: CAM_Specification_CIECAM16) -> NDArrayFloat: """ Convert from *CIECAM16* specification to *CIECAM16* :math:`JMh` correlates. @@ -393,7 +395,7 @@ def CIECAM16_to_JMh_CIECAM16(specification) -> NDArrayFloat: array([ 4.1731207...e+01, 1.0743677...e-01, 2.1706796...e+02]) """ - return tstack([specification.J, specification.M, specification.h]) + return tstack([specification.J, specification.M, specification.h]) # pyright: ignore def JMh_CIECAM16_to_CIECAM16(JMh: ArrayLike) -> CAM_Specification_CIECAM16: @@ -424,7 +426,9 @@ def JMh_CIECAM16_to_CIECAM16(JMh: ArrayLike) -> CAM_Specification_CIECAM16: return CAM_Specification_CIECAM16(J=J, M=M, h=h) -def Hellwig2022_to_JMh_Hellwig2022(specification) -> NDArrayFloat: +def Hellwig2022_to_JMh_Hellwig2022( + specification: CAM_Specification_Hellwig2022, +) -> NDArrayFloat: """ Convert from *Hellwig and Fairchild (2022)* specification to *Hellwig and Fairchild (2022)* :math:`JMh` correlates. @@ -448,7 +452,7 @@ def Hellwig2022_to_JMh_Hellwig2022(specification) -> NDArrayFloat: array([ 4.1731207...e+01, 2.9382869...e-02, 2.1706796...e+02]) """ - return tstack([specification.J, specification.M, specification.h]) + return tstack([specification.J, specification.M, specification.h]) # pyright: ignore def JMh_Hellwig2022_to_Hellwig2022( @@ -974,7 +978,7 @@ def mired_to_CCT_D_uv(mired: ArrayLike) -> NDArrayFloat: # Programmatically defining the colourspace models polar conversions. -def _format_node_name(name): +def _format_node_name(name: str) -> str: """Format given name by applying a series of substitutions.""" for pattern, substitution in [ @@ -1128,7 +1132,7 @@ def describe_conversion_path( padding: int = 3, print_callable: Callable = print, **kwargs: Any, -): +) -> None: """ Describe the conversion path from source colour representation to target colour representation using the automatic colour conversion graph. diff --git a/colour/graph/tests/test_conversion.py b/colour/graph/tests/test_conversion.py index 50529916a..7334a4700 100644 --- a/colour/graph/tests/test_conversion.py +++ b/colour/graph/tests/test_conversion.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.graph.conversion` module.""" +from __future__ import annotations + import numpy as np import pytest @@ -28,7 +30,7 @@ class TestDescribeConversionPath: unit tests methods. """ - def test_describe_conversion_path(self): + def test_describe_conversion_path(self) -> None: """ Test :func:`colour.graph.conversion.describe_conversion_path` definition. @@ -55,7 +57,7 @@ class TestConvert: methods. """ - def test_convert(self): + def test_convert(self) -> None: """Test :func:`colour.graph.conversion.convert` definition.""" RGB_a = convert( @@ -128,7 +130,7 @@ def test_convert(self): model, ) - def test_convert_direct_keyword_argument_passing(self): + def test_convert_direct_keyword_argument_passing(self) -> None: """ Test :func:`colour.graph.conversion.convert` definition behaviour when direct keyword arguments are passed. diff --git a/colour/hints/__init__.py b/colour/hints/__init__.py index caa7830b4..1e271d07d 100644 --- a/colour/hints/__init__.py +++ b/colour/hints/__init__.py @@ -21,6 +21,7 @@ List, Literal, NewType, + NoReturn, Protocol, Set, SupportsIndex, @@ -59,6 +60,7 @@ "List", "Literal", "Mapping", + "NoReturn", "NewType", "Protocol", "Sequence", @@ -148,14 +150,14 @@ def x(self) -> NDArray: # noqa: D102 ... @x.setter - def x(self, value: ArrayLike): ... + def x(self, value: ArrayLike) -> None: ... @property def y(self) -> NDArray: # noqa: D102 ... @y.setter - def y(self, value: ArrayLike): ... + def y(self, value: ArrayLike) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... # pragma: no cover @@ -169,7 +171,7 @@ def interpolator(self) -> ProtocolInterpolator: # noqa: D102 ... @interpolator.setter - def interpolator(self, value: ProtocolInterpolator): ... + def interpolator(self, value: ProtocolInterpolator) -> None: ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... # pragma: no cover diff --git a/colour/io/__init__.py b/colour/io/__init__.py index 326ffa208..42a8a4713 100644 --- a/colour/io/__init__.py +++ b/colour/io/__init__.py @@ -115,7 +115,7 @@ class io(ModuleAPI): """Define a class acting like the *io* module.""" - def __getattr__(self, attribute) -> Any: + def __getattr__(self, attribute: str) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index 410789360..f1776830c 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -15,6 +15,7 @@ import re from collections import defaultdict +from collections.abc import ValuesView from dataclasses import dataclass, field from pathlib import Path @@ -31,9 +32,9 @@ ) from colour.constants import CONSTANT_LIGHT_SPEED from colour.hints import ( + Any, Callable, Dict, - List, Literal, NDArrayFloat, Sequence, @@ -312,7 +313,7 @@ class Specification_Fichet2021: is_emissive: bool = field(default_factory=lambda: False) is_polarised: bool = field(default_factory=lambda: False) is_bispectral: bool = field(default_factory=lambda: False) - attributes: List | None = field(default_factory=lambda: None) + attributes: Tuple = field(default_factory=lambda: ()) @staticmethod @required("OpenImageIO") @@ -413,7 +414,7 @@ def from_spectral_image(path: str | Path) -> Specification_Fichet2021: is_emissive, is_polarised, is_bispectral, - attributes, + tuple(attributes), ) @@ -507,9 +508,10 @@ def read_spectral_image_Fichet2021( def sds_and_msds_to_components_Fichet2021( sds: Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution - | MultiSpectralDistributions, + | MultiSpectralDistributions + | ValuesView, specification: Specification_Fichet2021 = Specification_Fichet2021(), - **kwargs, + **kwargs: Any, ) -> ComponentsFichet2021: """ Convert given spectral and multi-spectral distributions to @@ -716,13 +718,14 @@ def write_spectral_image_Fichet2021( components: Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions - | ComponentsFichet2021, + | ComponentsFichet2021 + | ValuesView, path: str | Path, bit_depth: Literal["float16", "float32"] = "float32", specification: Specification_Fichet2021 = Specification_Fichet2021(), components_to_RGB_callable: Callable = components_to_sRGB_Fichet2021, - **kwargs, -): + **kwargs: Any, +) -> bool: """ Write given *Fichet et al. (2021)* components to given path using *OpenImageIO*. @@ -781,7 +784,8 @@ def write_spectral_image_Fichet2021( path = str(path) if isinstance( - components, (Sequence, SpectralDistribution, MultiSpectralDistributions) + components, + (Sequence, SpectralDistribution, MultiSpectralDistributions, ValuesView), ): components = sds_and_msds_to_components_Fichet2021( components, specification, **kwargs diff --git a/colour/io/image.py b/colour/io/image.py index 9003450c0..b8997bc22 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -147,7 +147,7 @@ class ImageSpec: def add_attributes_to_image_specification_OpenImageIO( image_specification: ImageSpec, attributes: Sequence -): +) -> ImageSpec: """ Add given attributes to given *OpenImageIO* image specification. @@ -336,7 +336,7 @@ def read_image_OpenImageIO( ] = "float32", additional_data: bool = False, **kwargs: Any, -) -> NDArrayReal | Tuple[NDArrayReal, list]: +) -> NDArrayReal | Tuple[NDArrayReal, Tuple[Image_Specification_Attribute]]: """ Read the image data at given path using *OpenImageIO*. @@ -414,7 +414,7 @@ def read_image_OpenImageIO( ) ) - return image, extra_attributes + return image, tuple(extra_attributes) else: return image diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index ddaa76e6a..8b33034ed 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -21,7 +21,7 @@ import numpy as np -from colour.hints import ArrayLike, List, NDArrayFloat +from colour.hints import ArrayLike, List, NDArrayFloat, NDArrayInt from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUTSequence from colour.utilities import ( as_float_array, @@ -134,7 +134,7 @@ def _parse_domain_section(lines: List[str]) -> NDArrayFloat: return np.asarray(pre_LUT_padded) - def _parse_table_section(lines): + def _parse_table_section(lines: list[str]) -> tuple[NDArrayInt, NDArrayFloat]: """Parse the table at given lines.""" size = as_int_array(lines[0].split()) @@ -242,7 +242,7 @@ def _parse_table_section(lines): def write_LUT_Cinespace( - LUT: LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7 + LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7 ) -> bool: """ Write given *LUT* to given *Cinespace* *.csp* *LUT* file. diff --git a/colour/io/luts/iridas_cube.py b/colour/io/luts/iridas_cube.py index eec9f4c8c..1a2910bd3 100644 --- a/colour/io/luts/iridas_cube.py +++ b/colour/io/luts/iridas_cube.py @@ -184,7 +184,7 @@ def read_LUT_IridasCube(path: str | Path) -> LUT3x1D | LUT3D: def write_LUT_IridasCube( - LUT: LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7 + LUT: LUT1D | LUT3x1D | LUT3D | LUTSequence, path: str | Path, decimals: int = 7 ) -> bool: """ Write given *LUT* to given *Iridas* *.cube* *LUT* file. @@ -192,8 +192,8 @@ def write_LUT_IridasCube( Parameters ---------- LUT - :class:`LUT3x1D`, :class:`LUT3D` or :class:`LUTSequence` class instance - to write at given path. + :class:`LUT1D`, :class:`LUT3x1D`, :class:`LUT3D` or :class:`LUTSequence` + class instance to write at given path. path *LUT* path. decimals diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index c298db55c..ef0612a6f 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -182,7 +182,7 @@ def table(self) -> NDArrayFloat: return self._table @table.setter - def table(self, value: ArrayLike): + def table(self, value: ArrayLike) -> None: """Setter for the **self.table** property.""" self._table = self._validate_table(value) @@ -206,7 +206,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -235,7 +235,7 @@ def domain(self) -> NDArrayFloat: return self._domain @domain.setter - def domain(self, value: ArrayLike): + def domain(self, value: ArrayLike) -> None: """Setter for the **self.domain** property.""" self._domain = self._validate_domain(value) @@ -285,7 +285,7 @@ def comments(self) -> list: return self._comments @comments.setter - def comments(self, value: Sequence): + def comments(self, value: Sequence) -> None: """Setter for the **self.comments** property.""" attest( @@ -2120,7 +2120,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: def LUT_to_LUT( - LUT, + LUT: AbstractLUT, cls: Type[AbstractLUT], force_conversion: bool = False, **kwargs: Any, @@ -2130,6 +2130,8 @@ def LUT_to_LUT( Parameters ---------- + LUT + *LUT* to convert. cls *LUT* class instance. force_conversion diff --git a/colour/io/luts/operator.py b/colour/io/luts/operator.py index 2d9f8ed45..3db8f4884 100644 --- a/colour/io/luts/operator.py +++ b/colour/io/luts/operator.py @@ -97,7 +97,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -126,7 +126,7 @@ def comments(self) -> List[str]: return self._comments @comments.setter - def comments(self, value: Sequence[str]): + def comments(self, value: Sequence[str]) -> None: """Setter for the **self.comments** property.""" attest( @@ -271,7 +271,7 @@ def matrix(self) -> NDArrayFloat: return self._matrix @matrix.setter - def matrix(self, value: ArrayLike): + def matrix(self, value: ArrayLike) -> None: """Setter for the **self.matrix** property.""" value = as_float_array(value) @@ -309,7 +309,7 @@ def offset(self) -> NDArrayFloat: return self._offset @offset.setter - def offset(self, value: ArrayLike): + def offset(self, value: ArrayLike) -> None: """Setter for the **self.offset** property.""" value = as_float_array(value) diff --git a/colour/io/luts/sequence.py b/colour/io/luts/sequence.py index 49176981f..9e6a576db 100644 --- a/colour/io/luts/sequence.py +++ b/colour/io/luts/sequence.py @@ -132,7 +132,7 @@ def sequence(self) -> List[ProtocolLUTSequenceItem]: return self._sequence @sequence.setter - def sequence(self, value: Sequence[ProtocolLUTSequenceItem]): + def sequence(self, value: Sequence[ProtocolLUTSequenceItem]) -> None: """Setter for the **self.sequence** property.""" for item in value: @@ -161,7 +161,7 @@ def __getitem__(self, index: int | slice) -> Any: return self._sequence[index] - def __setitem__(self, index: int | slice, value: Any): + def __setitem__(self, index: int | slice, value: Any) -> None: """ Set the *LUT* sequence at given index (or slice) with given value. @@ -182,7 +182,7 @@ def __setitem__(self, index: int | slice, value: Any): self._sequence[index] = value - def __delitem__(self, index: int | slice): + def __delitem__(self, index: int | slice) -> None: """ Delete the *LUT* sequence item(s) at given index (or slice). @@ -261,7 +261,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(\n{operations}\n)" - def __eq__(self, other) -> bool: + def __eq__(self, other: Any) -> bool: """ Return whether the *LUT* sequence is equal to given other object. @@ -284,7 +284,7 @@ def __eq__(self, other) -> bool: return all(self[i] == other[i] for i in range(len(self))) - def __ne__(self, other) -> bool: + def __ne__(self, other: Any) -> bool: """ Return whether the *LUT* sequence is not equal to given other object. @@ -301,7 +301,7 @@ def __ne__(self, other) -> bool: return not (self == other) - def insert(self, index: int, value: ProtocolLUTSequenceItem): + def insert(self, index: int, value: ProtocolLUTSequenceItem) -> None: """ Insert given *LUT* at given index into the *LUT* sequence. diff --git a/colour/io/luts/tests/test__init__.py b/colour/io/luts/tests/test__init__.py index 0435fc949..ad85bfd91 100644 --- a/colour/io/luts/tests/test__init__.py +++ b/colour/io/luts/tests/test__init__.py @@ -10,7 +10,8 @@ import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.io import LUTSequence, read_LUT, write_LUT +from colour.hints import cast +from colour.io import LUT1D, LUTSequence, read_LUT, write_LUT __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -34,10 +35,12 @@ class TestReadLUT: methods. """ - def test_read_LUT(self): + def test_read_LUT(self) -> None: """Test :func:`colour.io.luts.__init__.read_LUT` definition.""" - LUT_1 = read_LUT(os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d")) + LUT_1 = cast( + LUT1D, read_LUT(os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d")) + ) np.testing.assert_allclose( LUT_1.table, @@ -72,7 +75,10 @@ def test_read_LUT(self): '"colour.models.eotf_sRGB".', ] - LUT_2 = read_LUT(os.path.join(ROOT_LUTS, "resolve_cube", "LogC_Video.cube")) + LUT_2 = cast( + LUTSequence, + read_LUT(os.path.join(ROOT_LUTS, "resolve_cube", "LogC_Video.cube")), + ) np.testing.assert_allclose( LUT_2[0].table, np.array( @@ -106,7 +112,7 @@ def test_read_LUT(self): method="Sony SPI1D", ) - def test_raise_exception_read_LUT(self): + def test_raise_exception_read_LUT(self) -> None: """ Test :func:`colour.io.luts.__init__.read_LUT` definition raised exception. @@ -125,17 +131,17 @@ class TestWriteLUT: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT(self): + def test_write_LUT(self) -> None: """Test :func:`colour.io.luts.__init__.write_LUT` definition.""" LUT_1_r = read_LUT(os.path.join(ROOT_LUTS, "sony_spi1d", "eotf_sRGB_1D.spi1d")) diff --git a/colour/io/luts/tests/test_cinespace_csp.py b/colour/io/luts/tests/test_cinespace_csp.py index 692011700..e543a60ee 100644 --- a/colour/io/luts/tests/test_cinespace_csp.py +++ b/colour/io/luts/tests/test_cinespace_csp.py @@ -10,7 +10,15 @@ import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.io import LUT1D, LUT3x1D, read_LUT_Cinespace, write_LUT_Cinespace +from colour.hints import cast +from colour.io import ( + LUT1D, + LUT3D, + LUT3x1D, + LUTSequence, + read_LUT_Cinespace, + write_LUT_Cinespace, +) from colour.utilities import tstack __author__ = "Colour Developers" @@ -35,13 +43,16 @@ class TestReadLUTCinespace: unit tests methods. """ - def test_read_LUT_Cinespace(self): + def test_read_LUT_Cinespace(self) -> None: """ Test :func:`colour.io.luts.cinespace_csp.read_LUT_Cinespace` definition. """ - LUT_1 = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.csp")) + LUT_1 = cast( + LUT3x1D, + read_LUT_Cinespace(os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.csp")), + ) np.testing.assert_allclose( LUT_1.table, @@ -89,22 +100,29 @@ def test_read_LUT_Cinespace(self): assert LUT_1.size == 32 assert LUT_1.comments == [] - LUT_2 = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp")) + LUT_2 = cast(LUT3x1D, read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp"))) assert LUT_2.comments == ["Comments are ignored by most parsers"] np.testing.assert_array_equal(LUT_2.domain, np.array([[0, 0, 0], [1, 2, 3]])) - LUT_3 = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp") + LUT_3 = cast( + LUT3D, + read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp")), ) assert LUT_3.dimensions == 3 assert LUT_3.size == 2 - LUT_4 = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Explicit_Domain.csp")) + LUT_4 = cast( + LUTSequence, + read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Explicit_Domain.csp")), + ) assert LUT_4[0].is_domain_explicit() is True assert LUT_4[1].table.shape == (2, 3, 4, 3) - LUT_5 = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Uncommon_3x1D_With_Pre_Lut.csp") + LUT_5 = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join(ROOT_LUTS, "Uncommon_3x1D_With_Pre_Lut.csp") + ), ) assert isinstance(LUT_5[0], LUT3x1D) assert isinstance(LUT_5[1], LUT3x1D) @@ -116,17 +134,17 @@ class TestWriteLUTCinespace: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_Cinespace(self): + def test_write_LUT_Cinespace(self) -> None: """ Test :func:`colour.io.luts.cinespace_csp.write_LUT_Cinespace` definition. @@ -145,25 +163,30 @@ def test_write_LUT_Cinespace(self): assert LUT_1_r == LUT_1_t assert LUT_1_r == LUT_1_t - LUT_2_r = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp")) + LUT_2_r = cast(LUT3x1D, read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Demo.csp"))) write_LUT_Cinespace( LUT_2_r, os.path.join(self._temporary_directory, "Demo.csp") ) - LUT_2_t = read_LUT_Cinespace( - os.path.join(self._temporary_directory, "Demo.csp") + LUT_2_t = cast( + LUT3x1D, + read_LUT_Cinespace(os.path.join(self._temporary_directory, "Demo.csp")), ) assert LUT_2_r == LUT_2_t assert LUT_2_r.comments == LUT_2_t.comments - LUT_3_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp") + LUT_3_r = cast( + LUT3D, + read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Three_Dimensional_Table.csp")), ) write_LUT_Cinespace( LUT_3_r, os.path.join(self._temporary_directory, "Three_Dimensional_Table.csp"), ) - LUT_3_t = read_LUT_Cinespace( - os.path.join(self._temporary_directory, "Three_Dimensional_Table.csp") + LUT_3_t = cast( + LUT3D, + read_LUT_Cinespace( + os.path.join(self._temporary_directory, "Three_Dimensional_Table.csp") + ), ) assert LUT_3_r == LUT_3_t @@ -179,16 +202,23 @@ def test_write_LUT_Cinespace(self): LUT_4_t, os.path.join(self._temporary_directory, "Ragged_Domain.csp"), ) - LUT_4_r = read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Ragged_Domain.csp")) + LUT_4_r = cast( + LUT3x1D, read_LUT_Cinespace(os.path.join(ROOT_LUTS, "Ragged_Domain.csp")) + ) np.testing.assert_allclose( LUT_4_t.domain, LUT_4_r.domain, atol=TOLERANCE_ABSOLUTE_TESTS ) np.testing.assert_allclose(LUT_4_t.table, LUT_4_r.table, atol=5e-5) - LUT_5_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + LUT_5_r = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + ), + ) + LUT_5_r.sequence[0] = LUT_5_r.sequence[0].convert( # pyright: ignore + LUT1D, force_conversion=True ) - LUT_5_r.sequence[0] = LUT_5_r.sequence[0].convert(LUT1D, force_conversion=True) write_LUT_Cinespace( LUT_5_r, os.path.join( @@ -196,21 +226,30 @@ def test_write_LUT_Cinespace(self): "Three_Dimensional_Table_With_Shaper.csp", ), ) - LUT_5_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + LUT_5_r = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + ), ) - LUT_5_t = read_LUT_Cinespace( - os.path.join( - self._temporary_directory, - "Three_Dimensional_Table_With_Shaper.csp", - ) + LUT_5_t = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join( + self._temporary_directory, + "Three_Dimensional_Table_With_Shaper.csp", + ) + ), ) assert LUT_5_r == LUT_5_t - LUT_6_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + LUT_6_r = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + ), ) - LUT_6_r.sequence[0] = LUT_6_r.sequence[0].convert( + LUT_6_r.sequence[0] = LUT_6_r.sequence[0].convert( # pyright: ignore LUT3x1D, force_conversion=True ) write_LUT_Cinespace( @@ -220,30 +259,40 @@ def test_write_LUT_Cinespace(self): "Three_Dimensional_Table_With_Shaper.csp", ), ) - LUT_6_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + LUT_6_r = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.csp") + ), ) - LUT_6_t = read_LUT_Cinespace( - os.path.join( - self._temporary_directory, - "Three_Dimensional_Table_With_Shaper.csp", - ) + LUT_6_t = cast( + LUTSequence, + read_LUT_Cinespace( + os.path.join( + self._temporary_directory, + "Three_Dimensional_Table_With_Shaper.csp", + ) + ), ) assert LUT_6_r == LUT_6_t - LUT_7_r = read_LUT_Cinespace( - os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.csp") + LUT_7_r = cast( + LUT3x1D, + read_LUT_Cinespace(os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.csp")), ) write_LUT_Cinespace( - LUT_7_r.convert(LUT1D, force_conversion=True), + cast(LUT1D, LUT_7_r.convert(LUT1D, force_conversion=True)), os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.csp"), ) - LUT_7_t = read_LUT_Cinespace( - os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.csp") + LUT_7_t = cast( + LUT3x1D, + read_LUT_Cinespace( + os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.csp") + ), ) assert LUT_7_r == LUT_7_t - def test_raise_exception_write_LUT_Cinespace(self): + def test_raise_exception_write_LUT_Cinespace(self) -> None: """ Test :func:`colour.io.luts.cinespace_csp.write_LUT_Cinespace` definition raised exception. diff --git a/colour/io/luts/tests/test_common.py b/colour/io/luts/tests/test_common.py index 5ef5cb618..e44ec3539 100644 --- a/colour/io/luts/tests/test_common.py +++ b/colour/io/luts/tests/test_common.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.io.luts.common` module.""" +from __future__ import annotations + from colour.io.luts.common import path_to_title __author__ = "Colour Developers" @@ -20,7 +22,7 @@ class TestPathToTitle: methods. """ - def test_path_to_title(self): + def test_path_to_title(self) -> None: """Test :func:`colour.io.luts.common.path_to_title` definition.""" assert ( diff --git a/colour/io/luts/tests/test_iridas_cube.py b/colour/io/luts/tests/test_iridas_cube.py index b65e80f20..28bdb53fd 100644 --- a/colour/io/luts/tests/test_iridas_cube.py +++ b/colour/io/luts/tests/test_iridas_cube.py @@ -9,6 +9,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS +from colour.hints import cast from colour.io import ( LUT1D, LUTSequence, @@ -38,7 +39,7 @@ class TestReadLUTIridasCube: unit tests methods. """ - def test_read_LUT_IridasCube(self): + def test_read_LUT_IridasCube(self) -> None: """ Test :func:`colour.io.luts.iridas_cube.read_LUT_IridasCube` definition. @@ -111,17 +112,17 @@ class TestWriteLUTIridasCube: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_IridasCube(self): + def test_write_LUT_IridasCube(self) -> None: """ Test :func:`colour.io.luts.iridas_cube.write_LUT_IridasCube` definition. @@ -171,7 +172,7 @@ def test_write_LUT_IridasCube(self): os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube") ) write_LUT_IridasCube( - LUT_4_r.convert(LUT1D, force_conversion=True), + cast(LUT1D, LUT_4_r.convert(LUT1D, force_conversion=True)), os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube"), ) LUT_4_t = read_LUT_IridasCube( diff --git a/colour/io/luts/tests/test_lut.py b/colour/io/luts/tests/test_lut.py index daebf7e97..6f2121856 100644 --- a/colour/io/luts/tests/test_lut.py +++ b/colour/io/luts/tests/test_lut.py @@ -56,7 +56,7 @@ class TestAbstractLUT: """Define :class:`colour.io.luts.lut.AbstractLUT` class unit tests methods.""" - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -71,7 +71,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(AbstractLUT) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -110,39 +110,43 @@ class FixtureAbstractLUT: :class:`colour.io.luts.lut.LUT3D` classes fixture. """ - @pytest.fixture(autouse=True) - def setup_fixture_abstract_lut(self) -> None: - """Configure the class instance.""" - + def __init__(self) -> None: self._LUT_factory: Any = None - self._size: int | None = None - self._dimensions: int | None = None - self._domain_1: NDArrayFloat | None = None - self._domain_2: NDArrayFloat | None = None - self._domain_3: NDArrayFloat | None = None - self._table_1: NDArrayFloat | None = None - self._table_2: NDArrayFloat | None = None - self._table_3: NDArrayFloat | None = None - self._table_1_kwargs: dict | None = None - self._table_2_kwargs: dict | None = None - self._table_3_kwargs: dict | None = None - self._interpolator_1: Callable | Type[ProtocolInterpolator] | None = None + self._size: int = -1 + self._dimensions: int = -1 + self._domain_1: NDArrayFloat = np.array([]) + self._domain_2: NDArrayFloat = np.array([]) + self._domain_3: NDArrayFloat = np.array([]) + self._domain_4: NDArrayFloat = np.array([]) + self._table_1: NDArrayFloat = np.array([]) + self._table_2: NDArrayFloat = np.array([]) + self._table_3: NDArrayFloat = np.array([]) + self._table_1_kwargs: dict = {} + self._table_2_kwargs: dict = {} + self._table_3_kwargs: dict = {} + self._interpolator_1: Callable | Type[ProtocolInterpolator] = LinearInterpolator self._interpolator_kwargs_1: dict = {} - self._interpolator_2: Callable | Type[ProtocolInterpolator] | None = None + self._interpolator_2: Callable | Type[ProtocolInterpolator] = LinearInterpolator self._interpolator_kwargs_2: dict = {} self._invert_kwargs_1: dict = {} self._invert_kwargs_2: dict = {} - self._str: str | None = None + self._str: str = "" self._repr: str | None = None - self._inverted_apply_1: NDArrayFloat | None = None - self._inverted_apply_2: NDArrayFloat | None = None - self._applied_1: NDArrayFloat | None = None - self._applied_2: NDArrayFloat | None = None - self._applied_3: NDArrayFloat | None = None - self._applied_4: NDArrayFloat | None = None - - def test_required_methods(self): + self._inverted_apply_1: NDArrayFloat = np.array([]) + self._inverted_apply_2: NDArrayFloat = np.array([]) + self._applied_1: NDArrayFloat = np.array([]) + self._applied_2: NDArrayFloat = np.array([]) + self._applied_3: NDArrayFloat = np.array([]) + self._applied_4: NDArrayFloat = np.array([]) + + @pytest.fixture(autouse=True) + def setup_fixture_abstract_lut(self) -> None: + """Configure the class instance.""" + + self.__init__() + + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -158,7 +162,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(class_) - def test__init__(self): + def test__init__(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.__init__`, :class:`colour.io.luts.lut.LUT3x1D.__init__` and @@ -181,7 +185,7 @@ def test__init__(self): self._LUT_factory(self._table_3, domain=self._domain_3), self._LUT_factory ) - def test_table(self): + def test_table(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.table`, :class:`colour.io.luts.lut.LUT3x1D.table` and @@ -196,7 +200,7 @@ def test_table(self): LUT.table = table_1 np.testing.assert_allclose(LUT.table, table_1, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_name(self): + def test_name(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.name`, :class:`colour.io.luts.lut.LUT3x1D.name` and @@ -211,7 +215,7 @@ def test_name(self): assert LUT.name == f"Unity {self._table_1.shape[0]}" - def test_domain(self): + def test_domain(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.domain`, :class:`colour.io.luts.lut.LUT3x1D.domain` and @@ -226,7 +230,7 @@ def test_domain(self): LUT.domain = domain np.testing.assert_array_equal(LUT.domain, domain) - def test_size(self): + def test_size(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.size`, :class:`colour.io.luts.lut.LUT3x1D.size` and @@ -237,7 +241,7 @@ def test_size(self): assert LUT.size == LUT.table.shape[0] - def test_dimensions(self): + def test_dimensions(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.dimensions`, :class:`colour.io.luts.lut.LUT3x1D.dimensions` and @@ -248,7 +252,7 @@ def test_dimensions(self): assert LUT.dimensions == self._dimensions - def test_comments(self): + def test_comments(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.comments`, :class:`colour.io.luts.lut.LUT3x1D.comments` and @@ -263,7 +267,7 @@ def test_comments(self): assert LUT.comments == comments - def test__str__(self): + def test__str__(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.__str__`, :class:`colour.io.luts.lut.LUT3x1D.__str__` and @@ -274,7 +278,7 @@ def test__str__(self): assert str(LUT) == self._str - def test__repr__(self): + def test__repr__(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.__repr__`, :class:`colour.io.luts.lut.LUT3x1D.__repr__` and @@ -294,7 +298,7 @@ def test__repr__(self): assert repr(LUT) == self._repr - def test__eq__(self): + def test__eq__(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.__eq__`, :class:`colour.io.luts.lut.LUT3x1D.__eq__` and @@ -306,7 +310,7 @@ def test__eq__(self): assert LUT_1 == LUT_2 - def test__ne__(self): + def test__ne__(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.__ne__`, :class:`colour.io.luts.lut.LUT3x1D.__ne__` and @@ -323,7 +327,7 @@ def test__ne__(self): LUT_2.domain = self._domain_1 * 0.8 + 0.1 assert LUT_1 != LUT_2 - def test_is_domain_explicit(self): + def test_is_domain_explicit(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.is_domain_explicit`, :class:`colour.io.luts.lut.LUT3x1D.is_domain_explicit` and @@ -336,7 +340,7 @@ def test_is_domain_explicit(self): self._table_3, domain=self._domain_3 ).is_domain_explicit() - def test_arithmetical_operation(self): + def test_arithmetical_operation(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.arithmetical_operation`, :class:`colour.io.luts.lut.LUT3x1D.arithmetical_operation` and @@ -450,7 +454,7 @@ def test_arithmetical_operation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_linear_table(self): + def test_linear_table(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.linear_table`, :class:`colour.io.luts.lut.LUT3x1D.linear_table` and @@ -471,7 +475,7 @@ def test_linear_table(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_copy(self): + def test_copy(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.copy`, :class:`colour.io.luts.lut.LUT3x1D.copy` and @@ -483,7 +487,7 @@ def test_copy(self): assert LUT_1 is not LUT_1.copy() assert LUT_1.copy() == LUT_1 - def test_invert(self): + def test_invert(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.invert`, :class:`colour.io.luts.lut.LUT3x1D.invert` and @@ -525,7 +529,7 @@ def test_invert(self): except NotImplementedError: pass - def test_apply(self): + def test_apply(self) -> None: """ Test :class:`colour.io.luts.lut.LUT1D.apply`, :class:`colour.io.luts.lut.LUT3x1D.apply` and @@ -954,7 +958,7 @@ def setup_test_lut_3_d(self) -> None: Size : (33, 33, 33, 3) """ ).strip() - self._repr = None + self._repr = None # pyright: ignore self._inverted_apply_1 = np.array( [ [ @@ -1066,7 +1070,7 @@ class TestLUT_to_LUT: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._domain = np.array([[0.0, -0.1, -0.2], [1.0, 1.5, 3.0]]) @@ -1078,7 +1082,7 @@ def setup_method(self): ) self._LUT_3 = LUT3D(LUT3D.linear_table(16) ** (1 / 2.2), domain=self._domain) - def test_LUT_to_LUT(self): + def test_LUT_to_LUT(self) -> None: """Test :func:`colour.io.luts.lut.LUT_to_LUT` definition.""" # "LUT" 1D to "LUT" 1D. diff --git a/colour/io/luts/tests/test_operator.py b/colour/io/luts/tests/test_operator.py index 416ce1ba3..598f65924 100644 --- a/colour/io/luts/tests/test_operator.py +++ b/colour/io/luts/tests/test_operator.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.io.luts.operator` module.""" +from __future__ import annotations + import textwrap import numpy as np @@ -27,7 +29,7 @@ class TestAbstractLUTSequenceOperator: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("name", "comments") @@ -35,7 +37,7 @@ def test_required_attributes(self): for method in required_attributes: assert method in dir(AbstractLUTSequenceOperator) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("apply",) @@ -50,7 +52,7 @@ class TestLUTOperatorMatrix: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._lut_operator_matrix = LUTOperatorMatrix( @@ -60,7 +62,7 @@ def setup_method(self): comments=["A first comment.", "A second comment."], ) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("matrix", "offset") @@ -68,7 +70,7 @@ def test_required_attributes(self): for method in required_attributes: assert method in dir(LUTOperatorMatrix) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__", "__repr__", "__eq__", "__ne__", "apply") @@ -76,7 +78,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(LUTOperatorMatrix) - def test_matrix(self): + def test_matrix(self) -> None: """ Test :class:`colour.io.luts.operator.LUTOperatorMatrix.matrix` property. @@ -87,7 +89,7 @@ def test_matrix(self): lut_operator_matrix = LUTOperatorMatrix(M) np.testing.assert_array_equal(lut_operator_matrix.matrix, np.identity(4)) - def test_offset(self): + def test_offset(self) -> None: """ Test :class:`colour.io.luts.operator.LUTOperatorMatrix.offset` property. @@ -98,7 +100,7 @@ def test_offset(self): lut_operator_matrix = LUTOperatorMatrix(np.identity(3), offset) np.testing.assert_array_equal(lut_operator_matrix.offset, zeros(4)) - def test__str__(self): + def test__str__(self) -> None: """ Test :class:`colour.io.luts.operator.LUTOperatorMatrix.__str__` method. @@ -124,7 +126,7 @@ def test__str__(self): ) ) - def test__repr__(self): + def test__repr__(self) -> None: """ Test :class:`colour.io.luts.operator.LUTOperatorMatrix.__repr__` method. @@ -143,7 +145,7 @@ def test__repr__(self): ) ) - def test__eq__(self): + def test__eq__(self) -> None: """Test :class:`colour.io.luts.operator.LUTOperatorMatrix.__eq__` method.""" matrix = LUTOperatorMatrix( @@ -153,7 +155,7 @@ def test__eq__(self): assert self._lut_operator_matrix == matrix - def test__neq__(self): + def test__neq__(self) -> None: """ Test :class:`colour.io.luts.operator.LUTOperatorMatrix.__neq__` method. @@ -163,7 +165,7 @@ def test__neq__(self): assert self._lut_operator_matrix != matrix - def test_apply(self): + def test_apply(self) -> None: """Test :class:`colour.io.luts.operator.LUTOperatorMatrix.apply` method.""" samples = np.linspace(0, 1, 5) diff --git a/colour/io/luts/tests/test_resolve_cube.py b/colour/io/luts/tests/test_resolve_cube.py index 4cb24be0a..436c2ffd4 100644 --- a/colour/io/luts/tests/test_resolve_cube.py +++ b/colour/io/luts/tests/test_resolve_cube.py @@ -10,7 +10,15 @@ import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.io import LUT1D, read_LUT_ResolveCube, write_LUT_ResolveCube +from colour.hints import cast +from colour.io import ( + LUT1D, + LUT3D, + LUT3x1D, + LUTSequence, + read_LUT_ResolveCube, + write_LUT_ResolveCube, +) __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -34,14 +42,15 @@ class TestReadLUTResolveCube: unit tests methods. """ - def test_read_LUT_ResolveCube(self): + def test_read_LUT_ResolveCube(self) -> None: """ Test :func:`colour.io.luts.resolve_cube.read_LUT_ResolveCube` definition. """ - LUT_1 = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube") + LUT_1 = cast( + LUT3x1D, + read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube")), ) np.testing.assert_allclose( @@ -90,17 +99,25 @@ def test_read_LUT_ResolveCube(self): assert LUT_1.size == 32 assert LUT_1.comments == [] - LUT_2 = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) + LUT_2 = cast( + LUT3x1D, read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) + ) assert LUT_2.comments == ["Comments can't go anywhere"] np.testing.assert_array_equal(LUT_2.domain, np.array([[0, 0, 0], [3, 3, 3]])) - LUT_3 = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") + LUT_3 = cast( + LUT3D, + read_LUT_ResolveCube( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") + ), ) assert LUT_3.dimensions == 3 assert LUT_3.size == 2 - LUT_4 = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "LogC_Video.cube")) + LUT_4 = cast( + LUTSequence, + read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "LogC_Video.cube")), + ) np.testing.assert_allclose( LUT_4[0].table, np.array( @@ -134,17 +151,17 @@ class TestWriteLUTResolveCube: definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_ResolveCube(self): + def test_write_LUT_ResolveCube(self) -> None: """ Test :func:`colour.io.luts.resolve_cube.write_LUT_ResolveCube` definition. @@ -165,21 +182,27 @@ def test_write_LUT_ResolveCube(self): assert LUT_1_r == LUT_1_t - LUT_2_r = read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) + LUT_2_r = cast( + LUT3x1D, read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "Demo.cube")) + ) write_LUT_ResolveCube( LUT_2_r, os.path.join(self._temporary_directory, "Demo.cube") ) - LUT_2_t = read_LUT_ResolveCube( - os.path.join(self._temporary_directory, "Demo.cube") + LUT_2_t = cast( + LUT3x1D, + read_LUT_ResolveCube(os.path.join(self._temporary_directory, "Demo.cube")), ) assert LUT_2_r == LUT_2_t assert LUT_2_r.comments == LUT_2_t.comments - LUT_3_r = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") + LUT_3_r = cast( + LUT3D, + read_LUT_ResolveCube( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table.cube") + ), ) write_LUT_ResolveCube( @@ -187,17 +210,24 @@ def test_write_LUT_ResolveCube(self): os.path.join(self._temporary_directory, "Three_Dimensional_Table.cube"), ) - LUT_3_t = read_LUT_ResolveCube( - os.path.join(self._temporary_directory, "Three_Dimensional_Table.cube") + LUT_3_t = cast( + LUT3D, + read_LUT_ResolveCube( + os.path.join(self._temporary_directory, "Three_Dimensional_Table.cube") + ), ) - assert LUT_3_r == LUT_3_t - LUT_4_r = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") + LUT_4_r = cast( + LUTSequence, + read_LUT_ResolveCube( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") + ), ) - LUT_4_r.sequence[0] = LUT_4_r.sequence[0].convert(LUT1D, force_conversion=True) + LUT_4_r.sequence[0] = LUT_4_r.sequence[0].convert( # pyright: ignore + LUT1D, force_conversion=True + ) write_LUT_ResolveCube( LUT_4_r, @@ -207,35 +237,45 @@ def test_write_LUT_ResolveCube(self): ), ) - LUT_4_t = read_LUT_ResolveCube( - os.path.join( - self._temporary_directory, - "Three_Dimensional_Table_With_Shaper.cube", - ) + LUT_4_t = cast( + LUTSequence, + read_LUT_ResolveCube( + os.path.join( + self._temporary_directory, + "Three_Dimensional_Table_With_Shaper.cube", + ) + ), ) - LUT_4_r = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") + LUT_4_r = cast( + LUTSequence, + read_LUT_ResolveCube( + os.path.join(ROOT_LUTS, "Three_Dimensional_Table_With_Shaper.cube") + ), ) assert LUT_4_r == LUT_4_t - LUT_5_r = read_LUT_ResolveCube( - os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube") + LUT_5_r = cast( + LUT3x1D, + read_LUT_ResolveCube(os.path.join(ROOT_LUTS, "ACES_Proxy_10_to_ACES.cube")), ) write_LUT_ResolveCube( - LUT_5_r.convert(LUT1D, force_conversion=True), + cast(LUT1D, LUT_5_r.convert(LUT1D, force_conversion=True)), os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube"), ) - LUT_5_t = read_LUT_ResolveCube( - os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") + LUT_5_t = cast( + LUT3x1D, + read_LUT_ResolveCube( + os.path.join(self._temporary_directory, "ACES_Proxy_10_to_ACES.cube") + ), ) assert LUT_5_r == LUT_5_t - def test_raise_exception_write_LUT_ResolveCube(self): + def test_raise_exception_write_LUT_ResolveCube(self) -> None: """ Test :func:`colour.io.luts.resolve_cube.write_LUT_ResolveCube` definition raised exception. diff --git a/colour/io/luts/tests/test_sequence.py b/colour/io/luts/tests/test_sequence.py index ee7967b23..806335de3 100644 --- a/colour/io/luts/tests/test_sequence.py +++ b/colour/io/luts/tests/test_sequence.py @@ -36,7 +36,7 @@ class TestLUTSequence: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._LUT_1 = LUT1D(LUT1D.linear_table(16) + 0.125, "Nemo 1D") @@ -48,7 +48,7 @@ def setup_method(self): self._RGB = tstack([samples, samples, samples]) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("sequence",) @@ -56,7 +56,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(LUTSequence) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -77,7 +77,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(LUTSequence) - def test_sequence(self): + def test_sequence(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.sequence` property.""" sequence = [self._LUT_1, self._LUT_2, self._LUT_3] @@ -85,19 +85,19 @@ def test_sequence(self): LUT_sequence.sequence = sequence assert self._LUT_sequence.sequence == sequence - def test__init__(self): + def test__init__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__init__` method.""" assert LUTSequence(self._LUT_1, self._LUT_2, self._LUT_3) == self._LUT_sequence - def test__getitem__(self): + def test__getitem__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__getitem__` method.""" assert self._LUT_sequence[0] == self._LUT_1 assert self._LUT_sequence[1] == self._LUT_2 assert self._LUT_sequence[2] == self._LUT_3 - def test__setitem__(self): + def test__setitem__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__setitem__` method.""" LUT_sequence = self._LUT_sequence.copy() @@ -109,7 +109,7 @@ def test__setitem__(self): assert LUT_sequence[2] == self._LUT_2 assert LUT_sequence[0] == self._LUT_3 - def test__delitem__(self): + def test__delitem__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__delitem__` method.""" LUT_sequence = self._LUT_sequence.copy() @@ -119,12 +119,12 @@ def test__delitem__(self): assert LUT_sequence[0] == self._LUT_3 - def test__len__(self): + def test__len__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__len__` method.""" assert len(self._LUT_sequence) == 3 - def test__str__(self): + def test__str__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__str__` method.""" assert str(self._LUT_sequence) == ( @@ -165,7 +165,7 @@ def test__str__(self): ).strip() ) - def test__repr__(self): + def test__repr__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__repr__` method.""" LUT_sequence = self._LUT_sequence.copy() @@ -360,7 +360,7 @@ def test__repr__(self): ) ) - def test__eq__(self): + def test__eq__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__eq__` method.""" LUT_sequence_1 = LUTSequence(self._LUT_1, self._LUT_2, self._LUT_3) @@ -372,14 +372,14 @@ def test__eq__(self): assert LUT_sequence_1 != LUT_sequence_2 - def test__neq__(self): + def test__neq__(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.__neq__` method.""" assert self._LUT_sequence != LUTSequence( self._LUT_1, self._LUT_2.copy() * 0.75, self._LUT_3 ) - def test_insert(self): + def test_insert(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.insert` method.""" LUT_sequence = self._LUT_sequence.copy() @@ -393,7 +393,7 @@ def test_insert(self): self._LUT_3, ) - def test_apply(self): + def test_apply(self) -> None: """Test :class:`colour.io.luts.sequence.LUTSequence.apply` method.""" class GammaOperator(AbstractLUTSequenceOperator): diff --git a/colour/io/luts/tests/test_sony_spi1d.py b/colour/io/luts/tests/test_sony_spi1d.py index 0f38327c2..8c3d07e2e 100644 --- a/colour/io/luts/tests/test_sony_spi1d.py +++ b/colour/io/luts/tests/test_sony_spi1d.py @@ -33,7 +33,7 @@ class TestReadLUTSonySPI1D: unit tests methods. """ - def test_read_LUT_SonySPI1D(self): + def test_read_LUT_SonySPI1D(self) -> None: """Test :func:`colour.io.luts.sony_spi1d.read_LUT_SonySPI1D` definition.""" LUT_1 = read_LUT_SonySPI1D(os.path.join(ROOT_LUTS, "eotf_sRGB_1D.spi1d")) @@ -87,17 +87,17 @@ class TestWriteLUTSonySPI1D: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_SonySPI1D(self): + def test_write_LUT_SonySPI1D(self) -> None: """Test :func:`colour.io.luts.sony_spi1d.write_LUT_SonySPI1D` definition.""" LUT_1_r = read_LUT_SonySPI1D(os.path.join(ROOT_LUTS, "eotf_sRGB_1D.spi1d")) diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index 84c041538..52e2e00a9 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -39,7 +39,7 @@ class TestReadLUTSonySPI3D: unit tests methods. """ - def test_read_LUT_SonySPI3D(self): + def test_read_LUT_SonySPI3D(self) -> None: """Test :func:`colour.io.luts.sony_spi3d.read_LUT_SonySPI3D` definition.""" LUT_1 = read_LUT_SonySPI3D(os.path.join(ROOT_LUTS, "Colour_Correct.spi3d")) @@ -179,17 +179,17 @@ class TestWriteLUTSonySPI3D: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_SonySPI3D(self): + def test_write_LUT_SonySPI3D(self) -> None: """Test :func:`colour.io.luts.sony_spi3d.write_LUT_SonySPI3D` definition.""" LUT_r = read_LUT_SonySPI3D(os.path.join(ROOT_LUTS, "Colour_Correct.spi3d")) diff --git a/colour/io/luts/tests/test_sony_spimtx.py b/colour/io/luts/tests/test_sony_spimtx.py index b04d3bb9d..88f839be5 100644 --- a/colour/io/luts/tests/test_sony_spimtx.py +++ b/colour/io/luts/tests/test_sony_spimtx.py @@ -33,7 +33,7 @@ class TestReadLUTSonySPImtx: unit tests methods. """ - def test_read_LUT_SonySPImtx(self): + def test_read_LUT_SonySPImtx(self) -> None: """ Test :func:`colour.io.luts.sony_spimtx.read_LUT_SonySPImtx` definition. @@ -107,17 +107,17 @@ class TestWriteLUTSonySPImtx: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_LUT_SonySPImtx(self): + def test_write_LUT_SonySPImtx(self) -> None: """ Test :func:`colour.io.luts.sony_spimtx.write_LUT_SonySPImtx` definition. diff --git a/colour/io/tests/test_ctl.py b/colour/io/tests/test_ctl.py index f2e533b95..ebcfe500d 100644 --- a/colour/io/tests/test_ctl.py +++ b/colour/io/tests/test_ctl.py @@ -43,17 +43,17 @@ class TestCtlRender: """Define :func:`colour.io.ctl.ctl_render` definition unit tests methods.""" - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_ctl_render(self): # pragma: no cover + def test_ctl_render(self) -> None: # pragma: no cover """Test :func:`colour.io.ctl.ctl_render` definition.""" if not is_ctlrender_installed(): @@ -123,7 +123,7 @@ class TestProcessImageCtl: methods. """ - def test_process_image_ctl(self): # pragma: no cover + def test_process_image_ctl(self) -> None: # pragma: no cover """Test :func:`colour.io.ctl.process_image_ctl` definition.""" if not is_ctlrender_installed(): @@ -201,7 +201,7 @@ class TestTemplateCtlTransformFloat: tests methods. """ - def test_template_ctl_transform_float(self): + def test_template_ctl_transform_float(self) -> None: """Test :func:`colour.io.ctl.template_ctl_transform_float` definition.""" ctl_foo_bar_float = template_ctl_transform_float( @@ -254,7 +254,7 @@ class TestTemplateCtlTransformFloat3: tests methods. """ - def test_template_ctl_transform_float3(self): + def test_template_ctl_transform_float3(self) -> None: """Test :func:`colour.io.ctl.template_ctl_transform_float3` definition.""" ctl_foo_bar_float3 = template_ctl_transform_float3( diff --git a/colour/io/tests/test_fichet2021.py b/colour/io/tests/test_fichet2021.py index 1bc145328..36a78e7c0 100644 --- a/colour/io/tests/test_fichet2021.py +++ b/colour/io/tests/test_fichet2021.py @@ -16,7 +16,9 @@ sds_and_msds_to_msds, ) from colour.constants import CONSTANT_LIGHT_SPEED, TOLERANCE_ABSOLUTE_TESTS +from colour.hints import NDArrayFloat, Tuple, cast from colour.io import ( + ComponentsFichet2021, Specification_Fichet2021, read_spectral_image_Fichet2021, sd_to_spectrum_attribute_Fichet2021, @@ -57,7 +59,7 @@ class TestMatchGroupsToNm: tests methods. """ - def test_match_groups_to_nm(self): + def test_match_groups_to_nm(self) -> None: """Test :func:`colour.io.fichet2021.match_groups_to_nm` definition.""" np.testing.assert_allclose( @@ -85,7 +87,7 @@ class TestSdToSpectrumAttributeFichet2021: definition unit tests methods. """ - def test_sd_to_spectrum_attribute_Fichet2021(self): + def test_sd_to_spectrum_attribute_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.\ sd_to_spectrum_attribute_Fichet2021` definition. @@ -103,7 +105,7 @@ class TestSpectrumAttributeToSdFichet2021: definition unit tests methods. """ - def test_spectrum_attribute_to_sd_Fichet2021(self): + def test_spectrum_attribute_to_sd_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.\ spectrum_attribute_to_sd_Fichet2021` definition. @@ -132,7 +134,7 @@ class TestSdsAndMsdsToComponentsFichet2021: definition unit tests methods. """ - def test_sds_and_msds_to_components_Fichet2021(self): + def test_sds_and_msds_to_components_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.\ sds_and_msds_to_components_Fichet2021` definition. @@ -173,7 +175,7 @@ class TestComponentsToSRGBFichet2021: definition unit tests methods. """ - def test_components_to_sRGB_Fichet2021(self): + def test_components_to_sRGB_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.components_to_sRGB_Fichet2021` definition. @@ -189,7 +191,7 @@ def test_components_to_sRGB_Fichet2021(self): RGB, attributes = components_to_sRGB_Fichet2021(components, specification) np.testing.assert_allclose( - RGB, + cast(NDArrayFloat, RGB), np.array([[[0.17998291, 0.18000802, 0.18000908]]]), atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -239,7 +241,7 @@ def test_components_to_sRGB_Fichet2021(self): RGB, attributes = components_to_sRGB_Fichet2021(components, specification) np.testing.assert_allclose( - RGB, + cast(NDArrayFloat, RGB), np.array( [ [ @@ -291,10 +293,10 @@ def test_components_to_sRGB_Fichet2021(self): ) -def _test_spectral_image_D65(path): +def _test_spectral_image_D65(path: str) -> None: """Test the *D65* spectral image.""" - components = read_spectral_image_Fichet2021(path) + components = cast(ComponentsFichet2021, read_spectral_image_Fichet2021(path)) assert "S0" in components @@ -310,8 +312,11 @@ def _test_spectral_image_D65(path): atol=0.05, ) - components, specification = read_spectral_image_Fichet2021( - os.path.join(ROOT_RESOURCES, "D65.exr"), additional_data=True + components, specification = cast( + Tuple[ComponentsFichet2021, Specification_Fichet2021], + read_spectral_image_Fichet2021( + os.path.join(ROOT_RESOURCES, "D65.exr"), additional_data=True + ), ) assert specification.is_emissive is True @@ -349,11 +354,12 @@ def _test_spectral_image_D65(path): ) -def _test_spectral_image_Ohta1997(path): +def _test_spectral_image_Ohta1997(path: str) -> None: """Test the *Ohta (1997)* spectral image.""" - components, specification = read_spectral_image_Fichet2021( - path, additional_data=True + components, specification = cast( + Tuple[ComponentsFichet2021, Specification_Fichet2021], + read_spectral_image_Fichet2021(path, additional_data=True), ) assert "T" in components @@ -382,11 +388,12 @@ def _test_spectral_image_Ohta1997(path): assert specification.is_bispectral is False -def _test_spectral_image_Polarised(path): +def _test_spectral_image_Polarised(path: str) -> None: """Test the *Polarised* spectral image.""" - components, specification = read_spectral_image_Fichet2021( - path, additional_data=True + components, specification = cast( + Tuple[ComponentsFichet2021, Specification_Fichet2021], + read_spectral_image_Fichet2021(path, additional_data=True), ) assert list(components.keys()) == ["S0", "S1", "S2", "S3"] @@ -396,11 +403,12 @@ def _test_spectral_image_Polarised(path): assert specification.is_bispectral is False -def _test_spectral_image_BiSpectral(path): +def _test_spectral_image_BiSpectral(path: str) -> None: """Test the *Bi-Spectral* image.""" - components, specification = read_spectral_image_Fichet2021( - path, additional_data=True + components, specification = cast( + Tuple[ComponentsFichet2021, Specification_Fichet2021], + read_spectral_image_Fichet2021(path, additional_data=True), ) assert list(components.keys()) == [ @@ -458,7 +466,7 @@ class TestReadSpectralImageFichet2021: definition unit tests methods. """ - def test_read_spectral_image_Fichet2021(self): + def test_read_spectral_image_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.read_spectral_image_Fichet2021` definition. @@ -482,17 +490,17 @@ class TestWriteSpectralImageFichet2021: definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_spectral_image_Fichet2021(self): + def test_write_spectral_image_Fichet2021(self) -> None: """ Test :func:`colour.io.fichet2021.write_spectral_image_Fichet2021` definition. @@ -523,8 +531,11 @@ def test_write_spectral_image_Fichet2021(self): ("Polarised.exr", _test_spectral_image_Polarised), ("BiSpectral.exr", _test_spectral_image_BiSpectral), ]: - components, specification = read_spectral_image_Fichet2021( - os.path.join(ROOT_RESOURCES, basename), additional_data=True + components, specification = cast( + Tuple[ComponentsFichet2021, Specification_Fichet2021], + read_spectral_image_Fichet2021( + os.path.join(ROOT_RESOURCES, basename), additional_data=True + ), ) path = os.path.join(self._temporary_directory, basename) write_spectral_image_Fichet2021(components, path, "float16", specification) diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index d83cc4f98..d45338455 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -11,6 +11,7 @@ import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS +from colour.hints import NDArrayReal, Tuple, cast from colour.io import ( Image_Specification_Attribute, as_3_channels_image, @@ -54,7 +55,7 @@ class TestImageSpecificationOpenImageIO: unit tests methods. """ - def test_image_specification_OpenImageIO(self): # pragma: no cover + def test_image_specification_OpenImageIO(self) -> None: # pragma: no cover """ Test :func:`colour.io.image.image_specification_OpenImageIO` definition. @@ -70,11 +71,11 @@ def test_image_specification_OpenImageIO(self): # pragma: no cover 1920, 1080, 3, "float16", [compression] ) - assert specification.width == 1920 - assert specification.height == 1080 - assert specification.nchannels == 3 - assert specification.format == HALF - assert specification.extra_attribs[0].name == "Compression" + assert specification.width == 1920 # pyright: ignore + assert specification.height == 1080 # pyright: ignore + assert specification.nchannels == 3 # pyright: ignore + assert specification.format == HALF # pyright: ignore + assert specification.extra_attribs[0].name == "Compression" # pyright: ignore class TestConvertBitDepth: @@ -83,7 +84,7 @@ class TestConvertBitDepth: methods. """ - def test_convert_bit_depth(self): + def test_convert_bit_depth(self) -> None: """Test :func:`colour.io.image.convert_bit_depth` definition.""" a = np.around(np.linspace(0, 1, 10) * 255).astype("uint8") @@ -272,47 +273,63 @@ class TestReadImageOpenImageIO: tests methods. """ - def test_read_image_OpenImageIO(self): # pragma: no cover + def test_read_image_OpenImageIO(self) -> None: # pragma: no cover """Test :func:`colour.io.image.read_image_OpenImageIO` definition.""" if not is_openimageio_installed(): return - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") + image = cast( + NDArrayReal, + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") + ), ) assert image.shape == (1267, 1274, 3) assert image.dtype is np.dtype("float32") - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), - "float16", + image = cast( + NDArrayReal, + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), + "float16", + ), ) assert image.dtype is np.dtype("float16") - image, attributes = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), - additional_data=True, + image, attributes = cast( + Tuple[NDArrayReal, Tuple[Image_Specification_Attribute]], + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), + additional_data=True, + ), ) assert image.shape == (1267, 1274, 3) assert attributes[0].name == "oiio:ColorSpace" assert attributes[0].value in ("Linear", "lin_rec709") - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Single_Channel.exr") + image = cast( + NDArrayReal, + read_image_OpenImageIO(os.path.join(ROOT_RESOURCES, "Single_Channel.exr")), ) assert image.shape == (256, 256) - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint8" + image = cast( + NDArrayReal, + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint8" + ), ) assert image.shape == (128, 256, 4) assert image.dtype is np.dtype("uint8") assert np.min(image) == 0 assert np.max(image) == 255 - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint16" + image = cast( + NDArrayReal, + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint16" + ), ) assert image.shape == (128, 256, 4) assert image.dtype is np.dtype("uint16") @@ -326,8 +343,11 @@ def test_read_image_OpenImageIO(self): # pragma: no cover # self.assertEqual(np.min(image), 0.0) # self.assertEqual(np.max(image), 1.0) - image = read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float32" + image = cast( + NDArrayReal, + read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float32" + ), ) assert image.dtype is np.dtype("float32") assert np.min(image) == 0.0 @@ -340,17 +360,17 @@ class TestWriteImageOpenImageIO: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_image_OpenImageIO(self): # pragma: no cover + def test_write_image_OpenImageIO(self) -> None: # pragma: no cover """Test :func:`colour.io.image.write_image_OpenImageIO` definition.""" if not is_openimageio_installed(): @@ -381,9 +401,9 @@ def test_write_image_OpenImageIO(self): # pragma: no cover source_path = os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") target_path = os.path.join(self._temporary_directory, "CMS_Test_Pattern.exr") - image = read_image_OpenImageIO(source_path) + image = cast(NDArrayReal, read_image_OpenImageIO(source_path)) write_image_OpenImageIO(image, target_path) - image = read_image_OpenImageIO(target_path) + image = cast(NDArrayReal, read_image_OpenImageIO(target_path)) assert image.shape == (1267, 1274, 3) assert image.dtype is np.dtype("float32") @@ -434,7 +454,7 @@ class TestReadImageImageio: methods. """ - def test_read_image_Imageio(self): + def test_read_image_Imageio(self) -> None: """Test :func:`colour.io.image.read_image_Imageio` definition.""" image = read_image_Imageio(os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr")) @@ -488,17 +508,17 @@ class TestWriteImageImageio: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_image_Imageio(self): + def test_write_image_Imageio(self) -> None: """Test :func:`colour.io.image.write_image_Imageio` definition.""" source_path = os.path.join(ROOT_RESOURCES, "Overflowing_Gradient.png") @@ -539,7 +559,7 @@ class TestReadImage: methods. """ - def test_read_image(self): + def test_read_image(self) -> None: """Test :func:`colour.io.image.read_image` definition.""" image = read_image(os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr")) @@ -553,17 +573,17 @@ def test_read_image(self): class TestWriteImage: """Define :func:`colour.io.image.write_image` definition unit tests methods.""" - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_image(self): + def test_write_image(self) -> None: """Test :func:`colour.io.image.write_image` definition.""" source_path = os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") @@ -581,7 +601,7 @@ class TestAs3ChannelsImage: methods. """ - def test_as_3_channels_image(self): + def test_as_3_channels_image(self) -> None: """Test :func:`colour.io.image.as_3_channels_image` definition.""" a = 0.18 @@ -598,7 +618,7 @@ def test_as_3_channels_image(self): a = np.array([[[[0.18, 0.18, 0.18]]]]) np.testing.assert_equal(as_3_channels_image(a), b) - def test_raise_exception_as_3_channels_image(self): + def test_raise_exception_as_3_channels_image(self) -> None: """ Test :func:`colour.io.image.as_3_channels_image` definition raised exception. diff --git a/colour/io/tests/test_ocio.py b/colour/io/tests/test_ocio.py index ae5a18eea..5d0f10c9f 100644 --- a/colour/io/tests/test_ocio.py +++ b/colour/io/tests/test_ocio.py @@ -31,7 +31,7 @@ class TestProcessImageOpenColorIO: tests methods. """ - def test_process_image_OpenColorIO(self): + def test_process_image_OpenColorIO(self) -> None: """Test :func:`colour.io.ocio.process_image_OpenColorIO` definition.""" # TODO: Remove when "Pypi" wheel compatible with "ARM" on "macOS" is @@ -78,7 +78,7 @@ def test_process_image_OpenColorIO(self): "ACES - ACES2065-1", "Display - sRGB", "Output - SDR Video - ACES 1.0", - ocio.TRANSFORM_DIR_FORWARD, + ocio.TRANSFORM_DIR_FORWARD, # pyright: ignore config=config, ), np.array( diff --git a/colour/io/tests/test_tabular.py b/colour/io/tests/test_tabular.py index 5cc290263..7b6b276f1 100644 --- a/colour/io/tests/test_tabular.py +++ b/colour/io/tests/test_tabular.py @@ -123,7 +123,7 @@ class TestReadSpectralDataFromCsvFile: definition unit tests methods. """ - def test_read_spectral_data_from_csv_file(self): + def test_read_spectral_data_from_csv_file(self) -> None: """ Test :func:`colour.io.tabular.read_spectral_data_from_csv_file` definition. @@ -165,7 +165,7 @@ class TestReadSdsFromCsvFile: tests methods. """ - def test_read_sds_from_csv_file(self): + def test_read_sds_from_csv_file(self) -> None: """Test :func:`colour.io.tabular.read_sds_from_csv_file` definition.""" colour_checker_n_ohta = os.path.join(ROOT_RESOURCES, "colorchecker_n_ohta.csv") @@ -182,17 +182,17 @@ class TestWriteSdsToCsvFile: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_write_sds_to_csv_file(self): + def test_write_sds_to_csv_file(self) -> None: """Test :func:`colour.io.tabular.write_sds_to_csv_file` definition.""" colour_checker_n_ohta = os.path.join(ROOT_RESOURCES, "colorchecker_n_ohta.csv") @@ -205,7 +205,7 @@ def test_write_sds_to_csv_file(self): for key, value in sds.items(): assert value == sds_test[key] - def test_raise_exception_write_sds_to_csv_file(self): + def test_raise_exception_write_sds_to_csv_file(self) -> None: """ Test :func:`colour.io.tabular.write_sds_to_csv_file` definition raised exception. diff --git a/colour/io/tests/test_tm2714.py b/colour/io/tests/test_tm2714.py index 1001bc388..be17e5917 100644 --- a/colour/io/tests/test_tm2714.py +++ b/colour/io/tests/test_tm2714.py @@ -150,7 +150,7 @@ class TestIES_TM2714_Header: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._header = Header_IESTM2714( @@ -167,7 +167,7 @@ def setup_method(self): comments="k", ) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -188,7 +188,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Header_IESTM2714) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -203,7 +203,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Header_IESTM2714) - def test__str__(self): + def test__str__(self) -> None: """Test :meth:`colour.io.tm2714.Header_IESTM2714.__str__` method.""" assert str(self._header) == ( @@ -224,7 +224,7 @@ def test__str__(self): ).strip() ) - def test__repr__(self): + def test__repr__(self) -> None: """Test :meth:`colour.io.tm2714.Header_IESTM2714.__repr__` method.""" assert repr(self._header) == ( @@ -245,7 +245,7 @@ def test__repr__(self): ).strip() ) - def test__eq__(self): + def test__eq__(self) -> None: """Test :meth:`colour.io.tm2714.Header_IESTM2714.__eq__` method.""" header = deepcopy(self._header) @@ -254,7 +254,7 @@ def test__eq__(self): assert self._header != () - def test__ne__(self): + def test__ne__(self) -> None: """Test :meth:`colour.io.tm2714.Header_IESTM2714.__ne__` method.""" header = deepcopy(self._header) @@ -265,7 +265,7 @@ def test__ne__(self): header.manufacturer = "a" assert self._header == header - def test__hash__(self): + def test__hash__(self) -> None: """Test :meth:`colour.io.tm2714.Header_IESTM2714.__hash__` method.""" assert isinstance(hash(self._header), int) @@ -277,7 +277,7 @@ class TestIES_TM2714_Sd: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() @@ -286,12 +286,12 @@ def setup_method(self): os.path.join(ROOT_RESOURCES, "Fluorescent.spdx") ).read() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -308,7 +308,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(SpectralDistribution_IESTM2714) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__str__", "__repr__", "read", "write") @@ -316,7 +316,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(SpectralDistribution_IESTM2714) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.io.tm2714.SpectralDistribution_IESTM2714.__str__` method. @@ -446,7 +446,7 @@ def test__str__(self): ).strip() ) - def test__repr__(self): + def test__repr__(self) -> None: """ Test :meth:`colour.io.tm2714.SpectralDistribution_IESTM2714.__repr__` method. @@ -569,7 +569,7 @@ def test__repr__(self): ).strip() ) - def test_read(self, sd: SpectralDistribution | None = None): + def test_read(self, sd: SpectralDistribution | None = None) -> None: """ Test :meth:`colour.io.tm2714.SpectralDistribution_IESTM2714.read` method. @@ -609,7 +609,7 @@ def test_read(self, sd: SpectralDistribution | None = None): if key == specification.element: assert getattr(read, specification.attribute) == value - def test_raise_exception_read(self): + def test_raise_exception_read(self) -> None: """ Test :func:`colour.io.tm2714.SpectralDistribution_IESTM2714.read` method raised exception. @@ -623,7 +623,7 @@ def test_raise_exception_read(self): os.path.join(ROOT_RESOURCES, "Invalid.spdx") ) - def test_write(self): + def test_write(self) -> None: """ Test :meth:`colour.io.tm2714.SpectralDistribution_IESTM2714.write` method. @@ -662,7 +662,7 @@ def test_write(self): ): assert getattr(sd_r, attribute) == getattr(sd_t, attribute) - def test_raise_exception_write(self): + def test_raise_exception_write(self) -> None: """ Test :func:`colour.io.tm2714.SpectralDistribution_IESTM2714.write` method raised exception. diff --git a/colour/io/tests/test_uprtek_sekonic.py b/colour/io/tests/test_uprtek_sekonic.py index d23fc275d..7d0265e53 100644 --- a/colour/io/tests/test_uprtek_sekonic.py +++ b/colour/io/tests/test_uprtek_sekonic.py @@ -39,16 +39,22 @@ class FixtureAbstractSpectralDistribution: methods. """ - @pytest.fixture(autouse=True) - def setup_fixture_abstract_spectral_distribution(self) -> None: + def __init__(self) -> None: """Configure the class instance.""" self._sd_factory: Any = None - self._path: str | None = None + self._path: str = ROOT_RESOURCES self._spectral_data: dict | None = None - self._prefix: str | None = None + self._prefix: str = "" + self._header: dict = {} + + @pytest.fixture(autouse=True) + def setup_fixture_abstract_spectral_distribution(self) -> None: + """Configure the class instance.""" + + self.__init__() - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -66,7 +72,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(SpectralDistribution_UPRTek) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__str__", "read", "write") @@ -74,7 +80,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(SpectralDistribution_UPRTek) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.SpectralDistribution_UPRTek.__str__` and :meth:`colour.SpectralDistribution_Sekonic.__str__` methods. @@ -84,7 +90,7 @@ def test__str__(self): self._sd_factory(os.path.join(ROOT_RESOURCES, self._path)).read() ).startswith(self._prefix) - def test_read(self): + def test_read(self) -> None: """ Test :meth:`colour.SpectralDistribution_UPRTek.read` and :meth:`colour.SpectralDistribution_Sekonic.read` methods. diff --git a/colour/io/tests/test_xrite.py b/colour/io/tests/test_xrite.py index 74c517e2b..5e7aea0f7 100644 --- a/colour/io/tests/test_xrite.py +++ b/colour/io/tests/test_xrite.py @@ -68,7 +68,7 @@ class TestReadSdsFromXRiteFile: tests methods. """ - def test_read_sds_from_xrite_file(self): + def test_read_sds_from_xrite_file(self) -> None: """Test :func:`colour.io.xrite.read_sds_from_xrite_file` definition.""" colour_checker_xrite = os.path.join( diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 2d0a45048..1a7e8a2df 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -262,7 +262,7 @@ def manufacturer(self) -> str | None: return self._manufacturer @manufacturer.setter - def manufacturer(self, value: str | None): + def manufacturer(self, value: str | None) -> None: """Setter for the **self.manufacturer** property.""" if value is not None: @@ -292,7 +292,7 @@ def catalog_number(self) -> str | None: return self._catalog_number @catalog_number.setter - def catalog_number(self, value: str | None): + def catalog_number(self, value: str | None) -> None: """Setter for the **self.catalog_number** property.""" if value is not None: @@ -322,7 +322,7 @@ def description(self) -> str | None: return self._description @description.setter - def description(self, value: str | None): + def description(self, value: str | None) -> None: """Setter for the **self.description** property.""" if value is not None: @@ -352,7 +352,7 @@ def document_creator(self) -> str | None: return self._document_creator @document_creator.setter - def document_creator(self, value: str | None): + def document_creator(self, value: str | None) -> None: """Setter for the **self.document_creator** property.""" if value is not None: @@ -382,7 +382,7 @@ def unique_identifier(self) -> str | None: return self._unique_identifier @unique_identifier.setter - def unique_identifier(self, value: str | None): + def unique_identifier(self, value: str | None) -> None: """Setter for the **self.unique_identifier** property.""" if value is not None: @@ -412,7 +412,7 @@ def measurement_equipment(self) -> str | None: return self._measurement_equipment @measurement_equipment.setter - def measurement_equipment(self, value: str | None): + def measurement_equipment(self, value: str | None) -> None: """Setter for the **self.measurement_equipment** property.""" if value is not None: @@ -442,7 +442,7 @@ def laboratory(self) -> str | None: return self._laboratory @laboratory.setter - def laboratory(self, value: str | None): + def laboratory(self, value: str | None) -> None: """Setter for the **self.measurement_equipment** property.""" if value is not None: @@ -472,7 +472,7 @@ def report_number(self) -> str | None: return self._report_number @report_number.setter - def report_number(self, value: str | None): + def report_number(self, value: str | None) -> None: """Setter for the **self.report_number** property.""" if value is not None: @@ -502,7 +502,7 @@ def report_date(self) -> str | None: return self._report_date @report_date.setter - def report_date(self, value: str | None): + def report_date(self, value: str | None) -> None: """Setter for the **self.report_date** property.""" if value is not None: @@ -532,7 +532,7 @@ def document_creation_date(self) -> str | None: return self._document_creation_date @document_creation_date.setter - def document_creation_date(self, value: str | None): + def document_creation_date(self, value: str | None) -> None: """Setter for the **self.document_creation_date** property.""" if value is not None: @@ -562,7 +562,7 @@ def comments(self) -> str | None: return self._comments @comments.setter - def comments(self, value: str | None): + def comments(self, value: str | None) -> None: """Setter for the **self.comments** property.""" if value is not None: @@ -908,7 +908,7 @@ def __init__( ) = None, bandwidth_FWHM: float | None = None, bandwidth_corrected: bool | None = None, - **kwargs, + **kwargs: Any, ) -> None: super().__init__(**kwargs) @@ -1031,7 +1031,7 @@ def path(self) -> str | None: return self._path @path.setter - def path(self, value: str | Path | None): + def path(self, value: str | Path | None) -> None: """Setter for the **self.path** property.""" if value is not None: @@ -1063,7 +1063,7 @@ def header(self) -> Header_IESTM2714: return self._header @header.setter - def header(self, value: Header_IESTM2714): + def header(self, value: Header_IESTM2714) -> None: """Setter for the **self.header** property.""" attest( @@ -1129,7 +1129,7 @@ def spectral_quantity( ] | None ), - ): + ) -> None: """Setter for the **self.spectral_quantity** property.""" if value is not None: @@ -1196,7 +1196,7 @@ def reflection_geometry( ] | None ), - ): + ) -> None: """Setter for the **self.reflection_geometry** property.""" if value is not None: @@ -1231,7 +1231,7 @@ def transmission_geometry( def transmission_geometry( self, value: (Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] | None), - ): + ) -> None: """Setter for the **self.transmission_geometry** property.""" if value is not None: @@ -1261,7 +1261,7 @@ def bandwidth_FWHM(self) -> float | None: return self._bandwidth_FWHM @bandwidth_FWHM.setter - def bandwidth_FWHM(self, value: float | None): + def bandwidth_FWHM(self, value: float | None) -> None: """Setter for the **self.bandwidth_FWHM** property.""" if value is not None: @@ -1294,7 +1294,7 @@ def bandwidth_corrected(self) -> bool | None: return self._bandwidth_corrected @bandwidth_corrected.setter - def bandwidth_corrected(self, value: bool | None): + def bandwidth_corrected(self, value: bool | None) -> None: """Setter for the **self.bandwidth_corrected** property.""" if value is not None: diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index 3fec11323..649e5f80b 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -291,7 +291,7 @@ def uv_to_Luv( illuminant: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ "D65" ], - L: NDArrayFloat = np.array(100), + L: ArrayLike = np.array(100), ) -> NDArrayFloat: """ Return the *CIE L\\*u\\*v\\** colourspace array from given :math:`uv^p` diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index d568d5120..82a999363 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -195,7 +195,7 @@ def UCS_to_uv(UVW: ArrayLike) -> NDArrayFloat: return uv -def uv_to_UCS(uv: ArrayLike, V: NDArrayFloat = np.array(1)) -> NDArrayFloat: +def uv_to_UCS(uv: ArrayLike, V: ArrayLike = np.array(1)) -> NDArrayFloat: """ Return the *CIE 1960 UCS* :math:`UVW` colourspace array from given *uv* chromaticity coordinates. diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index b6c7b7d74..525a1ca3f 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -203,7 +203,7 @@ def xyY_to_xy(xyY: ArrayLike) -> NDArrayFloat: return xy -def xy_to_xyY(xy: ArrayLike, Y: NDArrayFloat = np.array(1)) -> NDArrayFloat: +def xy_to_xyY(xy: ArrayLike, Y: ArrayLike = np.array(1)) -> NDArrayFloat: """ Convert from *CIE xy* chromaticity coordinates to *CIE xyY* colourspace by extending the array last dimension with given :math:`Y` *luminance*. diff --git a/colour/models/hunter_lab.py b/colour/models/hunter_lab.py index 392584b8a..d9637ca35 100644 --- a/colour/models/hunter_lab.py +++ b/colour/models/hunter_lab.py @@ -83,9 +83,9 @@ def XYZ_to_Hunter_Lab( XYZ_n: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ "D65" ].XYZ_n, - K_ab: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ - "D65" - ].K_ab, + K_ab: ArrayLike | None = TVS_ILLUMINANTS_HUNTERLAB[ + "CIE 1931 2 Degree Standard Observer" + ]["D65"].K_ab, ) -> NDArrayFloat: """ Convert from *CIE XYZ* tristimulus values to *Hunter L,a,b* colour scale. @@ -161,9 +161,9 @@ def Hunter_Lab_to_XYZ( XYZ_n: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ "D65" ].XYZ_n, - K_ab: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ - "D65" - ].K_ab, + K_ab: ArrayLike | None = TVS_ILLUMINANTS_HUNTERLAB[ + "CIE 1931 2 Degree Standard Observer" + ]["D65"].K_ab, ) -> NDArrayFloat: """ Convert from *Hunter L,a,b* colour scale to *CIE XYZ* tristimulus values. diff --git a/colour/models/hunter_rdab.py b/colour/models/hunter_rdab.py index 35f20a01f..c818da467 100644 --- a/colour/models/hunter_rdab.py +++ b/colour/models/hunter_rdab.py @@ -40,9 +40,9 @@ def XYZ_to_Hunter_Rdab( XYZ_n: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ "D65" ].XYZ_n, - K_ab: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ - "D65" - ].K_ab, + K_ab: ArrayLike | None = TVS_ILLUMINANTS_HUNTERLAB[ + "CIE 1931 2 Degree Standard Observer" + ]["D65"].K_ab, ) -> NDArrayFloat: """ Convert from *CIE XYZ* tristimulus values to *Hunter Rd,a,b* colour scale. @@ -120,9 +120,9 @@ def Hunter_Rdab_to_XYZ( XYZ_n: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ "D65" ].XYZ_n, - K_ab: ArrayLike = TVS_ILLUMINANTS_HUNTERLAB["CIE 1931 2 Degree Standard Observer"][ - "D65" - ].K_ab, + K_ab: ArrayLike | None = TVS_ILLUMINANTS_HUNTERLAB[ + "CIE 1931 2 Degree Standard Observer" + ]["D65"].K_ab, ) -> NDArrayFloat: """ Convert from *Hunter Rd,a,b* colour scale to *CIE XYZ* tristimulus values. diff --git a/colour/models/rgb/datasets/tests/test__init__.py b/colour/models/rgb/datasets/tests/test__init__.py index 3baa44ca1..96ec47bca 100644 --- a/colour/models/rgb/datasets/tests/test__init__.py +++ b/colour/models/rgb/datasets/tests/test__init__.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.datasets` module.""" +from __future__ import annotations + import pickle from copy import deepcopy @@ -30,7 +32,7 @@ class TestRGB_COLOURSPACES: attribute unit tests methods. """ - def test_transformation_matrices(self): + def test_transformation_matrices(self) -> None: """ Test the transformations matrices from the :attr:`colour.models.rgb.datasets.RGB_COLOURSPACES` attribute @@ -73,7 +75,7 @@ def test_transformation_matrices(self): XYZ = np.dot(colourspace.matrix_RGB_to_XYZ, RGB) np.testing.assert_allclose(XYZ_r, XYZ, atol=tolerance) - def test_cctf(self): + def test_cctf(self) -> None: """ Test colour component transfer functions from the :attr:`colour.models.rgb.datasets.RGB_COLOURSPACES` attribute @@ -101,7 +103,7 @@ def test_cctf(self): atol=tolerance.get(colourspace.name, TOLERANCE_ABSOLUTE_TESTS), ) - def test_n_dimensional_cctf(self): + def test_n_dimensional_cctf(self) -> None: """ Test colour component transfer functions from the :attr:`colour.models.rgb.datasets.RGB_COLOURSPACES` attribute @@ -146,7 +148,7 @@ def test_n_dimensional_cctf(self): ) @ignore_numpy_errors - def test_nan_cctf(self): + def test_nan_cctf(self) -> None: """ Test colour component transfer functions from the :attr:`colour.models.rgb.datasets.RGB_COLOURSPACES` attribute @@ -158,7 +160,7 @@ def test_nan_cctf(self): colourspace.cctf_encoding(cases) colourspace.cctf_decoding(cases) - def test_pickle(self): + def test_pickle(self) -> None: """Test the "pickle-ability" of the *RGB* colourspaces.""" for colourspace in RGB_COLOURSPACES.values(): diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 0c8d26e33..14186ae17 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -400,7 +400,9 @@ def ICtCp_to_RGB( def XYZ_to_ICtCp( XYZ: ArrayLike, - illuminant=CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"], + illuminant: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ + "D65" + ], chromatic_adaptation_transform: ( LiteralChromaticAdaptationTransform | str | None ) = "CAT02", @@ -521,7 +523,9 @@ def XYZ_to_ICtCp( def ICtCp_to_XYZ( ICtCp: ArrayLike, - illuminant=CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"], + illuminant: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ + "D65" + ], chromatic_adaptation_transform: ( LiteralChromaticAdaptationTransform | str | None ) = "CAT02", diff --git a/colour/models/rgb/itut_h_273.py b/colour/models/rgb/itut_h_273.py index c54212c0b..96646b2a8 100644 --- a/colour/models/rgb/itut_h_273.py +++ b/colour/models/rgb/itut_h_273.py @@ -60,7 +60,7 @@ import numpy as np -from colour.hints import Any, Callable, Dict, NDArrayFloat +from colour.hints import Any, ArrayLike, Callable, Dict, NDArrayFloat, NoReturn from colour.models.rgb.datasets.dcdm_xyz import ( CCS_WHITEPOINT_DCDM_XYZ, MATRIX_DCDM_XYZ_TO_XYZ, @@ -208,7 +208,7 @@ def _clipped_domain_function( """ @functools.wraps(function) - def wrapped(x, *args: Any, **kwargs: Any) -> Any: + def wrapped(x: ArrayLike, *args: Any, **kwargs: Any) -> Any: """Wrap given function.""" return function(np.clip(x, *domain), *args, **kwargs) @@ -216,7 +216,7 @@ def wrapped(x, *args: Any, **kwargs: Any) -> Any: return wrapped -def _reserved(*args: Any): # noqa: ARG001 +def _reserved(*args: Any) -> NoReturn: # noqa: ARG001 """ Define a reserved function. @@ -231,7 +231,7 @@ def _reserved(*args: Any): # noqa: ARG001 raise RuntimeError("Reserved; For future use by ITU-T | ISO/IEC.") -def _unspecified(*args: Any): # noqa: ARG001 +def _unspecified(*args: Any) -> NoReturn: # noqa: ARG001 """ Define an unspecified function. @@ -887,7 +887,7 @@ class FFmpegConstantsMatrixCoefficients_ITUTH273(IntEnum): def describe_video_signal_colour_primaries( - code_point: int, print_description: bool = True, **kwargs + code_point: int, print_description: bool = True, **kwargs: Any ) -> str: """ Describe given video signal colour primaries code point. @@ -1043,7 +1043,7 @@ class SpecificationColourPrimaries: def describe_video_signal_transfer_characteristics( - code_point: int, print_description: bool = True, **kwargs + code_point: int, print_description: bool = True, **kwargs: Any ) -> str: """ Describe given video signal transfer characteristics code point. @@ -1167,7 +1167,7 @@ class SpecificationTransferCharacteristics: def describe_video_signal_matrix_coefficients( - code_point: int, print_description: bool = True, **kwargs + code_point: int, print_description: bool = True, **kwargs: Any ) -> str: """ Describe given video signal matrix coefficients code point. diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 88b4f5d72..06be42397 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -295,7 +295,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -324,7 +324,7 @@ def primaries(self) -> NDArrayFloat: return self._primaries @primaries.setter - def primaries(self, value: ArrayLike): + def primaries(self, value: ArrayLike) -> None: """Setter for the **self.primaries** property.""" attest( @@ -361,7 +361,7 @@ def whitepoint(self) -> NDArrayFloat: return self._whitepoint @whitepoint.setter - def whitepoint(self, value: ArrayLike): + def whitepoint(self, value: ArrayLike) -> None: """Setter for the **self.whitepoint** property.""" attest( @@ -395,7 +395,7 @@ def whitepoint_name(self) -> str | None: return self._whitepoint_name @whitepoint_name.setter - def whitepoint_name(self, value: str | None): + def whitepoint_name(self, value: str | None) -> None: """Setter for the **self.whitepoint_name** property.""" if value is not None: @@ -433,7 +433,7 @@ def matrix_RGB_to_XYZ(self) -> NDArrayFloat: return self._matrix_RGB_to_XYZ @matrix_RGB_to_XYZ.setter - def matrix_RGB_to_XYZ(self, value: ArrayLike | None): + def matrix_RGB_to_XYZ(self, value: ArrayLike | None) -> None: """Setter for the **self.matrix_RGB_to_XYZ** property.""" if value is not None: @@ -474,7 +474,7 @@ def matrix_XYZ_to_RGB(self) -> NDArrayFloat: return self._matrix_XYZ_to_RGB @matrix_XYZ_to_RGB.setter - def matrix_XYZ_to_RGB(self, value: ArrayLike | None): + def matrix_XYZ_to_RGB(self, value: ArrayLike | None) -> None: """Setter for the **self.matrix_XYZ_to_RGB** property.""" if value is not None: @@ -511,7 +511,7 @@ def cctf_encoding(self) -> Callable | None: return self._cctf_encoding @cctf_encoding.setter - def cctf_encoding(self, value: Callable | None): + def cctf_encoding(self, value: Callable | None) -> None: """Setter for the **self.cctf_encoding** property.""" if value is not None: @@ -545,7 +545,7 @@ def cctf_decoding(self) -> Callable | None: return self._cctf_decoding @cctf_decoding.setter - def cctf_decoding(self, value: Callable | None): + def cctf_decoding(self, value: Callable | None) -> None: """Setter for the **self.cctf_decoding** property.""" if value is not None: @@ -579,7 +579,7 @@ def use_derived_matrix_RGB_to_XYZ(self) -> bool: return self._use_derived_matrix_RGB_to_XYZ @use_derived_matrix_RGB_to_XYZ.setter - def use_derived_matrix_RGB_to_XYZ(self, value: bool): + def use_derived_matrix_RGB_to_XYZ(self, value: bool) -> None: """Setter for the **self.use_derived_matrix_RGB_to_XYZ** property.""" attest( @@ -614,7 +614,7 @@ def use_derived_matrix_XYZ_to_RGB(self) -> bool: return self._use_derived_matrix_XYZ_to_RGB @use_derived_matrix_XYZ_to_RGB.setter - def use_derived_matrix_XYZ_to_RGB(self, value: bool): + def use_derived_matrix_XYZ_to_RGB(self, value: bool) -> None: """Setter for the **self.use_derived_matrix_XYZ_to_RGB** property.""" attest( @@ -804,7 +804,7 @@ def __repr__(self) -> str: ], ) - def _derive_transformation_matrices(self): + def _derive_transformation_matrices(self) -> None: """ Compute the derived transformations matrices, the normalised primary matrix and its inverse. @@ -816,7 +816,7 @@ def _derive_transformation_matrices(self): self._derived_matrix_RGB_to_XYZ = npm self._derived_matrix_XYZ_to_RGB = np.linalg.inv(npm) - def use_derived_transformation_matrices(self, usage: bool = True): + def use_derived_transformation_matrices(self, usage: bool = True) -> None: """ Enable or disables usage of both derived transformations matrices, the normalised primary matrix and its inverse in subsequent @@ -1067,8 +1067,8 @@ def RGB_to_XYZ( LiteralChromaticAdaptationTransform | str | None ) = "CAT02", apply_cctf_decoding: bool = False, - *args, - **kwargs, + *args: Any, + **kwargs: Any, ) -> NDArrayFloat: """ Convert given *RGB* colourspace array to *CIE XYZ* tristimulus values. diff --git a/colour/models/rgb/tests/test_cmyk.py b/colour/models/rgb/tests/test_cmyk.py index 2745f0280..eb0f6a8e2 100644 --- a/colour/models/rgb/tests/test_cmyk.py +++ b/colour/models/rgb/tests/test_cmyk.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.cmyk` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestRGB_to_CMY: methods. """ - def test_RGB_to_CMY(self): + def test_RGB_to_CMY(self) -> None: """Test :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition.""" np.testing.assert_allclose( @@ -55,7 +57,7 @@ def test_RGB_to_CMY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_CMY(self): + def test_n_dimensional_RGB_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition n-dimensional arrays support. @@ -72,7 +74,7 @@ def test_n_dimensional_RGB_to_CMY(self): CMY = np.reshape(CMY, (2, 3, 3)) np.testing.assert_allclose(RGB_to_CMY(RGB), CMY, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_RGB_to_CMY(self): + def test_domain_range_scale_RGB_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition domain and range scale support. @@ -91,7 +93,7 @@ def test_domain_range_scale_RGB_to_CMY(self): ) @ignore_numpy_errors - def test_nan_RGB_to_CMY(self): + def test_nan_RGB_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.RGB_to_CMY` definition nan support. @@ -108,7 +110,7 @@ class TestCMY_to_RGB: methods. """ - def test_CMY_to_RGB(self): + def test_CMY_to_RGB(self) -> None: """Test :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition.""" np.testing.assert_allclose( @@ -129,7 +131,7 @@ def test_CMY_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CMY_to_RGB(self): + def test_n_dimensional_CMY_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition n-dimensional arrays support. @@ -146,7 +148,7 @@ def test_n_dimensional_CMY_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(CMY_to_RGB(CMY), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_CMY_to_RGB(self): + def test_domain_range_scale_CMY_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition domain and range scale support. @@ -165,7 +167,7 @@ def test_domain_range_scale_CMY_to_RGB(self): ) @ignore_numpy_errors - def test_nan_CMY_to_RGB(self): + def test_nan_CMY_to_RGB(self) -> None: """Test :func:`colour.models.rgb.cmyk.CMY_to_RGB` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -179,7 +181,7 @@ class TestCMY_to_CMYK: methods. """ - def test_CMY_to_CMYK(self): + def test_CMY_to_CMYK(self) -> None: """Test :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition.""" np.testing.assert_allclose( @@ -200,7 +202,7 @@ def test_CMY_to_CMYK(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CMY_to_CMYK(self): + def test_n_dimensional_CMY_to_CMYK(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition n-dimensional arrays support. @@ -221,7 +223,7 @@ def test_n_dimensional_CMY_to_CMYK(self): CMY_to_CMYK(CMY), CMYK, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_CMY_to_CMYK(self): + def test_domain_range_scale_CMY_to_CMYK(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition domain and range scale support. @@ -240,7 +242,7 @@ def test_domain_range_scale_CMY_to_CMYK(self): ) @ignore_numpy_errors - def test_nan_CMY_to_CMYK(self): + def test_nan_CMY_to_CMYK(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMY_to_CMYK` definition nan support. @@ -257,7 +259,7 @@ class TestCMYK_to_CMY: methods. """ - def test_CMYK_to_CMY(self): + def test_CMYK_to_CMY(self) -> None: """Test :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition.""" np.testing.assert_allclose( @@ -278,7 +280,7 @@ def test_CMYK_to_CMY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CMYK_to_CMY(self): + def test_n_dimensional_CMYK_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition n-dimensional arrays support. @@ -299,7 +301,7 @@ def test_n_dimensional_CMYK_to_CMY(self): CMYK_to_CMY(CMYK), CMY, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_CMYK_to_CMY(self): + def test_domain_range_scale_CMYK_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition domain and range scale support. @@ -318,7 +320,7 @@ def test_domain_range_scale_CMYK_to_CMY(self): ) @ignore_numpy_errors - def test_nan_CMYK_to_CMY(self): + def test_nan_CMYK_to_CMY(self) -> None: """ Test :func:`colour.models.rgb.cmyk.CMYK_to_CMY` definition nan support. diff --git a/colour/models/rgb/tests/test_common.py b/colour/models/rgb/tests/test_common.py index e80a91834..667a43a5c 100644 --- a/colour/models/rgb/tests/test_common.py +++ b/colour/models/rgb/tests/test_common.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.common` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -24,7 +26,7 @@ class TestXYZ_to_sRGB: methods. """ - def test_XYZ_to_sRGB(self): + def test_XYZ_to_sRGB(self) -> None: """Test :func:`colour.models.rgb.common.XYZ_to_sRGB` definition.""" np.testing.assert_allclose( @@ -83,7 +85,7 @@ class TestsRGB_to_XYZ: methods. """ - def test_sRGB_to_XYZ(self): + def test_sRGB_to_XYZ(self) -> None: """Test :func:`colour.models.rgb.common.sRGB_to_XYZ` definition.""" np.testing.assert_allclose( diff --git a/colour/models/rgb/tests/test_cylindrical.py b/colour/models/rgb/tests/test_cylindrical.py index 4cee31734..2373776b4 100644 --- a/colour/models/rgb/tests/test_cylindrical.py +++ b/colour/models/rgb/tests/test_cylindrical.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.cylindrical` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -38,7 +40,7 @@ class TestRGB_to_HSV: tests methods. """ - def test_RGB_to_HSV(self): + def test_RGB_to_HSV(self) -> None: """Test :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition.""" np.testing.assert_allclose( @@ -65,7 +67,7 @@ def test_RGB_to_HSV(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_HSV(self): + def test_n_dimensional_RGB_to_HSV(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition n-dimensional arrays support. @@ -82,7 +84,7 @@ def test_n_dimensional_RGB_to_HSV(self): HSV = np.reshape(HSV, (2, 3, 3)) np.testing.assert_allclose(RGB_to_HSV(RGB), HSV, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_RGB_to_HSV(self): + def test_domain_range_scale_RGB_to_HSV(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition domain and range scale support. @@ -101,7 +103,7 @@ def test_domain_range_scale_RGB_to_HSV(self): ) @ignore_numpy_errors - def test_nan_RGB_to_HSV(self): + def test_nan_RGB_to_HSV(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSV` definition nan support. @@ -118,7 +120,7 @@ class TestHSV_to_RGB: tests methods. """ - def test_HSV_to_RGB(self): + def test_HSV_to_RGB(self) -> None: """Test :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition.""" np.testing.assert_allclose( @@ -145,7 +147,7 @@ def test_HSV_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_HSV_to_RGB(self): + def test_n_dimensional_HSV_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition n-dimensional arrays support. @@ -162,7 +164,7 @@ def test_n_dimensional_HSV_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(HSV_to_RGB(HSV), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_HSV_to_RGB(self): + def test_domain_range_scale_HSV_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition domain and range scale support. @@ -181,7 +183,7 @@ def test_domain_range_scale_HSV_to_RGB(self): ) @ignore_numpy_errors - def test_nan_HSV_to_RGB(self): + def test_nan_HSV_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSV_to_RGB` definition nan support. @@ -198,7 +200,7 @@ class TestRGB_to_HSL: tests methods. """ - def test_RGB_to_HSL(self): + def test_RGB_to_HSL(self) -> None: """Test :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition.""" np.testing.assert_allclose( @@ -225,7 +227,7 @@ def test_RGB_to_HSL(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_HSL(self): + def test_n_dimensional_RGB_to_HSL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition n-dimensional arrays support. @@ -242,7 +244,7 @@ def test_n_dimensional_RGB_to_HSL(self): HSL = np.reshape(HSL, (2, 3, 3)) np.testing.assert_allclose(RGB_to_HSL(RGB), HSL, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_RGB_to_HSL(self): + def test_domain_range_scale_RGB_to_HSL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition domain and range scale support. @@ -261,7 +263,7 @@ def test_domain_range_scale_RGB_to_HSL(self): ) @ignore_numpy_errors - def test_nan_RGB_to_HSL(self): + def test_nan_RGB_to_HSL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HSL` definition nan support. @@ -278,7 +280,7 @@ class TestHSL_to_RGB: tests methods. """ - def test_HSL_to_RGB(self): + def test_HSL_to_RGB(self) -> None: """Test :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition.""" np.testing.assert_allclose( @@ -305,7 +307,7 @@ def test_HSL_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_HSL_to_RGB(self): + def test_n_dimensional_HSL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition n-dimensional arrays support. @@ -322,7 +324,7 @@ def test_n_dimensional_HSL_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(HSL_to_RGB(HSL), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_HSL_to_RGB(self): + def test_domain_range_scale_HSL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition domain and range scale support. @@ -341,7 +343,7 @@ def test_domain_range_scale_HSL_to_RGB(self): ) @ignore_numpy_errors - def test_nan_HSL_to_RGB(self): + def test_nan_HSL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HSL_to_RGB` definition nan support. @@ -358,7 +360,7 @@ class TestRGB_to_HCL: tests methods. """ - def test_RGB_to_HCL(self): + def test_RGB_to_HCL(self) -> None: """Test :func:`colour.models.rgb.cylindrical.RGB_to_HCL` definition.""" np.testing.assert_allclose( @@ -385,7 +387,7 @@ def test_RGB_to_HCL(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_HCL(self): + def test_n_dimensional_RGB_to_HCL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HCL` definition n-dimensional arrays support. @@ -402,7 +404,7 @@ def test_n_dimensional_RGB_to_HCL(self): HCL = np.reshape(HCL, (2, 3, 3)) np.testing.assert_allclose(RGB_to_HCL(RGB), HCL, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_RGB_to_HCL(self): + def test_domain_range_scale_RGB_to_HCL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HCL` definition domain and range scale support. @@ -421,7 +423,7 @@ def test_domain_range_scale_RGB_to_HCL(self): ) @ignore_numpy_errors - def test_nan_RGB_to_HCL(self): + def test_nan_RGB_to_HCL(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.RGB_to_HCL` definition nan support. @@ -438,7 +440,7 @@ class TestHCL_to_RGB: tests methods. """ - def test_HCL_to_RGB(self): + def test_HCL_to_RGB(self) -> None: """Test :func:`colour.models.rgb.cylindrical.HCL_to_RGB` definition.""" np.testing.assert_allclose( @@ -465,7 +467,7 @@ def test_HCL_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_HCL_to_RGB(self): + def test_n_dimensional_HCL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HCL_to_RGB` definition n-dimensional arrays support. @@ -482,7 +484,7 @@ def test_n_dimensional_HCL_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(HCL_to_RGB(HCL), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_HCL_to_RGB(self): + def test_domain_range_scale_HCL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HCL_to_RGB` definition domain and range scale support. @@ -501,7 +503,7 @@ def test_domain_range_scale_HCL_to_RGB(self): ) @ignore_numpy_errors - def test_nan_HCL_to_RGB(self): + def test_nan_HCL_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.cylindrical.HCL_to_RGB` definition nan support. diff --git a/colour/models/rgb/tests/test_derivation.py b/colour/models/rgb/tests/test_derivation.py index 07a2c9ece..5a50b6abd 100644 --- a/colour/models/rgb/tests/test_derivation.py +++ b/colour/models/rgb/tests/test_derivation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.derivation` module.""" +from __future__ import annotations + import contextlib import re from itertools import product @@ -41,7 +43,7 @@ class Testxy_to_z: tests methods. """ - def test_xy_to_z(self): + def test_xy_to_z(self) -> None: """Test :func:`colour.models.rgb.derivation.xy_to_z` definition.""" np.testing.assert_allclose( @@ -62,7 +64,7 @@ def test_xy_to_z(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_z(self): + def test_n_dimensional_xy_to_z(self) -> None: """ Test :func:`colour.models.rgb.derivation.xy_to_z` definition n-dimensional arrays support. @@ -83,7 +85,7 @@ def test_n_dimensional_xy_to_z(self): np.testing.assert_allclose(xy_to_z(xy), z, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_xy_to_z(self): + def test_nan_xy_to_z(self) -> None: """ Test :func:`colour.models.rgb.derivation.xy_to_z` definition nan support. @@ -100,7 +102,7 @@ class TestNormalisedPrimaryMatrix: definition unit tests methods. """ - def test_normalised_primary_matrix(self): + def test_normalised_primary_matrix(self) -> None: """ Test :func:`colour.models.rgb.derivation.normalised_primary_matrix` definition. @@ -137,7 +139,7 @@ def test_normalised_primary_matrix(self): ) @ignore_numpy_errors - def test_nan_normalised_primary_matrix(self): + def test_nan_normalised_primary_matrix(self) -> None: """ Test :func:`colour.models.rgb.derivation.normalised_primary_matrix` definition nan support. @@ -158,7 +160,7 @@ class TestChromaticallyAdaptedPrimaries: chromatically_adapted_primaries` definition unit tests methods. """ - def test_chromatically_adapted_primaries(self): + def test_chromatically_adapted_primaries(self) -> None: """ Test :func:`colour.models.rgb.derivation.\ chromatically_adapted_primaries` definition. @@ -214,7 +216,7 @@ def test_chromatically_adapted_primaries(self): ) @ignore_numpy_errors - def test_nan_chromatically_adapted_primaries(self): + def test_nan_chromatically_adapted_primaries(self) -> None: """ Test :func:`colour.models.rgb.derivation.\ chromatically_adapted_primaries` definition nan support. @@ -234,7 +236,7 @@ class TestPrimariesWhitepoint: definition unit tests methods. """ - def test_primaries_whitepoint(self): + def test_primaries_whitepoint(self) -> None: """ Test :func:`colour.models.rgb.derivation.primaries_whitepoint` definition. @@ -291,7 +293,7 @@ def test_primaries_whitepoint(self): ) @ignore_numpy_errors - def test_nan_primaries_whitepoint(self): + def test_nan_primaries_whitepoint(self) -> None: """ Test :func:`colour.models.rgb.derivation.primaries_whitepoint` definition nan support. @@ -310,7 +312,7 @@ class TestRGBLuminanceEquation: definition unit tests methods. """ - def test_RGB_luminance_equation(self): + def test_RGB_luminance_equation(self) -> None: """ Test :func:`colour.models.rgb.derivation.RGB_luminance_equation` definition. @@ -344,7 +346,7 @@ class TestRGBLuminance: unit tests methods. """ - def test_RGB_luminance(self): + def test_RGB_luminance(self) -> None: """ Test :func:`colour.models.rgb.derivation.RGB_luminance` definition. @@ -380,7 +382,7 @@ def test_RGB_luminance(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_luminance(self): + def test_n_dimensional_RGB_luminance(self) -> None: """ Test :func:`colour.models.rgb.derivation.RGB_luminance` definition n_dimensional arrays support. @@ -404,7 +406,7 @@ def test_n_dimensional_RGB_luminance(self): ) @ignore_numpy_errors - def test_nan_RGB_luminance(self): + def test_nan_RGB_luminance(self) -> None: """ Test :func:`colour.models.rgb.derivation.RGB_luminance` definition nan support. diff --git a/colour/models/rgb/tests/test_hanbury2003.py b/colour/models/rgb/tests/test_hanbury2003.py index 4b99607b0..7490cb9a2 100644 --- a/colour/models/rgb/tests/test_hanbury2003.py +++ b/colour/models/rgb/tests/test_hanbury2003.py @@ -1,5 +1,7 @@ """Defines unit tests for :mod:`colour.models.rgb.hanbury2003` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestRGB_to_IHLS: tests methods. """ - def test_RGB_to_IHLS(self): + def test_RGB_to_IHLS(self) -> None: """Test :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition.""" np.testing.assert_allclose( @@ -48,7 +50,7 @@ def test_RGB_to_IHLS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_IHLS(self): + def test_n_dimensional_RGB_to_IHLS(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition n-dimensional arrays support. @@ -65,7 +67,7 @@ def test_n_dimensional_RGB_to_IHLS(self): HYS = np.reshape(HYS, (2, 3, 3)) np.testing.assert_allclose(RGB_to_IHLS(RGB), HYS, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_RGB_to_IHLS(self): + def test_domain_range_scale_RGB_to_IHLS(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition domain and range scale support. @@ -84,7 +86,7 @@ def test_domain_range_scale_RGB_to_IHLS(self): ) @ignore_numpy_errors - def test_nan_RGB_to_IHLS(self): + def test_nan_RGB_to_IHLS(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.RGB_to_IHLS` definition nan support. @@ -101,7 +103,7 @@ class TestIHLS_to_RGB: tests methods. """ - def test_IHLS_to_RGB(self): + def test_IHLS_to_RGB(self) -> None: """Test :func:`colour.models.rgb.hanbury2003.IHLS_to_RGB` definition.""" np.testing.assert_allclose( @@ -122,7 +124,7 @@ def test_IHLS_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_IHLS_to_RGB(self): + def test_n_dimensional_IHLS_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.IHLS_to_RGB` definition n-dimensional arrays support. @@ -139,7 +141,7 @@ def test_n_dimensional_IHLS_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(IHLS_to_RGB(HYS), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_IHLS_to_RGB(self): + def test_domain_range_scale_IHLS_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.IHLS_to_RGB` definition domain and range scale support. @@ -158,7 +160,7 @@ def test_domain_range_scale_IHLS_to_RGB(self): ) @ignore_numpy_errors - def test_nan_IHLS_to_RGB(self): + def test_nan_IHLS_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.hanbury2003.IHLS_to_RGB` definition nan support. diff --git a/colour/models/rgb/tests/test_ictcp.py b/colour/models/rgb/tests/test_ictcp.py index 034752ed2..926680bc7 100644 --- a/colour/models/rgb/tests/test_ictcp.py +++ b/colour/models/rgb/tests/test_ictcp.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.ictcp` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestRGB_to_ICtCp: tests methods. """ - def test_RGB_to_ICtCp(self): + def test_RGB_to_ICtCp(self) -> None: """Test :func:`colour.models.rgb.ictcp.RGB_to_ICtCp` definition.""" np.testing.assert_allclose( @@ -91,7 +93,7 @@ def test_RGB_to_ICtCp(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_ICtCp(self): + def test_n_dimensional_RGB_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.RGB_to_ICtCp` definition n-dimensional support. @@ -112,7 +114,7 @@ def test_n_dimensional_RGB_to_ICtCp(self): RGB_to_ICtCp(RGB), ICtCp, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_RGB_to_ICtCp(self): + def test_domain_range_scale_RGB_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.RGB_to_ICtCp` definition domain and range scale support. @@ -131,7 +133,7 @@ def test_domain_range_scale_RGB_to_ICtCp(self): ) @ignore_numpy_errors - def test_nan_RGB_to_ICtCp(self): + def test_nan_RGB_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.RGB_to_ICtCp` definition nan support. @@ -148,7 +150,7 @@ class TestICtCp_to_RGB: methods. """ - def test_ICtCp_to_RGB(self): + def test_ICtCp_to_RGB(self) -> None: """Test :func:`colour.models.rgb.ictcp.ICtCp_to_RGB` definition.""" np.testing.assert_allclose( @@ -205,7 +207,7 @@ def test_ICtCp_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ICtCp_to_RGB(self): + def test_n_dimensional_ICtCp_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_RGB` definition n-dimensional support. @@ -226,7 +228,7 @@ def test_n_dimensional_ICtCp_to_RGB(self): ICtCp_to_RGB(ICtCp), RGB, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ICtCp_to_RGB(self): + def test_domain_range_scale_ICtCp_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_RGB` definition domain and range scale support. @@ -245,7 +247,7 @@ def test_domain_range_scale_ICtCp_to_RGB(self): ) @ignore_numpy_errors - def test_nan_ICtCp_to_RGB(self): + def test_nan_ICtCp_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_RGB` definition nan support. @@ -262,7 +264,7 @@ class TestXYZ_to_ICtCp: tests methods. """ - def test_XYZ_to_ICtCp(self): + def test_XYZ_to_ICtCp(self) -> None: """Test :func:`colour.models.rgb.ictcp.XYZ_to_ICtCp` definition.""" np.testing.assert_allclose( @@ -338,7 +340,7 @@ def test_XYZ_to_ICtCp(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_ICtCp(self): + def test_n_dimensional_XYZ_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.XYZ_to_ICtCp` definition n-dimensional support. @@ -359,7 +361,7 @@ def test_n_dimensional_XYZ_to_ICtCp(self): XYZ_to_ICtCp(XYZ), ICtCp, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_ICtCp(self): + def test_domain_range_scale_XYZ_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.XYZ_to_ICtCp` definition domain and range scale support. @@ -378,7 +380,7 @@ def test_domain_range_scale_XYZ_to_ICtCp(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_ICtCp(self): + def test_nan_XYZ_to_ICtCp(self) -> None: """ Test :func:`colour.models.rgb.ictcp.XYZ_to_ICtCp` definition nan support. @@ -395,7 +397,7 @@ class TestICtCp_to_XYZ: methods. """ - def test_ICtCp_to_XYZ(self): + def test_ICtCp_to_XYZ(self) -> None: """Test :func:`colour.models.rgb.ictcp.ICtCp_to_XYZ` definition.""" np.testing.assert_allclose( @@ -471,7 +473,7 @@ def test_ICtCp_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ICtCp_to_XYZ(self): + def test_n_dimensional_ICtCp_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_XYZ` definition n-dimensional support. @@ -492,7 +494,7 @@ def test_n_dimensional_ICtCp_to_XYZ(self): ICtCp_to_XYZ(ICtCp), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ICtCp_to_XYZ(self): + def test_domain_range_scale_ICtCp_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_XYZ` definition domain and range scale support. @@ -511,7 +513,7 @@ def test_domain_range_scale_ICtCp_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_ICtCp_to_XYZ(self): + def test_nan_ICtCp_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.ictcp.ICtCp_to_XYZ` definition nan support. diff --git a/colour/models/rgb/tests/test_itut_h_273.py b/colour/models/rgb/tests/test_itut_h_273.py index 33efe82e3..660fce04c 100644 --- a/colour/models/rgb/tests/test_itut_h_273.py +++ b/colour/models/rgb/tests/test_itut_h_273.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.itut_h_273` module.""" +from __future__ import annotations + from colour.models import ( describe_video_signal_colour_primaries, describe_video_signal_matrix_coefficients, @@ -26,7 +28,7 @@ class TestDescribeVideoSignalColourPrimaries: describe_video_signal_colour_primaries` definition unit tests methods. """ - def test_describe_video_signal_colour_primaries(self): + def test_describe_video_signal_colour_primaries(self) -> None: """ Test :func:`colour.models.rgb.itut_h_273.\ @@ -43,7 +45,7 @@ class TestDescribeVideoSignalTransferCharacteristics: describe_video_signal_transfer_characteristics` definition unit tests methods. """ - def test_describe_video_signal_transfer_characteristics(self): + def test_describe_video_signal_transfer_characteristics(self) -> None: """ Test :func:`colour.models.rgb.itut_h_273.\ describe_video_signal_transfer_characteristics` definition. @@ -59,7 +61,7 @@ class TestDescribeVideoSignalMatrixCoefficients: describe_video_signal_matrix_coefficients` definition unit tests methods. """ - def test_describe_video_signal_matrix_coefficients(self): + def test_describe_video_signal_matrix_coefficients(self) -> None: """ Test :func:`colour.models.rgb.itut_h_273.\ describe_video_signal_matrix_coefficients` definition. diff --git a/colour/models/rgb/tests/test_prismatic.py b/colour/models/rgb/tests/test_prismatic.py index d434a9493..339bb4baa 100644 --- a/colour/models/rgb/tests/test_prismatic.py +++ b/colour/models/rgb/tests/test_prismatic.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.prismatic` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestRGB_to_Prismatic: unit tests methods. """ - def test_RGB_to_Prismatic(self): + def test_RGB_to_Prismatic(self) -> None: """Test :func:`colour.models.rgb.prismatic.RGB_to_Prismatic` definition.""" np.testing.assert_allclose( @@ -42,7 +44,7 @@ def test_RGB_to_Prismatic(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_Prismatic(self): + def test_n_dimensional_RGB_to_Prismatic(self) -> None: """ Test :func:`colour.models.rgb.prismatic.RGB_to_Prismatic` definition n-dimensional support. @@ -63,7 +65,7 @@ def test_n_dimensional_RGB_to_Prismatic(self): RGB_to_Prismatic(RGB), Lrgb, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_RGB_to_Prismatic(self): + def test_domain_range_scale_RGB_to_Prismatic(self) -> None: """ Test :func:`colour.models.rgb.prismatic.RGB_to_Prismatic` definition domain and range scale support. @@ -82,7 +84,7 @@ def test_domain_range_scale_RGB_to_Prismatic(self): ) @ignore_numpy_errors - def test_nan_RGB_to_Prismatic(self): + def test_nan_RGB_to_Prismatic(self) -> None: """ Test :func:`colour.models.rgb.prismatic.RGB_to_Prismatic` definition nan support. @@ -99,7 +101,7 @@ class TestPrismatic_to_RGB: unit tests methods. """ - def test_Prismatic_to_RGB(self): + def test_Prismatic_to_RGB(self) -> None: """Test :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition.""" np.testing.assert_allclose( @@ -114,7 +116,7 @@ def test_Prismatic_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Prismatic_to_RGB(self): + def test_n_dimensional_Prismatic_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition n-dimensional support. @@ -135,7 +137,7 @@ def test_n_dimensional_Prismatic_to_RGB(self): Prismatic_to_RGB(Lrgb), RGB, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Prismatic_to_RGB(self): + def test_domain_range_scale_Prismatic_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition domain and range scale support. @@ -154,7 +156,7 @@ def test_domain_range_scale_Prismatic_to_RGB(self): ) @ignore_numpy_errors - def test_nan_Prismatic_to_RGB(self): + def test_nan_Prismatic_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.prismatic.Prismatic_to_RGB` definition nan support. diff --git a/colour/models/rgb/tests/test_rgb_colourspace.py b/colour/models/rgb/tests/test_rgb_colourspace.py index d0cfc1d09..7415f2e21 100644 --- a/colour/models/rgb/tests/test_rgb_colourspace.py +++ b/colour/models/rgb/tests/test_rgb_colourspace.py @@ -2,6 +2,8 @@ Define the unit tests for the :mod:`colour.models.rgb.rgb_colourspace` module. """ +from __future__ import annotations + import re import textwrap from itertools import product @@ -48,7 +50,7 @@ class TestRGB_Colourspace: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" p = np.array([0.73470, 0.26530, 0.00000, 1.00000, 0.00010, -0.07700]) @@ -66,7 +68,7 @@ def setup_method(self): linear_function, ) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -85,7 +87,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(RGB_Colourspace) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -100,7 +102,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(RGB_Colourspace) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.__str__` method. @@ -137,7 +139,7 @@ def test__str__(self): ).strip() ) - def test__repr__(self): + def test__repr__(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\ __repr__` method. @@ -166,7 +168,7 @@ def test__repr__(self): ).strip() ) - def test_use_derived_transformation_matrices(self): + def test_use_derived_transformation_matrices(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\ use_derived_transformation_matrices` method. @@ -213,7 +215,7 @@ def test_use_derived_transformation_matrices(self): self._colourspace.matrix_XYZ_to_RGB, np.identity(3) ) - def test_chromatically_adapt(self): + def test_chromatically_adapt(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.\ chromatically_adapt` method. @@ -266,7 +268,7 @@ def test_chromatically_adapt(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_copy(self): + def test_copy(self) -> None: """ Test :meth:`colour.models.rgb.rgb_colourspace.RGB_Colourspace.copy` method. @@ -281,7 +283,7 @@ class TestXYZ_to_RGB: unit tests methods. """ - def test_XYZ_to_RGB(self): + def test_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition. @@ -338,50 +340,50 @@ def test_XYZ_to_RGB(self): ) # TODO: Remove tests when dropping deprecated signature support. - np.testing.assert_allclose( - XYZ_to_RGB( + np.testing.assert_allclose( # pyright: ignore + XYZ_to_RGB( # pyright: ignore np.array([0.21638819, 0.12570000, 0.03847493]), - np.array([0.34570, 0.35850]), + np.array([0.34570, 0.35850]), # pyright: ignore np.array([0.31270, 0.32900]), - np.array( + np.array( # pyright: ignore [ [3.24062548, -1.53720797, -0.49862860], [-0.96893071, 1.87575606, 0.04151752], [0.05571012, -0.20402105, 1.05699594], ] ), - "Bradford", + "Bradford", # pyright: ignore eotf_inverse_sRGB, ), np.array([0.70556599, 0.19109268, 0.22340812]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - XYZ_to_RGB( + np.testing.assert_allclose( # pyright: ignore + XYZ_to_RGB( # pyright: ignore np.array([0.21638819, 0.12570000, 0.03847493]), - np.array([0.34570, 0.35850]), + np.array([0.34570, 0.35850]), # pyright: ignore np.array([0.31270, 0.32900]), - np.array( + np.array( # pyright: ignore [ [3.24062548, -1.53720797, -0.49862860], [-0.96893071, 1.87575606, 0.04151752], [0.05571012, -0.20402105, 1.05699594], ] ), - None, + None, # pyright: ignore eotf_inverse_sRGB, ), np.array([0.72794579, 0.18180021, 0.17951580]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - XYZ_to_RGB( + np.testing.assert_allclose( # pyright: ignore + XYZ_to_RGB( # pyright: ignore np.array([0.21638819, 0.12570000, 0.03847493]), - np.array([0.34570, 0.35850]), + np.array([0.34570, 0.35850]), # pyright: ignore np.array([0.32168, 0.33767]), - np.array( + np.array( # pyright: ignore [ [1.04981102, 0.00000000, -0.00009748], [-0.49590302, 1.37331305, 0.09824004], @@ -393,12 +395,12 @@ def test_XYZ_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - XYZ_to_RGB( + np.testing.assert_allclose( # pyright: ignore + XYZ_to_RGB( # pyright: ignore np.array([0.21638819, 0.12570000, 0.03847493]), - np.array([0.34570, 0.35850]), + np.array([0.34570, 0.35850]), # pyright: ignore np.array([0.31270, 0.32900, 1.00000]), - np.array( + np.array( # pyright: ignore [ [3.24062548, -1.53720797, -0.49862860], [-0.96893071, 1.87575606, 0.04151752], @@ -410,7 +412,7 @@ def test_XYZ_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_RGB(self): + def test_n_dimensional_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition n-dimensional support. @@ -444,7 +446,7 @@ def test_n_dimensional_XYZ_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_RGB(self): + def test_domain_range_scale_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition domain and range scale support. @@ -464,7 +466,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_RGB(self): + def test_nan_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.XYZ_to_RGB` definition nan support. @@ -472,8 +474,7 @@ def test_nan_XYZ_to_RGB(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) - M = np.reshape(np.vstack([cases[0, ...], cases[0, ...], cases[0, ...]]), (3, 3)) - XYZ_to_RGB(cases, cases[..., 0:2], cases[..., 0:2], M) + XYZ_to_RGB(cases, "sRGB", cases[..., 0:2]) class TestRGB_to_XYZ: @@ -482,7 +483,7 @@ class TestRGB_to_XYZ: unit tests methods. """ - def test_RGB_to_XYZ(self): + def test_RGB_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition. @@ -539,50 +540,50 @@ def test_RGB_to_XYZ(self): ) # TODO: Remove tests when dropping deprecated signature support. - np.testing.assert_allclose( - RGB_to_XYZ( + np.testing.assert_allclose( # pyright: ignore + RGB_to_XYZ( # pyright: ignore np.array([0.70556599, 0.19109268, 0.22340812]), - np.array([0.31270, 0.32900]), + np.array([0.31270, 0.32900]), # pyright: ignore np.array([0.34570, 0.35850]), - np.array( + np.array( # pyright: ignore [ [0.41240000, 0.35760000, 0.18050000], [0.21260000, 0.71520000, 0.07220000], [0.01930000, 0.11920000, 0.95050000], ] ), - "Bradford", + "Bradford", # pyright: ignore eotf_sRGB, ), np.array([0.21638819, 0.12570000, 0.03847493]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - RGB_to_XYZ( + np.testing.assert_allclose( # pyright: ignore + RGB_to_XYZ( # pyright: ignore np.array([0.72794579, 0.18180021, 0.17951580]), - np.array([0.31270, 0.32900]), + np.array([0.31270, 0.32900]), # pyright: ignore np.array([0.34570, 0.35850]), - np.array( + np.array( # pyright: ignore [ [0.41240000, 0.35760000, 0.18050000], [0.21260000, 0.71520000, 0.07220000], [0.01930000, 0.11920000, 0.95050000], ] ), - None, + None, # pyright: ignore eotf_sRGB, ), np.array([0.21638819, 0.12570000, 0.03847493]), atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - RGB_to_XYZ( + np.testing.assert_allclose( # pyright: ignore + RGB_to_XYZ( # pyright: ignore np.array([0.21959099, 0.06985815, 0.04703704]), - np.array([0.32168, 0.33767]), + np.array([0.32168, 0.33767]), # pyright: ignore np.array([0.34570, 0.35850]), - np.array( + np.array( # pyright: ignore [ [0.95255240, 0.00000000, 0.00009368], [0.34396645, 0.72816610, -0.07213255], @@ -594,12 +595,12 @@ def test_RGB_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - np.testing.assert_allclose( - RGB_to_XYZ( + np.testing.assert_allclose( # pyright: ignore + RGB_to_XYZ( # pyright: ignore np.array([0.45620801, 0.03079991, 0.04091883]), - np.array([0.31270, 0.32900, 1.00000]), + np.array([0.31270, 0.32900, 1.00000]), # pyright: ignore np.array([0.34570, 0.35850]), - np.array( + np.array( # pyright: ignore [ [0.41240000, 0.35760000, 0.18050000], [0.21260000, 0.71520000, 0.07220000], @@ -611,7 +612,7 @@ def test_RGB_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_XYZ(self): + def test_n_dimensional_RGB_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition n-dimensional support. @@ -645,7 +646,7 @@ def test_n_dimensional_RGB_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_RGB(self): + def test_domain_range_scale_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition domain and range scale support. @@ -665,7 +666,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): ) @ignore_numpy_errors - def test_nan_RGB_to_XYZ(self): + def test_nan_RGB_to_XYZ(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_XYZ` definition nan support. @@ -673,8 +674,7 @@ def test_nan_RGB_to_XYZ(self): cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] cases = np.array(list(set(product(cases, repeat=3)))) - M = np.reshape(np.vstack([cases[0, ...], cases[0, ...], cases[0, ...]]), (3, 3)) - RGB_to_XYZ(cases, cases[..., 0:2], cases[..., 0:2], M) + RGB_to_XYZ(cases, "sRGB", cases[..., 0:2]) class TestMatrix_RGB_to_RGB: @@ -683,7 +683,7 @@ class TestMatrix_RGB_to_RGB: definition unit tests methods. """ - def test_matrix_RGB_to_RGB(self): + def test_matrix_RGB_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.matrix_RGB_to_RGB` definition. @@ -766,7 +766,7 @@ class TestRGB_to_RGB: unit tests methods. """ - def test_RGB_to_RGB(self): + def test_RGB_to_RGB(self) -> None: """Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_RGB` definition.""" aces_2065_1_colourspace = RGB_COLOURSPACES["ACES2065-1"] @@ -866,7 +866,7 @@ def test_RGB_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_RGB(self): + def test_n_dimensional_RGB_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_RGB` definition n-dimensional support. @@ -893,7 +893,7 @@ def test_n_dimensional_RGB_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_RGB(self): + def test_domain_range_scale_XYZ_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_RGB` definition domain and range scale support. @@ -918,7 +918,7 @@ def test_domain_range_scale_XYZ_to_RGB(self): ) @ignore_numpy_errors - def test_nan_RGB_to_RGB(self): + def test_nan_RGB_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.rgb_colourspace.RGB_to_RGB` definition nan support. diff --git a/colour/models/rgb/tests/test_ycbcr.py b/colour/models/rgb/tests/test_ycbcr.py index 4f471f1e1..f62ff5016 100644 --- a/colour/models/rgb/tests/test_ycbcr.py +++ b/colour/models/rgb/tests/test_ycbcr.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.ycbcr` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -43,7 +45,7 @@ class TestRoundBT2100: methods. """ - def test_round_BT2100(self): + def test_round_BT2100(self) -> None: """Test :func:`colour.models.rgb.ycbcr.round_BT2100` definition.""" np.testing.assert_array_equal( @@ -58,7 +60,7 @@ class TestRangeYCbCr: methods. """ - def test_ranges_YCbCr(self): + def test_ranges_YCbCr(self) -> None: """Test :func:`colour.models.rgb.ycbcr.ranges_YCbCr` definition.""" np.testing.assert_allclose( @@ -116,7 +118,7 @@ class TestMatrixYCbCr: methods. """ - def test_matrix_YCbCr(self): + def test_matrix_YCbCr(self) -> None: """Test :func:`colour.models.rgb.ycbcr.matrix_YCbCr` definition.""" np.testing.assert_allclose( @@ -186,7 +188,7 @@ class TestOffsetYCbCr: methods. """ - def test_offset_YCbCr(self): + def test_offset_YCbCr(self) -> None: """Test :func:`colour.models.rgb.ycbcr.offset_YCbCr` definition.""" np.testing.assert_allclose( @@ -220,7 +222,7 @@ class TestRGB_to_YCbCr: methods. """ - def test_RGB_to_YCbCr(self): + def test_RGB_to_YCbCr(self) -> None: """Test :func:`colour.models.rgb.ycbcr.RGB_to_YCbCr` definition.""" np.testing.assert_allclose( @@ -262,7 +264,7 @@ def test_RGB_to_YCbCr(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_YCbCr(self): + def test_n_dimensional_RGB_to_YCbCr(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.RGB_to_YCbCr` definition n-dimensional arrays support. @@ -289,7 +291,7 @@ def test_n_dimensional_RGB_to_YCbCr(self): YCbCr = np.reshape(YCbCr, (4, 4, 4, 3)) np.testing.assert_allclose(RGB_to_YCbCr(RGB), YCbCr) - def test_domain_range_scale_RGB_to_YCbCr(self): + def test_domain_range_scale_RGB_to_YCbCr(self) -> None: """ Test :func:`colour.models.rgb.prismatic.RGB_to_YCbCr` definition domain and range scale support. @@ -308,7 +310,7 @@ def test_domain_range_scale_RGB_to_YCbCr(self): ) @ignore_numpy_errors - def test_nan_RGB_to_YCbCr(self): + def test_nan_RGB_to_YCbCr(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.RGB_to_YCbCr` definition nan support. @@ -325,7 +327,7 @@ class TestYCbCr_to_RGB: methods. """ - def test_YCbCr_to_RGB(self): + def test_YCbCr_to_RGB(self) -> None: """Test :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition.""" np.testing.assert_allclose( @@ -359,7 +361,7 @@ def test_YCbCr_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_YCbCr_to_RGB(self): + def test_n_dimensional_YCbCr_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition n-dimensional arrays support. @@ -386,7 +388,7 @@ def test_n_dimensional_YCbCr_to_RGB(self): YCbCr = np.reshape(YCbCr, (4, 4, 4, 3)) np.testing.assert_allclose(YCbCr_to_RGB(YCbCr), RGB) - def test_domain_range_scale_YCbCr_to_RGB(self): + def test_domain_range_scale_YCbCr_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.prismatic.YCbCr_to_RGB` definition domain and range scale support. @@ -405,7 +407,7 @@ def test_domain_range_scale_YCbCr_to_RGB(self): ) @ignore_numpy_errors - def test_nan_YCbCr_to_RGB(self): + def test_nan_YCbCr_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition nan support. @@ -422,7 +424,7 @@ class TestRGB_to_YcCbcCrc: tests methods. """ - def test_RGB_to_YcCbcCrc(self): + def test_RGB_to_YcCbcCrc(self) -> None: """Test :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition.""" np.testing.assert_allclose( @@ -443,7 +445,7 @@ def test_RGB_to_YcCbcCrc(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_RGB_to_YcCbcCrc(self): + def test_n_dimensional_RGB_to_YcCbcCrc(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition n-dimensional arrays support. @@ -476,7 +478,7 @@ def test_n_dimensional_RGB_to_YcCbcCrc(self): RGB_to_YcCbcCrc(RGB), YcCbcCrc, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_RGB_to_YcCbcCrc(self): + def test_domain_range_scale_RGB_to_YcCbcCrc(self) -> None: """ Test :func:`colour.models.rgb.prismatic.RGB_to_YcCbcCrc` definition domain and range scale support. @@ -495,7 +497,7 @@ def test_domain_range_scale_RGB_to_YcCbcCrc(self): ) @ignore_numpy_errors - def test_nan_RGB_to_YcCbcCrc(self): + def test_nan_RGB_to_YcCbcCrc(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.RGB_to_YcCbcCrc` definition nan support. @@ -512,7 +514,7 @@ class TestYcCbcCrc_to_RGB: methods. """ - def test_YcCbcCrc_to_RGB(self): + def test_YcCbcCrc_to_RGB(self) -> None: """Test :func:`colour.models.rgb.ycbcr.YCbCr_to_RGB` definition.""" np.testing.assert_allclose( @@ -533,7 +535,7 @@ def test_YcCbcCrc_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_YcCbcCrc_to_RGB(self): + def test_n_dimensional_YcCbcCrc_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.YcCbcCrc_to_RGB` definition n-dimensional arrays support. @@ -566,7 +568,7 @@ def test_n_dimensional_YcCbcCrc_to_RGB(self): YcCbcCrc_to_RGB(YcCbcCrc), RGB, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_YcCbcCrc_to_RGB(self): + def test_domain_range_scale_YcCbcCrc_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.prismatic.YcCbcCrc_to_RGB` definition domain and range scale support. @@ -585,7 +587,7 @@ def test_domain_range_scale_YcCbcCrc_to_RGB(self): ) @ignore_numpy_errors - def test_nan_YcCbcCrc_to_RGB(self): + def test_nan_YcCbcCrc_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycbcr.YcCbcCrc_to_RGB` definition nan support. diff --git a/colour/models/rgb/tests/test_ycocg.py b/colour/models/rgb/tests/test_ycocg.py index 385453504..3bd5d4069 100644 --- a/colour/models/rgb/tests/test_ycocg.py +++ b/colour/models/rgb/tests/test_ycocg.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.rgb.ycocg` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestRGB_to_YCoCg: methods. """ - def test_RGB_to_YCoCg(self): + def test_RGB_to_YCoCg(self) -> None: """Test :func:`colour.models.rgb.ycocg.RGB_to_YCoCg` definition.""" np.testing.assert_array_equal( @@ -45,7 +47,7 @@ def test_RGB_to_YCoCg(self): np.array([0.5625, -0.375, 0.1875]), ) - def test_n_dimensional_RGB_to_YCoCg(self): + def test_n_dimensional_RGB_to_YCoCg(self) -> None: """ Test :func:`colour.models.rgb.ycocg.RGB_to_YCoCg` definition n-dimensional arrays support. @@ -79,7 +81,7 @@ def test_n_dimensional_RGB_to_YCoCg(self): ) @ignore_numpy_errors - def test_nan_RGB_to_YCoCg(self): + def test_nan_RGB_to_YCoCg(self) -> None: """ Test :func:`colour.models.rgb.ycocg.RGB_to_YCoCg` definition nan support. @@ -96,7 +98,7 @@ class TestYCoCg_to_RGB: methods. """ - def test_YCoCg_to_RGB(self): + def test_YCoCg_to_RGB(self) -> None: """Test :func:`colour.models.rgb.ycocg.YCoCg_to_RGB` definition.""" np.testing.assert_array_equal( @@ -114,7 +116,7 @@ def test_YCoCg_to_RGB(self): np.array([0.0, 0.75, 0.75]), ) - def test_n_dimensional_YCoCg_to_RGB(self): + def test_n_dimensional_YCoCg_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycocg.YCoCg_to_RGB` definition n-dimensional arrays support. @@ -148,7 +150,7 @@ def test_n_dimensional_YCoCg_to_RGB(self): ) @ignore_numpy_errors - def test_nan_YCoCg_to_RGB(self): + def test_nan_YCoCg_to_RGB(self) -> None: """ Test :func:`colour.models.rgb.ycocg.YCoCg_to_RGB` definition nan support. diff --git a/colour/models/rgb/transfer_functions/__init__.py b/colour/models/rgb/transfer_functions/__init__.py index 6f4b17bae..375aed9db 100644 --- a/colour/models/rgb/transfer_functions/__init__.py +++ b/colour/models/rgb/transfer_functions/__init__.py @@ -874,7 +874,7 @@ def eotf( def eotf_inverse( value: ArrayLike, function: LiteralEOTFInverse | str = "ITU-R BT.1886", - **kwargs, + **kwargs: Any, ) -> NDArrayFloat | NDArrayInt: """ Encode estimated tristimulus values in a scene to :math:`R'G'B'` video diff --git a/colour/models/rgb/transfer_functions/itur_bt_1361.py b/colour/models/rgb/transfer_functions/itur_bt_1361.py index fb4f2adf0..65be8b234 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1361.py @@ -17,9 +17,12 @@ R-REC-BT.1361-0-199802-W!!PDF-E.pdf """ +from __future__ import annotations + import numpy as np from colour.algebra import spow +from colour.hints import ArrayLike, NDArrayFloat from colour.models.rgb.transfer_functions import oetf_BT709, oetf_inverse_BT709 from colour.utilities import ( as_float, @@ -41,7 +44,7 @@ ] -def oetf_BT1361(L): +def oetf_BT1361(L: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-R BT.1361* extended color gamut system opto-electronic transfer function (OETF). @@ -102,7 +105,7 @@ def oetf_BT1361(L): return as_float(from_range_1(E_p)) -def oetf_inverse_BT1361(E_p): +def oetf_inverse_BT1361(E_p: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-R BT.1361* extended color gamut system inverse opto-electronic transfer functions (OETF). diff --git a/colour/models/rgb/transfer_functions/itut_h_273.py b/colour/models/rgb/transfer_functions/itut_h_273.py index e2a10e450..c7c1512c3 100644 --- a/colour/models/rgb/transfer_functions/itut_h_273.py +++ b/colour/models/rgb/transfer_functions/itut_h_273.py @@ -25,9 +25,12 @@ Distribution Master — Image Characteristic. doi:10.5594/SMPTE.ST428-1.2019 """ +from __future__ import annotations + import numpy as np from colour.algebra import spow +from colour.hints import ArrayLike, NDArrayFloat from colour.models.rgb.transfer_functions import ( eotf_DCDM, eotf_inverse_DCDM, @@ -60,7 +63,7 @@ ] -def oetf_H273_Log(L_c): +def oetf_H273_Log(L_c: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* opto-electronic transfer function (OETF) for logarithmic encoding (100:1 range). @@ -122,7 +125,7 @@ def oetf_H273_Log(L_c): return as_float(from_range_1(V)) -def oetf_inverse_H273_Log(V): +def oetf_inverse_H273_Log(V: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* inverse-opto-electronic transfer function (OETF) for logarithmic encoding (100:1 range). @@ -183,7 +186,7 @@ def oetf_inverse_H273_Log(V): return as_float(from_range_1(L_c)) -def oetf_H273_LogSqrt(L_c): +def oetf_H273_LogSqrt(L_c: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* opto-electronic transfer function (OETF) for logarithmic encoding (100\\*Sqrt(10):1 range). @@ -246,7 +249,7 @@ def oetf_H273_LogSqrt(L_c): return as_float(from_range_1(V)) -def oetf_inverse_H273_LogSqrt(V): +def oetf_inverse_H273_LogSqrt(V: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* inverse-opto-electronic transfer function (OETF) for logarithmic encoding (100\\*Sqrt(10):1 range). @@ -306,7 +309,7 @@ def oetf_inverse_H273_LogSqrt(V): return as_float(from_range_1(L_c)) -def oetf_H273_IEC61966_2(L_c): +def oetf_H273_IEC61966_2(L_c: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* opto-electronic transfer function (OETF) for *IEC 61966-2* family of transfer functions (*2-1 sRGB*, @@ -356,8 +359,10 @@ def oetf_H273_IEC61966_2(L_c): -0.4613561295004... """ + L_c = as_float_array(L_c) + V = np.where( - as_float_array(L_c) >= 0, + L_c >= 0, eotf_inverse_sRGB(L_c), -eotf_inverse_sRGB(-L_c), ) @@ -365,7 +370,7 @@ def oetf_H273_IEC61966_2(L_c): return as_float(V) -def oetf_inverse_H273_IEC61966_2(V): +def oetf_inverse_H273_IEC61966_2(V: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* inverse opto-electronic transfer function (OETF) for *IEC 61966-2* family of transfer functions (*2-1 sRGB*, @@ -415,8 +420,10 @@ def oetf_inverse_H273_IEC61966_2(V): -0.1799999999... """ + V = as_float_array(V) + L_c = np.where( - as_float_array(V) >= 0, + V >= 0, eotf_sRGB(V), -eotf_sRGB(-V), ) @@ -424,7 +431,7 @@ def oetf_inverse_H273_IEC61966_2(V): return as_float(L_c) -def eotf_inverse_H273_ST428_1(L_o): +def eotf_inverse_H273_ST428_1(L_o: ArrayLike) -> NDArrayFloat: """ Define *Recommendation ITU-T H.273* inverse electro-optical transfer function (EOTF) for *SMPTE ST 428-1 (2019)*. @@ -474,7 +481,7 @@ def eotf_inverse_H273_ST428_1(L_o): return as_float(from_range_1(eotf_inverse_DCDM(L_o * 48))) -def eotf_H273_ST428_1(V): +def eotf_H273_ST428_1(V: ArrayLike) -> NDArrayFloat: """ Define the *SMPTE ST 428-1 (2019)* electro-optical transfer function (EOTF). diff --git a/colour/models/rgb/transfer_functions/red.py b/colour/models/rgb/transfer_functions/red.py index 7369f0d9d..a3b8fadbf 100644 --- a/colour/models/rgb/transfer_functions/red.py +++ b/colour/models/rgb/transfer_functions/red.py @@ -685,7 +685,7 @@ def log_encoding_Log3G10( def log_decoding_Log3G10( - y, method: Literal["v1", "v2", "v3"] | str = "v3" + y: ArrayLike, method: Literal["v1", "v2", "v3"] | str = "v3" ) -> NDArrayFloat: """ Define the *Log3G10* log decoding curve / electro-optical transfer diff --git a/colour/models/rgb/transfer_functions/tests/test__init__.py b/colour/models/rgb/transfer_functions/tests/test__init__.py index bc5ee0336..723e64eb3 100644 --- a/colour/models/rgb/transfer_functions/tests/test__init__.py +++ b/colour/models/rgb/transfer_functions/tests/test__init__.py @@ -43,7 +43,7 @@ class TestCctfEncoding: definition unit tests methods. """ - def test_raise_exception_cctf_encoding(self): + def test_raise_exception_cctf_encoding(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition raised exception. @@ -69,7 +69,7 @@ class TestCctfDecoding: definition unit tests methods. """ - def test_raise_exception_cctf_decoding(self): + def test_raise_exception_cctf_decoding(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition raised exception. @@ -92,7 +92,7 @@ def test_raise_exception_cctf_decoding(self): class TestTransferFunctions: """Define the transfer functions unit tests methods.""" - def test_transfer_functions(self): + def test_transfer_functions(self) -> None: """Test the transfer functions reciprocity.""" ignored_transfer_functions = ( diff --git a/colour/models/rgb/transfer_functions/tests/test_aces.py b/colour/models/rgb/transfer_functions/tests/test_aces.py index 19df0007a..8611f6163 100644 --- a/colour/models/rgb/transfer_functions/tests/test_aces.py +++ b/colour/models/rgb/transfer_functions/tests/test_aces.py @@ -39,7 +39,7 @@ class TestLogEncoding_ACESproxy: definition unit tests methods. """ - def test_log_encoding_ACESproxy(self): + def test_log_encoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition. @@ -71,7 +71,7 @@ def test_log_encoding_ACESproxy(self): assert log_encoding_ACESproxy(0.18, out_int=True) == 426 - def test_n_dimensional_log_encoding_ACESproxy(self): + def test_n_dimensional_log_encoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition n-dimensional arrays support. @@ -104,7 +104,7 @@ def test_n_dimensional_log_encoding_ACESproxy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_encoding_ACESproxy(self): + def test_domain_range_scale_log_encoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition domain and range scale support. @@ -123,7 +123,7 @@ def test_domain_range_scale_log_encoding_ACESproxy(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ACESproxy(self): + def test_nan_log_encoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACESproxy` definition nan support. @@ -139,7 +139,7 @@ class TestLogDecoding_ACESproxy: definition unit tests methods. """ - def test_log_decoding_ACESproxy(self): + def test_log_decoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACESproxy` definition. @@ -175,7 +175,7 @@ def test_log_decoding_ACESproxy(self): atol=0.01, ) - def test_n_dimensional_log_decoding_ACESproxy(self): + def test_n_dimensional_log_decoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACESproxy` definition n-dimensional arrays support. @@ -208,7 +208,7 @@ def test_n_dimensional_log_decoding_ACESproxy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_decoding_ACESproxy(self): + def test_domain_range_scale_log_decoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACESproxy` definition domain and range scale support. @@ -227,7 +227,7 @@ def test_domain_range_scale_log_decoding_ACESproxy(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ACESproxy(self): + def test_nan_log_decoding_ACESproxy(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACESproxy` definition nan support. @@ -242,7 +242,7 @@ class TestLogEncoding_ACEScc: log_encoding_ACEScc` definition unit tests methods. """ - def test_log_encoding_ACEScc(self): + def test_log_encoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScc` definition. @@ -266,7 +266,7 @@ def test_log_encoding_ACEScc(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_ACEScc(self): + def test_n_dimensional_log_encoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScc` definition n-dimensional arrays support. @@ -293,7 +293,7 @@ def test_n_dimensional_log_encoding_ACEScc(self): log_encoding_ACEScc(lin_AP1), ACEScc, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_ACEScc(self): + def test_domain_range_scale_log_encoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScc` definition domain and range scale support. @@ -312,7 +312,7 @@ def test_domain_range_scale_log_encoding_ACEScc(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ACEScc(self): + def test_nan_log_encoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScc` definition nan support. @@ -327,7 +327,7 @@ class TestLogDecoding_ACEScc: log_decoding_ACEScc` definition unit tests methods. """ - def test_log_decoding_ACEScc(self): + def test_log_decoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScc` definition. @@ -351,7 +351,7 @@ def test_log_decoding_ACEScc(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_ACEScc(self): + def test_n_dimensional_log_decoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScc` definition n-dimensional arrays support. @@ -378,7 +378,7 @@ def test_n_dimensional_log_decoding_ACEScc(self): log_decoding_ACEScc(ACEScc), lin_AP1, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_ACEScc(self): + def test_domain_range_scale_log_decoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScc` definition domain and range scale support. @@ -397,7 +397,7 @@ def test_domain_range_scale_log_decoding_ACEScc(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ACEScc(self): + def test_nan_log_decoding_ACEScc(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScc` definition nan support. @@ -412,7 +412,7 @@ class TestLogEncoding_ACEScct: log_encoding_ACEScct` definition unit tests methods. """ - def test_log_encoding_ACEScct(self): + def test_log_encoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition. @@ -436,7 +436,7 @@ def test_log_encoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_ACEScct(self): + def test_n_dimensional_log_encoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition n-dimensional arrays support. @@ -469,7 +469,7 @@ def test_n_dimensional_log_encoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_encoding_ACEScct(self): + def test_domain_range_scale_log_encoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition domain and range scale support. @@ -487,7 +487,7 @@ def test_domain_range_scale_log_encoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_ACEScc_equivalency_log_encoding_ACEScct(self): + def test_ACEScc_equivalency_log_encoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition ACEScc equivalency, and explicit requirement @@ -504,7 +504,7 @@ def test_ACEScc_equivalency_log_encoding_ACEScct(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ACEScct(self): + def test_nan_log_encoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_encoding_ACEScct` definition nan support. @@ -519,7 +519,7 @@ class TestLogDecoding_ACEScct: log_decoding_ACEScct` definition unit tests methods. """ - def test_log_decoding_ACEScct(self): + def test_log_decoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition. @@ -543,7 +543,7 @@ def test_log_decoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_ACEScct(self): + def test_n_dimensional_log_decoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition n-dimensional arrays support. @@ -576,7 +576,7 @@ def test_n_dimensional_log_decoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_decoding_ACEScct(self): + def test_domain_range_scale_log_decoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition domain and range scale support. @@ -594,7 +594,7 @@ def test_domain_range_scale_log_decoding_ACEScct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_ACEScc_equivalency_log_decoding_ACEScct(self): + def test_ACEScc_equivalency_log_decoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition ACEScc equivalency, and explicit requirement @@ -611,7 +611,7 @@ def test_ACEScc_equivalency_log_decoding_ACEScct(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ACEScct(self): + def test_nan_log_decoding_ACEScct(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.aces.\ log_decoding_ACEScct` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py b/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py index ff5b9f0df..19e64508f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py +++ b/colour/models/rgb/transfer_functions/tests/test_apple_log_profile.py @@ -31,7 +31,7 @@ class TestLogEncoding_AppleLogProfile: log_encoding_AppleLogProfile` definition unit tests methods. """ - def test_log_encoding_AppleLogProfile(self): + def test_log_encoding_AppleLogProfile(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_encoding_AppleLogProfile` definition. @@ -55,7 +55,7 @@ def test_log_encoding_AppleLogProfile(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_DLog(self): + def test_n_dimensional_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_encoding_AppleLogProfile` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_DLog(self): log_encoding_AppleLogProfile(R), P, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_DLog(self): + def test_domain_range_scale_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_encoding_AppleLogProfile` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_DLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_DLog(self): + def test_nan_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_encoding_AppleLogProfile` definition nan support. @@ -118,7 +118,7 @@ class TestLogDecoding_AppleLogProfile: log_decoding_AppleLogProfile` definition unit tests methods. """ - def test_log_decoding_AppleLogProfile(self): + def test_log_decoding_AppleLogProfile(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_decoding_AppleLogProfile` definition. @@ -142,7 +142,7 @@ def test_log_decoding_AppleLogProfile(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_DLog(self): + def test_n_dimensional_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_decoding_AppleLogProfile` definition n-dimensional arrays support. @@ -169,7 +169,7 @@ def test_n_dimensional_log_decoding_DLog(self): log_decoding_AppleLogProfile(P), R, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_DLog(self): + def test_domain_range_scale_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_decoding_AppleLogProfile` definition domain and range scale support. @@ -188,7 +188,7 @@ def test_domain_range_scale_log_decoding_DLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_DLog(self): + def test_nan_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.apple_log_profile.\ log_decoding_AppleLogProfile` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py index fefb6a7ea..f63e41d36 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/tests/test_arib_std_b67.py @@ -31,7 +31,7 @@ class TestOetf_ARIBSTDB67: oetf_ARIBSTDB67` definition unit tests methods. """ - def test_oetf_ARIBSTDB67(self): + def test_oetf_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_ARIBSTDB67` definition. @@ -61,7 +61,7 @@ def test_oetf_ARIBSTDB67(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_ARIBSTDB67(self): + def test_n_dimensional_oetf_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_ARIBSTDB67` definition n-dimensional arrays support. @@ -88,7 +88,7 @@ def test_n_dimensional_oetf_ARIBSTDB67(self): oetf_ARIBSTDB67(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_ARIBSTDB67(self): + def test_domain_range_scale_oetf_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_ARIBSTDB67` definition domain and range scale support. @@ -107,7 +107,7 @@ def test_domain_range_scale_oetf_ARIBSTDB67(self): ) @ignore_numpy_errors - def test_nan_oetf_ARIBSTDB67(self): + def test_nan_oetf_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_ARIBSTDB67` definition nan support. @@ -122,7 +122,7 @@ class TestOetf_inverse_ARIBSTDB67: oetf_inverse_ARIBSTDB67` definition unit tests methods. """ - def test_oetf_inverse_ARIBSTDB67(self): + def test_oetf_inverse_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_inverse_ARIBSTDB67` definition. @@ -154,7 +154,7 @@ def test_oetf_inverse_ARIBSTDB67(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_ARIBSTDB67(self): + def test_n_dimensional_oetf_inverse_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_inverse_ARIBSTDB67` definition n-dimensional arrays support. @@ -181,7 +181,7 @@ def test_n_dimensional_oetf_inverse_ARIBSTDB67(self): oetf_inverse_ARIBSTDB67(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_ARIBSTDB67(self): + def test_domain_range_scale_oetf_inverse_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_inverse_ARIBSTDB67` definition domain and range scale support. @@ -200,7 +200,7 @@ def test_domain_range_scale_oetf_inverse_ARIBSTDB67(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_ARIBSTDB67(self): + def test_nan_oetf_inverse_ARIBSTDB67(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arib_std_b67.\ oetf_inverse_ARIBSTDB67` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_arri.py b/colour/models/rgb/transfer_functions/tests/test_arri.py index bb01441cc..feffb36c3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_arri.py +++ b/colour/models/rgb/transfer_functions/tests/test_arri.py @@ -35,7 +35,7 @@ class TestLogEncoding_ARRILogC3: log_encoding_ARRILogC3` definition unit tests methods. """ - def test_log_encoding_ARRILogC3(self): + def test_log_encoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC3` definition. @@ -59,7 +59,7 @@ def test_log_encoding_ARRILogC3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_ARRILogC3(self): + def test_n_dimensional_log_encoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC3` definition n-dimensional arrays support. @@ -86,7 +86,7 @@ def test_n_dimensional_log_encoding_ARRILogC3(self): log_encoding_ARRILogC3(x), t, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_ARRILogC3(self): + def test_domain_range_scale_log_encoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC3` definition domain and range scale support. @@ -105,7 +105,7 @@ def test_domain_range_scale_log_encoding_ARRILogC3(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ARRILogC3(self): + def test_nan_log_encoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC3` definition nan support. @@ -120,7 +120,7 @@ class TestLogDecoding_ARRILogC3: log_decoding_ARRILogC3` definition unit tests methods. """ - def test_log_decoding_ARRILogC3(self): + def test_log_decoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC3` definition. @@ -144,7 +144,7 @@ def test_log_decoding_ARRILogC3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_ARRILogC3(self): + def test_n_dimensional_log_decoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC3` definition n-dimensional arrays support. @@ -171,7 +171,7 @@ def test_n_dimensional_log_decoding_ARRILogC3(self): log_decoding_ARRILogC3(t), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_ARRILogC3(self): + def test_domain_range_scale_log_decoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC3` definition domain and range scale support. @@ -190,7 +190,7 @@ def test_domain_range_scale_log_decoding_ARRILogC3(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ARRILogC3(self): + def test_nan_log_decoding_ARRILogC3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC3` definition nan support. @@ -205,7 +205,7 @@ class TestLogEncoding_ARRILogC4: log_encoding_ARRILogC4` definition unit tests methods. """ - def test_log_encoding_ARRILogC4(self): + def test_log_encoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC4` definition. @@ -229,7 +229,7 @@ def test_log_encoding_ARRILogC4(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_ARRILogC4(self): + def test_n_dimensional_log_encoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC4` definition n-dimensional arrays support. @@ -256,7 +256,7 @@ def test_n_dimensional_log_encoding_ARRILogC4(self): log_encoding_ARRILogC4(x), t, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_ARRILogC4(self): + def test_domain_range_scale_log_encoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC4` definition domain and range scale support. @@ -275,7 +275,7 @@ def test_domain_range_scale_log_encoding_ARRILogC4(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ARRILogC4(self): + def test_nan_log_encoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_encoding_ARRILogC4` definition nan support. @@ -290,7 +290,7 @@ class TestLogDecoding_ARRILogC4: log_decoding_ARRILogC4` definition unit tests methods. """ - def test_log_decoding_ARRILogC4(self): + def test_log_decoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC4` definition. @@ -314,7 +314,7 @@ def test_log_decoding_ARRILogC4(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_ARRILogC4(self): + def test_n_dimensional_log_decoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC4` definition n-dimensional arrays support. @@ -341,7 +341,7 @@ def test_n_dimensional_log_decoding_ARRILogC4(self): log_decoding_ARRILogC4(t), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_ARRILogC4(self): + def test_domain_range_scale_log_decoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC4` definition domain and range scale support. @@ -360,7 +360,7 @@ def test_domain_range_scale_log_decoding_ARRILogC4(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ARRILogC4(self): + def test_nan_log_decoding_ARRILogC4(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.arri.\ log_decoding_ARRILogC4` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py b/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py index 622575596..84318a28d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py +++ b/colour/models/rgb/transfer_functions/tests/test_blackmagic_design.py @@ -31,7 +31,7 @@ class TestOetf_BlackmagicFilmGeneration5: oetf_BlackmagicFilmGeneration5` definition unit tests methods. """ - def test_oetf_BlackmagicFilmGeneration5(self): + def test_oetf_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_BlackmagicFilmGeneration5` definition. @@ -67,7 +67,7 @@ def test_oetf_BlackmagicFilmGeneration5(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_BlackmagicFilmGeneration5(self): + def test_n_dimensional_oetf_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_BlackmagicFilmGeneration5` definition n-dimensional @@ -95,7 +95,7 @@ def test_n_dimensional_oetf_BlackmagicFilmGeneration5(self): oetf_BlackmagicFilmGeneration5(L), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_BlackmagicFilmGeneration5(self): + def test_domain_range_scale_oetf_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_BlackmagicFilmGeneration5` definition domain and range @@ -115,7 +115,7 @@ def test_domain_range_scale_oetf_BlackmagicFilmGeneration5(self): ) @ignore_numpy_errors - def test_nan_oetf_BlackmagicFilmGeneration5(self): + def test_nan_oetf_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_BlackmagicFilmGeneration5` definition nan support. @@ -133,7 +133,7 @@ class TestOetf_inverse_BlackmagicFilmGeneration5: methods. """ - def test_oetf_inverse_BlackmagicFilmGeneration5(self): + def test_oetf_inverse_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_inverse_BlackmagicFilmGeneration5` definition. @@ -169,7 +169,7 @@ def test_oetf_inverse_BlackmagicFilmGeneration5(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_BlackmagicFilmGeneration5(self): + def test_n_dimensional_oetf_inverse_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_inverse_BlackmagicFilmGeneration5` definition @@ -203,7 +203,7 @@ def test_n_dimensional_oetf_inverse_BlackmagicFilmGeneration5(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_oetf_inverse_BlackmagicFilmGeneration5(self): + def test_domain_range_scale_oetf_inverse_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_inverse_BlackmagicFilmGeneration5` definition domain and @@ -223,7 +223,7 @@ def test_domain_range_scale_oetf_inverse_BlackmagicFilmGeneration5(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BlackmagicFilmGeneration5(self): + def test_nan_oetf_inverse_BlackmagicFilmGeneration5(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ blackmagic_design.oetf_inverse_BlackmagicFilmGeneration5` definition nan diff --git a/colour/models/rgb/transfer_functions/tests/test_canon.py b/colour/models/rgb/transfer_functions/tests/test_canon.py index 509d64754..8f44c0f0d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_canon.py +++ b/colour/models/rgb/transfer_functions/tests/test_canon.py @@ -51,7 +51,7 @@ class TestLogEncoding_CanonLog_v1: log_encoding_CanonLog_v1` definition unit tests methods. """ - def test_log_encoding_CanonLog_v1(self): + def test_log_encoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1` definition. @@ -99,7 +99,7 @@ def test_log_encoding_CanonLog_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog_v1(self): + def test_n_dimensional_log_encoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1` definition n-dimensional arrays support. @@ -126,7 +126,7 @@ def test_n_dimensional_log_encoding_CanonLog_v1(self): log_encoding_CanonLog_v1(x), clog, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_CanonLog_v1(self): + def test_domain_range_scale_log_encoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1` definition domain and range scale support. @@ -145,7 +145,7 @@ def test_domain_range_scale_log_encoding_CanonLog_v1(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog_v1(self): + def test_nan_log_encoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1` definition nan support. @@ -160,7 +160,7 @@ class TestLogDecoding_CanonLog_v1: log_decoding_CanonLog_v1` definition unit tests methods. """ - def test_log_decoding_CanonLog_v1(self): + def test_log_decoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1` definition. @@ -208,7 +208,7 @@ def test_log_decoding_CanonLog_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog_v1(self): + def test_n_dimensional_log_decoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1` definition n-dimensional arrays support. @@ -235,7 +235,7 @@ def test_n_dimensional_log_decoding_CanonLog_v1(self): log_decoding_CanonLog_v1(clog), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_CanonLog_v1(self): + def test_domain_range_scale_log_decoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1` definition domain and range scale support. @@ -254,7 +254,7 @@ def test_domain_range_scale_log_decoding_CanonLog_v1(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog_v1(self): + def test_nan_log_decoding_CanonLog_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1` definition nan support. @@ -269,7 +269,7 @@ class TestLogEncoding_CanonLog_v1_2: log_encoding_CanonLog_v1_2` definition unit tests methods. """ - def test_log_encoding_CanonLog_v1_2(self): + def test_log_encoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1_2` definition. @@ -342,7 +342,7 @@ def test_log_encoding_CanonLog_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog_v1_2(self): + def test_n_dimensional_log_encoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1_2` definition n-dimensional arrays support. @@ -369,7 +369,7 @@ def test_n_dimensional_log_encoding_CanonLog_v1_2(self): log_encoding_CanonLog_v1_2(x), clog, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_CanonLog_v1_2(self): + def test_domain_range_scale_log_encoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1_2` definition domain and range scale support. @@ -388,7 +388,7 @@ def test_domain_range_scale_log_encoding_CanonLog_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog_v1_2(self): + def test_nan_log_encoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog_v1_2` definition nan support. @@ -403,7 +403,7 @@ class TestLogDecoding_CanonLog_v1_2: log_decoding_CanonLog_v1_2` definition unit tests methods. """ - def test_log_decoding_CanonLog_v1_2(self): + def test_log_decoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1_2` definition. @@ -476,7 +476,7 @@ def test_log_decoding_CanonLog_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog_v1_2(self): + def test_n_dimensional_log_decoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1_2` definition n-dimensional arrays support. @@ -503,7 +503,7 @@ def test_n_dimensional_log_decoding_CanonLog_v1_2(self): log_decoding_CanonLog_v1_2(clog), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_CanonLog_v1_2(self): + def test_domain_range_scale_log_decoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1_2` definition domain and range scale support. @@ -522,7 +522,7 @@ def test_domain_range_scale_log_decoding_CanonLog_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog_v1_2(self): + def test_nan_log_decoding_CanonLog_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog_v1_2` definition nan support. @@ -537,7 +537,7 @@ class TestLogEncoding_CanonLog2_v1: log_encoding_CanonLog2_v1` definition unit tests methods. """ - def test_log_encoding_CanonLog2_v1(self): + def test_log_encoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1` definition. @@ -585,7 +585,7 @@ def test_log_encoding_CanonLog2_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog2_v1(self): + def test_n_dimensional_log_encoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1` definition n-dimensional arrays support. @@ -612,7 +612,7 @@ def test_n_dimensional_log_encoding_CanonLog2_v1(self): log_encoding_CanonLog2_v1(x), clog2, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_CanonLog2_v1(self): + def test_domain_range_scale_log_encoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1` definition domain and range scale support. @@ -631,7 +631,7 @@ def test_domain_range_scale_log_encoding_CanonLog2_v1(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog2_v1(self): + def test_nan_log_encoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1` definition nan support. @@ -646,7 +646,7 @@ class TestLogDecoding_CanonLog2_v1: log_decoding_CanonLog2_v1` definition unit tests methods. """ - def test_log_decoding_CanonLog2_v1(self): + def test_log_decoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1` definition. @@ -694,7 +694,7 @@ def test_log_decoding_CanonLog2_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog2_v1(self): + def test_n_dimensional_log_decoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1` definition n-dimensional arrays support. @@ -721,7 +721,7 @@ def test_n_dimensional_log_decoding_CanonLog2_v1(self): log_decoding_CanonLog2_v1(clog2), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_CanonLog2_v1(self): + def test_domain_range_scale_log_decoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1` definition domain and range scale support. @@ -740,7 +740,7 @@ def test_domain_range_scale_log_decoding_CanonLog2_v1(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog2_v1(self): + def test_nan_log_decoding_CanonLog2_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1` definition nan support. @@ -755,7 +755,7 @@ class TestLogEncoding_CanonLog2_v1_2: log_encoding_CanonLog2_v1_2` definition unit tests methods. """ - def test_log_encoding_CanonLog2_v1_2(self): + def test_log_encoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1_2` definition. @@ -828,7 +828,7 @@ def test_log_encoding_CanonLog2_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog2_v1_2(self): + def test_n_dimensional_log_encoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1_2` definition n-dimensional arrays support. @@ -861,7 +861,7 @@ def test_n_dimensional_log_encoding_CanonLog2_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_encoding_CanonLog2_v1_2(self): + def test_domain_range_scale_log_encoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1_2` definition domain and range scale support. @@ -880,7 +880,7 @@ def test_domain_range_scale_log_encoding_CanonLog2_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog2_v1_2(self): + def test_nan_log_encoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog2_v1_2` definition nan support. @@ -895,7 +895,7 @@ class TestLogDecoding_CanonLog2_v1_2: log_decoding_CanonLog2_v1_2` definition unit tests methods. """ - def test_log_decoding_CanonLog2_v1_2(self): + def test_log_decoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1_2` definition. @@ -968,7 +968,7 @@ def test_log_decoding_CanonLog2_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog2_v1_2(self): + def test_n_dimensional_log_decoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1_2` definition n-dimensional arrays support. @@ -1001,7 +1001,7 @@ def test_n_dimensional_log_decoding_CanonLog2_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_decoding_CanonLog2_v1_2(self): + def test_domain_range_scale_log_decoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1_2` definition domain and range scale support. @@ -1020,7 +1020,7 @@ def test_domain_range_scale_log_decoding_CanonLog2_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog2_v1_2(self): + def test_nan_log_decoding_CanonLog2_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog2_v1_2` definition nan support. @@ -1035,7 +1035,7 @@ class TestLogEncoding_CanonLog3_v1: log_encoding_CanonLog3_v1` definition unit tests methods. """ - def test_log_encoding_CanonLog3_v1(self): + def test_log_encoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1` definition. @@ -1083,7 +1083,7 @@ def test_log_encoding_CanonLog3_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog3_v1(self): + def test_n_dimensional_log_encoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1` definition n-dimensional arrays support. @@ -1110,7 +1110,7 @@ def test_n_dimensional_log_encoding_CanonLog3_v1(self): log_encoding_CanonLog3_v1(x), clog3, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_CanonLog3_v1(self): + def test_domain_range_scale_log_encoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1` definition domain and range scale support. @@ -1129,7 +1129,7 @@ def test_domain_range_scale_log_encoding_CanonLog3_v1(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog3_v1(self): + def test_nan_log_encoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1` definition nan support. @@ -1144,7 +1144,7 @@ class TestLogDecoding_CanonLog3_v1: log_decoding_CanonLog3_v1` definition unit tests methods. """ - def test_log_decoding_CanonLog3_v1(self): + def test_log_decoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1` definition. @@ -1192,7 +1192,7 @@ def test_log_decoding_CanonLog3_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog3_v1(self): + def test_n_dimensional_log_decoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1` definition n-dimensional arrays support. @@ -1219,7 +1219,7 @@ def test_n_dimensional_log_decoding_CanonLog3_v1(self): log_decoding_CanonLog3_v1(clog3), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_CanonLog3_v1(self): + def test_domain_range_scale_log_decoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1` definition domain and range scale support. @@ -1238,7 +1238,7 @@ def test_domain_range_scale_log_decoding_CanonLog3_v1(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog3_v1(self): + def test_nan_log_decoding_CanonLog3_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1` definition nan support. @@ -1253,7 +1253,7 @@ class TestLogEncoding_CanonLog3_v1_2: log_encoding_CanonLog3_v1_2` definition unit tests methods. """ - def test_log_encoding_CanonLog3_v1_2(self): + def test_log_encoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1_2` definition. @@ -1326,7 +1326,7 @@ def test_log_encoding_CanonLog3_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_CanonLog3_v1_2(self): + def test_n_dimensional_log_encoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1_2` definition n-dimensional arrays support. @@ -1359,7 +1359,7 @@ def test_n_dimensional_log_encoding_CanonLog3_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_encoding_CanonLog3_v1_2(self): + def test_domain_range_scale_log_encoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1_2` definition domain and range scale support. @@ -1378,7 +1378,7 @@ def test_domain_range_scale_log_encoding_CanonLog3_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_CanonLog3_v1_2(self): + def test_nan_log_encoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_encoding_CanonLog3_v1_2` definition nan support. @@ -1393,7 +1393,7 @@ class TestLogDecoding_CanonLog3_v1_2: log_decoding_CanonLog3_v1_2` definition unit tests methods. """ - def test_log_decoding_CanonLog3_v1_2(self): + def test_log_decoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1_2` definition. @@ -1466,7 +1466,7 @@ def test_log_decoding_CanonLog3_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_CanonLog3_v1_2(self): + def test_n_dimensional_log_decoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1_2` definition n-dimensional arrays support. @@ -1499,7 +1499,7 @@ def test_n_dimensional_log_decoding_CanonLog3_v1_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_log_decoding_CanonLog3_v1_2(self): + def test_domain_range_scale_log_decoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1_2` definition domain and range scale support. @@ -1518,7 +1518,7 @@ def test_domain_range_scale_log_decoding_CanonLog3_v1_2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_CanonLog3_v1_2(self): + def test_nan_log_decoding_CanonLog3_v1_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.canon.\ log_decoding_CanonLog3_v1_2` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_cineon.py b/colour/models/rgb/transfer_functions/tests/test_cineon.py index 63722ad26..7354dc916 100644 --- a/colour/models/rgb/transfer_functions/tests/test_cineon.py +++ b/colour/models/rgb/transfer_functions/tests/test_cineon.py @@ -31,7 +31,7 @@ class TestLogEncoding_Cineon: log_encoding_Cineon` definition unit tests methods. """ - def test_log_encoding_Cineon(self): + def test_log_encoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_encoding_Cineon` definition. @@ -55,7 +55,7 @@ def test_log_encoding_Cineon(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Cineon(self): + def test_n_dimensional_log_encoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_encoding_Cineon` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_Cineon(self): log_encoding_Cineon(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Cineon(self): + def test_domain_range_scale_log_encoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_encoding_Cineon` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_Cineon(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Cineon(self): + def test_nan_log_encoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_encoding_Cineon` definition nan support. @@ -116,7 +116,7 @@ class TestLogDecoding_Cineon: log_decoding_Cineon` definition unit tests methods. """ - def test_log_decoding_Cineon(self): + def test_log_decoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_decoding_Cineon` definition. @@ -140,7 +140,7 @@ def test_log_decoding_Cineon(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Cineon(self): + def test_n_dimensional_log_decoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_decoding_Cineon` definition n-dimensional arrays support. @@ -167,7 +167,7 @@ def test_n_dimensional_log_decoding_Cineon(self): log_decoding_Cineon(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Cineon(self): + def test_domain_range_scale_log_decoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_decoding_Cineon` definition domain and range scale support. @@ -186,7 +186,7 @@ def test_domain_range_scale_log_decoding_Cineon(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Cineon(self): + def test_nan_log_decoding_Cineon(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.cineon.\ log_decoding_Cineon` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_common.py b/colour/models/rgb/transfer_functions/tests/test_common.py index 41f9a4ff1..a72b52206 100644 --- a/colour/models/rgb/transfer_functions/tests/test_common.py +++ b/colour/models/rgb/transfer_functions/tests/test_common.py @@ -33,7 +33,7 @@ class TestCV_range: definition unit tests methods. """ - def test_CV_range(self): + def test_CV_range(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.CV_range` definition. @@ -70,7 +70,7 @@ class TestLegalToFull: definition unit tests methods. """ - def test_legal_to_full(self): + def test_legal_to_full(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.legal_to_full` definition. @@ -92,7 +92,7 @@ def test_legal_to_full(self): np.testing.assert_allclose(legal_to_full(940, in_int=True, out_int=True), 1023) - def test_n_dimensional_legal_to_full(self): + def test_n_dimensional_legal_to_full(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.legal_to_full` definition n-dimensional arrays support. @@ -120,7 +120,7 @@ def test_n_dimensional_legal_to_full(self): ) @ignore_numpy_errors - def test_nan_legal_to_full(self): + def test_nan_legal_to_full(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.legal_to_full` definition nan support. @@ -135,7 +135,7 @@ class TestFullToLegal: definition unit tests methods. """ - def test_full_to_legal(self): + def test_full_to_legal(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.full_to_legal` definition. @@ -157,7 +157,7 @@ def test_full_to_legal(self): np.testing.assert_allclose(full_to_legal(1023, in_int=True, out_int=True), 940) - def test_n_dimensional_full_to_legal(self): + def test_n_dimensional_full_to_legal(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.full_to_legal` definition n-dimensional arrays support. @@ -185,7 +185,7 @@ def test_n_dimensional_full_to_legal(self): ) @ignore_numpy_errors - def test_nan_full_to_legal(self): + def test_nan_full_to_legal(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.common.full_to_legal` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py b/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py index 30bbb191c..863f7c87e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py +++ b/colour/models/rgb/transfer_functions/tests/test_davinci_intermediate.py @@ -31,7 +31,7 @@ class TestOetf_DaVinciIntermediate: oetf_DaVinciIntermediate` definition unit tests methods. """ - def test_oetf_DaVinciIntermediate(self): + def test_oetf_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_DaVinciIntermediate` definition. @@ -65,7 +65,7 @@ def test_oetf_DaVinciIntermediate(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_DaVinciIntermediate(self): + def test_n_dimensional_oetf_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_DaVinciIntermediate` definition n-dimensional arrays @@ -93,7 +93,7 @@ def test_n_dimensional_oetf_DaVinciIntermediate(self): oetf_DaVinciIntermediate(L), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_DaVinciIntermediate(self): + def test_domain_range_scale_oetf_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_DaVinciIntermediate` definition domain and range @@ -113,7 +113,7 @@ def test_domain_range_scale_oetf_DaVinciIntermediate(self): ) @ignore_numpy_errors - def test_nan_oetf_DaVinciIntermediate(self): + def test_nan_oetf_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_DaVinciIntermediate` definition nan support. @@ -129,7 +129,7 @@ class TestOetf_inverse_DaVinciIntermediate: methods. """ - def test_oetf_inverse_DaVinciIntermediate(self): + def test_oetf_inverse_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_inverse_DaVinciIntermediate` definition. @@ -165,7 +165,7 @@ def test_oetf_inverse_DaVinciIntermediate(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_DaVinciIntermediate(self): + def test_n_dimensional_oetf_inverse_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_inverse_DaVinciIntermediate` definition n-dimensional @@ -199,7 +199,7 @@ def test_n_dimensional_oetf_inverse_DaVinciIntermediate(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_oetf_inverse_DaVinciIntermediate(self): + def test_domain_range_scale_oetf_inverse_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_inverse_DaVinciIntermediate` definition domain and @@ -219,7 +219,7 @@ def test_domain_range_scale_oetf_inverse_DaVinciIntermediate(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_DaVinciIntermediate(self): + def test_nan_oetf_inverse_DaVinciIntermediate(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ davinci_intermediate.oetf_inverse_DaVinciIntermediate` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_dcdm.py b/colour/models/rgb/transfer_functions/tests/test_dcdm.py index 4913ec832..122504d1c 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dcdm.py +++ b/colour/models/rgb/transfer_functions/tests/test_dcdm.py @@ -28,7 +28,7 @@ class TestEotf_inverse_DCDM: definition unit tests methods. """ - def test_eotf_inverse_DCDM(self): + def test_eotf_inverse_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ dcdm.eotf_inverse_DCDM` definition. @@ -48,7 +48,7 @@ def test_eotf_inverse_DCDM(self): assert eotf_inverse_DCDM(0.18, out_int=True) == 462 - def test_n_dimensional_eotf_inverse_DCDM(self): + def test_n_dimensional_eotf_inverse_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.\ eotf_inverse_DCDM` definition n-dimensional arrays support. @@ -75,7 +75,7 @@ def test_n_dimensional_eotf_inverse_DCDM(self): eotf_inverse_DCDM(XYZ), XYZ_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_DCDM(self): + def test_domain_range_scale_eotf_inverse_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.\ dcdm.eotf_inverse_DCDM` definition domain and range scale support. @@ -94,7 +94,7 @@ def test_domain_range_scale_eotf_inverse_DCDM(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_DCDM(self): + def test_nan_eotf_inverse_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.\ eotf_inverse_DCDM` definition nan support. @@ -109,7 +109,7 @@ class TestEotf_DCDM: definition unit tests methods. """ - def test_eotf_DCDM(self): + def test_eotf_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.eotf_DCDM` definition. @@ -127,7 +127,7 @@ def test_eotf_DCDM(self): np.testing.assert_allclose(eotf_DCDM(462, in_int=True), 0.18, atol=1e-5) - def test_n_dimensional_eotf_DCDM(self): + def test_n_dimensional_eotf_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.eotf_DCDM` definition n-dimensional arrays support. @@ -148,7 +148,7 @@ def test_n_dimensional_eotf_DCDM(self): XYZ = np.reshape(XYZ, (2, 3, 1)) np.testing.assert_allclose(eotf_DCDM(XYZ_p), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_eotf_DCDM(self): + def test_domain_range_scale_eotf_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.eotf_DCDM` definition domain and range scale support. @@ -167,7 +167,7 @@ def test_domain_range_scale_eotf_DCDM(self): ) @ignore_numpy_errors - def test_nan_eotf_DCDM(self): + def test_nan_eotf_DCDM(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dcdm.eotf_DCDM` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py index 4fe805e1e..854d7865f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py @@ -31,7 +31,7 @@ class TestEotf_inverse_DICOMGSDF: eotf_inverse_DICOMGSDF` definition unit tests methods. """ - def test_eotf_inverse_DICOMGSDF(self): + def test_eotf_inverse_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_inverse_DICOMGSDF` definition. @@ -61,7 +61,7 @@ def test_eotf_inverse_DICOMGSDF(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_inverse_DICOMGSDF(self): + def test_n_dimensional_eotf_inverse_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_inverse_DICOMGSDF` definition n-dimensional arrays support. @@ -88,7 +88,7 @@ def test_n_dimensional_eotf_inverse_DICOMGSDF(self): eotf_inverse_DICOMGSDF(L), J, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_DICOMGSDF(self): + def test_domain_range_scale_eotf_inverse_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_inverse_DICOMGSDF` definition domain and range scale support. @@ -107,7 +107,7 @@ def test_domain_range_scale_eotf_inverse_DICOMGSDF(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_DICOMGSDF(self): + def test_nan_eotf_inverse_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_inverse_DICOMGSDF` definition nan support. @@ -122,7 +122,7 @@ class TestEotf_DICOMGSDF: eotf_DICOMGSDF` definition unit tests methods. """ - def test_eotf_DICOMGSDF(self): + def test_eotf_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_DICOMGSDF` definition. @@ -152,7 +152,7 @@ def test_eotf_DICOMGSDF(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_DICOMGSDF(self): + def test_n_dimensional_eotf_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_DICOMGSDF` definition n-dimensional arrays support. @@ -173,7 +173,7 @@ def test_n_dimensional_eotf_DICOMGSDF(self): L = np.reshape(L, (2, 3, 1)) np.testing.assert_allclose(eotf_DICOMGSDF(J), L, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_eotf_DICOMGSDF(self): + def test_domain_range_scale_eotf_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_DICOMGSDF` definition domain and range scale support. @@ -192,7 +192,7 @@ def test_domain_range_scale_eotf_DICOMGSDF(self): ) @ignore_numpy_errors - def test_nan_eotf_DICOMGSDF(self): + def test_nan_eotf_DICOMGSDF(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dicom_gsdf.\ eotf_DICOMGSDF` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py b/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py index 1685e7bce..dae2a47f4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_dji_d_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_DJIDLog: log_encoding_DJIDLog` definition unit tests methods. """ - def test_log_encoding_DJIDLog(self): + def test_log_encoding_DJIDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_encoding_DJIDLog` definition. @@ -51,7 +51,7 @@ def test_log_encoding_DJIDLog(self): log_encoding_DJIDLog(1.0), 0.584555, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_encoding_DLog(self): + def test_n_dimensional_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_encoding_DJIDLog` definition n-dimensional arrays support. @@ -78,7 +78,7 @@ def test_n_dimensional_log_encoding_DLog(self): log_encoding_DJIDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_DLog(self): + def test_domain_range_scale_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_encoding_DJIDLog` definition domain and range scale support. @@ -97,7 +97,7 @@ def test_domain_range_scale_log_encoding_DLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_DLog(self): + def test_nan_log_encoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_encoding_DJIDLog` definition nan support. @@ -112,7 +112,7 @@ class TestLogDecoding_DJIDLog: log_decoding_DJIDLog` definition unit tests methods. """ - def test_log_decoding_DJIDLog(self): + def test_log_decoding_DJIDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_decoding_DJIDLog` definition. @@ -128,7 +128,7 @@ def test_log_decoding_DJIDLog(self): np.testing.assert_allclose(log_decoding_DJIDLog(0.584555), 1.0, atol=1e-6) - def test_n_dimensional_log_decoding_DLog(self): + def test_n_dimensional_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_decoding_DJIDLog` definition n-dimensional arrays support. @@ -155,7 +155,7 @@ def test_n_dimensional_log_decoding_DLog(self): log_decoding_DJIDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_DLog(self): + def test_domain_range_scale_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_decoding_DJIDLog` definition domain and range scale support. @@ -174,7 +174,7 @@ def test_domain_range_scale_log_decoding_DLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_DLog(self): + def test_nan_log_decoding_DLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.dji_d_log.\ log_decoding_DJIDLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_exponent.py b/colour/models/rgb/transfer_functions/tests/test_exponent.py index 260a44e5e..476f4c8c4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_exponent.py +++ b/colour/models/rgb/transfer_functions/tests/test_exponent.py @@ -31,7 +31,7 @@ class TestExponentFunctionBasic: exponent_function_basic` definition unit tests methods. """ - def test_exponent_function_basic(self): + def test_exponent_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_basic` definition. @@ -111,7 +111,7 @@ def test_exponent_function_basic(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_exponent_function_basic(self): + def test_n_dimensional_exponent_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_basic` definition n-dimensional arrays support. @@ -226,7 +226,7 @@ def test_n_dimensional_exponent_function_basic(self): ) @ignore_numpy_errors - def test_nan_exponent_function_basic(self): + def test_nan_exponent_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_basic` definition nan support. @@ -243,7 +243,7 @@ class TestExponentFunctionMonitorCurve: exponent_function_monitor_curve` definition unit tests methods. """ - def test_exponent_function_monitor_curve(self): + def test_exponent_function_monitor_curve(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_monitor_curve` definition. @@ -303,7 +303,7 @@ def test_exponent_function_monitor_curve(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_exponent_function_monitor_curve(self): + def test_n_dimensional_exponent_function_monitor_curve(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_monitor_curve` definition n-dimensional arrays support. @@ -394,7 +394,7 @@ def test_n_dimensional_exponent_function_monitor_curve(self): ) @ignore_numpy_errors - def test_nan_exponent_function_monitor_curve(self): + def test_nan_exponent_function_monitor_curve(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.exponent.\ exponent_function_monitor_curve` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py index adf679c91..0fff4fa15 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmic_pro.py @@ -31,7 +31,7 @@ class TestLogEncoding_FilmicPro6: log_encoding_FilmicPro6` definition unit tests methods. """ - def test_log_encoding_FilmicPro6(self): + def test_log_encoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_encoding_FilmicPro6` definition. @@ -55,7 +55,7 @@ def test_log_encoding_FilmicPro6(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_FilmicPro6(self): + def test_n_dimensional_log_encoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_encoding_FilmicPro6` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_FilmicPro6(self): log_encoding_FilmicPro6(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_FilmicPro6(self): + def test_domain_range_scale_log_encoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_encoding_FilmicPro6` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_FilmicPro6(self): ) @ignore_numpy_errors - def test_nan_log_encoding_FilmicPro6(self): + def test_nan_log_encoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_encoding_FilmicPro6` definition nan support. @@ -116,7 +116,7 @@ class TestLogDecoding_FilmicPro6: log_decoding_FilmicPro6` definition unit tests methods. """ - def test_log_decoding_FilmicPro6(self): + def test_log_decoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_decoding_FilmicPro6` definition. @@ -136,7 +136,7 @@ def test_log_decoding_FilmicPro6(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_FilmicPro6(self): + def test_n_dimensional_log_decoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_decoding_FilmicPro6` definition n-dimensional arrays support. @@ -163,7 +163,7 @@ def test_n_dimensional_log_decoding_FilmicPro6(self): log_decoding_FilmicPro6(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_FilmicPro6(self): + def test_domain_range_scale_log_decoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_decoding_FilmicPro6` definition domain and range scale support. @@ -182,7 +182,7 @@ def test_domain_range_scale_log_decoding_FilmicPro6(self): ) @ignore_numpy_errors - def test_nan_log_decoding_FilmicPro6(self): + def test_nan_log_decoding_FilmicPro6(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmic_pro.\ log_decoding_FilmicPro6` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py b/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py index b8545d5e1..4344e9fd4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_filmlight_t_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_FilmLightTLog: log_encoding_FilmLightTLog` definition unit tests methods. """ - def test_log_encoding_FilmLightTLog(self): + def test_log_encoding_FilmLightTLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_encoding_FilmLightTLog` definition. @@ -55,7 +55,7 @@ def test_log_encoding_FilmLightTLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_TLog(self): + def test_n_dimensional_log_encoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_encoding_FilmLightTLog` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_TLog(self): log_encoding_FilmLightTLog(x), t, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_TLog(self): + def test_domain_range_scale_log_encoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_encoding_FilmLightTLog` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_TLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_TLog(self): + def test_nan_log_encoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_encoding_FilmLightTLog` definition nan support. @@ -116,7 +116,7 @@ class TestLogDecoding_FilmLightTLog: log_decoding_FilmLightTLog` definition unit tests methods. """ - def test_log_decoding_FilmLightTLog(self): + def test_log_decoding_FilmLightTLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_decoding_FilmLightTLog` definition. @@ -140,7 +140,7 @@ def test_log_decoding_FilmLightTLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_TLog(self): + def test_n_dimensional_log_decoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_decoding_FilmLightTLog` definition n-dimensional arrays support. @@ -167,7 +167,7 @@ def test_n_dimensional_log_decoding_TLog(self): log_decoding_FilmLightTLog(t), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_TLog(self): + def test_domain_range_scale_log_decoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_decoding_FilmLightTLog` definition domain and range scale support. @@ -186,7 +186,7 @@ def test_domain_range_scale_log_decoding_TLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_TLog(self): + def test_nan_log_decoding_TLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.filmlight_t_log.\ log_decoding_FilmLightTLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py b/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py index 995484070..dccbbd35f 100644 --- a/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_fujifilm_f_log.py @@ -35,7 +35,7 @@ class TestLogEncoding_FLog: log_encoding_FLog` definition unit tests methods. """ - def test_log_encoding_FLog(self): + def test_log_encoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_encoding_FLog` definition. @@ -77,7 +77,7 @@ def test_log_encoding_FLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_FLog(self): + def test_n_dimensional_log_encoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_encoding_FLog` definition n-dimensional arrays support. @@ -104,7 +104,7 @@ def test_n_dimensional_log_encoding_FLog(self): log_encoding_FLog(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_FLog(self): + def test_domain_range_scale_log_encoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_encoding_FLog` definition domain and range scale support. @@ -123,7 +123,7 @@ def test_domain_range_scale_log_encoding_FLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_FLog(self): + def test_nan_log_encoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_encoding_FLog` definition nan support. @@ -138,7 +138,7 @@ class TestLogDecoding_FLog: log_decoding_FLog` definition unit tests methods. """ - def test_log_decoding_FLog(self): + def test_log_decoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_decoding_FLog` definition. @@ -180,7 +180,7 @@ def test_log_decoding_FLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_FLog(self): + def test_n_dimensional_log_decoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_decoding_FLog` definition n-dimensional arrays support. @@ -207,7 +207,7 @@ def test_n_dimensional_log_decoding_FLog(self): log_decoding_FLog(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_FLog(self): + def test_domain_range_scale_log_decoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_decoding_FLog` definition domain and range scale support. @@ -226,7 +226,7 @@ def test_domain_range_scale_log_decoding_FLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_FLog(self): + def test_nan_log_decoding_FLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_f_log.\ log_decoding_FLog` definition nan support. @@ -241,7 +241,7 @@ class TestLogEncoding_FLog2: log_encoding_FLog2` definition unit tests methods. """ - def test_log_encoding_FLog2(self): + def test_log_encoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_encoding_FLog2` definition. @@ -283,7 +283,7 @@ def test_log_encoding_FLog2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_FLog2(self): + def test_n_dimensional_log_encoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_encoding_FLog2` definition n-dimensional arrays support. @@ -310,7 +310,7 @@ def test_n_dimensional_log_encoding_FLog2(self): log_encoding_FLog2(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_FLog2(self): + def test_domain_range_scale_log_encoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_encoding_FLog2` definition domain and range scale support. @@ -327,7 +327,7 @@ def test_domain_range_scale_log_encoding_FLog2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_FLog2(self): + def test_nan_log_encoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_encoding_FLog2` definition nan support. @@ -342,7 +342,7 @@ class TestLogDecoding_FLog2: log_decoding_FLog2` definition unit tests methods. """ - def test_log_decoding_FLog2(self): + def test_log_decoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_decoding_FLog2` definition. @@ -384,7 +384,7 @@ def test_log_decoding_FLog2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_FLog2(self): + def test_n_dimensional_log_decoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_decoding_FLog2` definition n-dimensional arrays support. @@ -411,7 +411,7 @@ def test_n_dimensional_log_decoding_FLog2(self): log_decoding_FLog2(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_FLog2(self): + def test_domain_range_scale_log_decoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_decoding_FLog2` definition domain and range scale support. @@ -429,7 +429,7 @@ def test_domain_range_scale_log_decoding_FLog2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_FLog2(self): + def test_nan_log_decoding_FLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.fujifilm_flog.\ log_decoding_FLog2` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_gamma.py b/colour/models/rgb/transfer_functions/tests/test_gamma.py index d7e83aca2..97faddae6 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gamma.py +++ b/colour/models/rgb/transfer_functions/tests/test_gamma.py @@ -27,7 +27,7 @@ class TestGammaFunction: definition unit tests methods. """ - def test_gamma_function(self): + def test_gamma_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gamma.\ gamma_function` definition. @@ -93,7 +93,7 @@ def test_gamma_function(self): gamma_function(0.0, 2.2, "Clamp"), 0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_gamma_function(self): + def test_n_dimensional_gamma_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gamma.\ gamma_function` definition n-dimensional arrays support. @@ -209,7 +209,7 @@ def test_n_dimensional_gamma_function(self): ) @ignore_numpy_errors - def test_nan_gamma_function(self): + def test_nan_gamma_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gamma.\ gamma_function` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_gopro.py b/colour/models/rgb/transfer_functions/tests/test_gopro.py index 8ea944ca9..6ea2eda7d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_gopro.py +++ b/colour/models/rgb/transfer_functions/tests/test_gopro.py @@ -31,7 +31,7 @@ class TestLogEncoding_Protune: log_encoding_Protune` definition unit tests methods. """ - def test_log_encoding_Protune(self): + def test_log_encoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_encoding_Protune` definition. @@ -51,7 +51,7 @@ def test_log_encoding_Protune(self): log_encoding_Protune(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_encoding_Protune(self): + def test_n_dimensional_log_encoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_encoding_Protune` definition n-dimensional arrays support. @@ -78,7 +78,7 @@ def test_n_dimensional_log_encoding_Protune(self): log_encoding_Protune(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Protune(self): + def test_domain_range_scale_log_encoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_encoding_Protune` definition domain and range scale support. @@ -97,7 +97,7 @@ def test_domain_range_scale_log_encoding_Protune(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Protune(self): + def test_nan_log_encoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_encoding_Protune` definition nan support. @@ -112,7 +112,7 @@ class TestLogDecoding_Protune: log_decoding_Protune` definition unit tests methods. """ - def test_log_decoding_Protune(self): + def test_log_decoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_decoding_Protune` definition. @@ -132,7 +132,7 @@ def test_log_decoding_Protune(self): log_decoding_Protune(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_decoding_Protune(self): + def test_n_dimensional_log_decoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_decoding_Protune` definition n-dimensional arrays support. @@ -159,7 +159,7 @@ def test_n_dimensional_log_decoding_Protune(self): log_decoding_Protune(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Protune(self): + def test_domain_range_scale_log_decoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_decoding_Protune` definition domain and range scale support. @@ -178,7 +178,7 @@ def test_domain_range_scale_log_decoding_Protune(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Protune(self): + def test_nan_log_decoding_Protune(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.gopro.\ log_decoding_Protune` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py index 5d9e9912e..d378c2e7e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py @@ -31,7 +31,7 @@ class TestOetf_BT1361: definition unit tests methods. """ - def test_oetf_BT1361(self): + def test_oetf_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_BT1361` definition. @@ -57,7 +57,7 @@ def test_oetf_BT1361(self): np.testing.assert_allclose(oetf_BT1361(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_oetf_BT1361(self): + def test_n_dimensional_oetf_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_BT1361` definition n-dimensional arrays support. @@ -78,7 +78,7 @@ def test_n_dimensional_oetf_BT1361(self): V = np.reshape(V, (2, 3, 1)) np.testing.assert_allclose(oetf_BT1361(L), V, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_oetf_BT1361(self): + def test_domain_range_scale_oetf_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_BT1361` definition domain and range scale support. @@ -97,7 +97,7 @@ def test_domain_range_scale_oetf_BT1361(self): ) @ignore_numpy_errors - def test_nan_oetf_BT1361(self): + def test_nan_oetf_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_BT1361` definition nan support. @@ -112,7 +112,7 @@ class TestOetf_inverse_BT1361: oetf_inverse_BT1361` definition unit tests methods. """ - def test_oetf_inverse_BT1361(self): + def test_oetf_inverse_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_inverse_BT1361` definition. @@ -144,7 +144,7 @@ def test_oetf_inverse_BT1361(self): oetf_inverse_BT1361(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_BT1361(self): + def test_n_dimensional_oetf_inverse_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_inverse_BT1361` definition n-dimensional arrays support. @@ -171,7 +171,7 @@ def test_n_dimensional_oetf_inverse_BT1361(self): oetf_inverse_BT1361(V), L, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT1361(self): + def test_domain_range_scale_oetf_inverse_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_inverse_BT1361` definition domain and range scale support. @@ -190,7 +190,7 @@ def test_domain_range_scale_oetf_inverse_BT1361(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT1361(self): + def test_nan_oetf_inverse_BT1361(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1361.\ oetf_inverse_BT1361` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py index e0fdba9fd..36d7ddbba 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py @@ -31,7 +31,7 @@ class TestEotf_inverse_BT1886: eotf_inverse_BT1886` definition unit tests methods. """ - def test_eotf_inverse_BT1886(self): + def test_eotf_inverse_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_inverse_BT1886` definition. @@ -51,7 +51,7 @@ def test_eotf_inverse_BT1886(self): eotf_inverse_BT1886(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_inverse_BT1886(self): + def test_n_dimensional_eotf_inverse_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_inverse_BT1886` definition n-dimensional arrays support. @@ -78,7 +78,7 @@ def test_n_dimensional_eotf_inverse_BT1886(self): eotf_inverse_BT1886(L), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_BT1886(self): + def test_domain_range_scale_eotf_inverse_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_inverse_BT1886` definition domain and range scale support. @@ -97,7 +97,7 @@ def test_domain_range_scale_eotf_inverse_BT1886(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_BT1886(self): + def test_nan_eotf_inverse_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_inverse_BT1886` definition nan support. @@ -112,7 +112,7 @@ class TestEotf_BT1886: eotf_BT1886` definition unit tests methods. """ - def test_eotf_BT1886(self): + def test_eotf_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_BT1886` definition. @@ -126,7 +126,7 @@ def test_eotf_BT1886(self): np.testing.assert_allclose(eotf_BT1886(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_eotf_BT1886(self): + def test_n_dimensional_eotf_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_BT1886` definition n-dimensional arrays support. @@ -147,7 +147,7 @@ def test_n_dimensional_eotf_BT1886(self): L = np.reshape(L, (2, 3, 1)) np.testing.assert_allclose(eotf_BT1886(V), L, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_eotf_BT1886(self): + def test_domain_range_scale_eotf_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_BT1886` definition domain and range scale support. @@ -166,7 +166,7 @@ def test_domain_range_scale_eotf_BT1886(self): ) @ignore_numpy_errors - def test_nan_eotf_BT1886(self): + def test_nan_eotf_BT1886(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_1886.\ eotf_BT1886` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py index 05a74cfdd..62253d167 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py @@ -31,7 +31,7 @@ class TestOetf_BT2020: oetf_BT2020` definition unit tests methods. """ - def test_oetf_BT2020(self): + def test_oetf_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_BT2020` definition. @@ -45,7 +45,7 @@ def test_oetf_BT2020(self): np.testing.assert_allclose(oetf_BT2020(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_oetf_BT2020(self): + def test_n_dimensional_oetf_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_BT2020` definition n-dimensional arrays support. @@ -66,7 +66,7 @@ def test_n_dimensional_oetf_BT2020(self): E_p = np.reshape(E_p, (2, 3, 1)) np.testing.assert_allclose(oetf_BT2020(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_oetf_BT2020(self): + def test_domain_range_scale_oetf_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_BT2020` definition domain and range scale support. @@ -85,7 +85,7 @@ def test_domain_range_scale_oetf_BT2020(self): ) @ignore_numpy_errors - def test_nan_oetf_BT2020(self): + def test_nan_oetf_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_BT2020` definition nan support. @@ -100,7 +100,7 @@ class TestOetf_inverse_BT2020: oetf_inverse_BT2020` definition unit tests methods. """ - def test_oetf_inverse_BT2020(self): + def test_oetf_inverse_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_inverse_BT2020` definition. @@ -120,7 +120,7 @@ def test_oetf_inverse_BT2020(self): oetf_inverse_BT2020(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_BT2020(self): + def test_n_dimensional_oetf_inverse_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_inverse_BT2020` definition n-dimensional arrays support. @@ -147,7 +147,7 @@ def test_n_dimensional_oetf_inverse_BT2020(self): oetf_inverse_BT2020(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT2020(self): + def test_domain_range_scale_oetf_inverse_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_inverse_BT2020` definition domain and range scale support. @@ -166,7 +166,7 @@ def test_domain_range_scale_oetf_inverse_BT2020(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT2020(self): + def test_nan_oetf_inverse_BT2020(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2020.\ oetf_inverse_BT2020` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py index e856a0741..376d33e86 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2100.py @@ -63,7 +63,7 @@ class TestOetf_BT2100_PQ: oetf_BT2100_PQ` definition unit tests methods. """ - def test_oetf_BT2100_PQ(self): + def test_oetf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_PQ` definition. @@ -87,7 +87,7 @@ def test_oetf_BT2100_PQ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_BT2100_PQ(self): + def test_n_dimensional_oetf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_PQ` definition n-dimensional arrays support. @@ -114,7 +114,7 @@ def test_n_dimensional_oetf_BT2100_PQ(self): oetf_BT2100_PQ(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_BT2100_PQ(self): + def test_domain_range_scale_oetf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_PQ` definition domain and range scale support. @@ -133,7 +133,7 @@ def test_domain_range_scale_oetf_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_oetf_BT2100_PQ(self): + def test_nan_oetf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_PQ` definition nan support. @@ -148,7 +148,7 @@ class TestOetf_inverse_BT2100_PQ: oetf_inverse_BT2100_PQ` definition unit tests methods. """ - def test_oetf_inverse_BT2100_PQ(self): + def test_oetf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_PQ` definition. @@ -172,7 +172,7 @@ def test_oetf_inverse_BT2100_PQ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_BT2100_PQ(self): + def test_n_dimensional_oetf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_PQ` definition n-dimensional arrays support. @@ -199,7 +199,7 @@ def test_n_dimensional_oetf_inverse_BT2100_PQ(self): oetf_inverse_BT2100_PQ(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT2100_PQ(self): + def test_domain_range_scale_oetf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_PQ` definition domain and range scale support. @@ -218,7 +218,7 @@ def test_domain_range_scale_oetf_inverse_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT2100_PQ(self): + def test_nan_oetf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_PQ` definition nan support. @@ -233,7 +233,7 @@ class TestEotf_BT2100_PQ: eotf_BT2100_PQ` definition unit tests methods. """ - def test_eotf_BT2100_PQ(self): + def test_eotf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_PQ` definition. @@ -253,7 +253,7 @@ def test_eotf_BT2100_PQ(self): eotf_BT2100_PQ(1.0), 10000.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_BT2100_PQ(self): + def test_n_dimensional_eotf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_PQ` definition n-dimensional arrays support. @@ -280,7 +280,7 @@ def test_n_dimensional_eotf_BT2100_PQ(self): eotf_BT2100_PQ(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_BT2100_PQ(self): + def test_domain_range_scale_eotf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_PQ` definition domain and range scale support. @@ -299,7 +299,7 @@ def test_domain_range_scale_eotf_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_eotf_BT2100_PQ(self): + def test_nan_eotf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_PQ` definition nan support. @@ -314,7 +314,7 @@ class TestEotf_inverse_BT2100_PQ: eotf_inverse_BT2100_PQ` definition unit tests methods. """ - def test_eotf_inverse_BT2100_PQ(self): + def test_eotf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_PQ` definition. @@ -336,7 +336,7 @@ def test_eotf_inverse_BT2100_PQ(self): eotf_inverse_BT2100_PQ(10000.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_inverse_BT2100_PQ(self): + def test_n_dimensional_eotf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_PQ` definition n-dimensional arrays support. @@ -363,7 +363,7 @@ def test_n_dimensional_eotf_inverse_BT2100_PQ(self): eotf_inverse_BT2100_PQ(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_BT2100_PQ(self): + def test_domain_range_scale_eotf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_PQ` definition domain and range scale support. @@ -382,7 +382,7 @@ def test_domain_range_scale_eotf_inverse_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_BT2100_PQ(self): + def test_nan_eotf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_PQ` definition nan support. @@ -397,7 +397,7 @@ class TestOotf_BT2100_PQ: ootf_BT2100_PQ` definition unit tests methods. """ - def test_ootf_BT2100_PQ(self): + def test_ootf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_PQ` definition. @@ -419,7 +419,7 @@ def test_ootf_BT2100_PQ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_BT2100_PQ(self): + def test_n_dimensional_ootf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_PQ` definition n-dimensional arrays support. @@ -446,7 +446,7 @@ def test_n_dimensional_ootf_BT2100_PQ(self): ootf_BT2100_PQ(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_BT2100_PQ(self): + def test_domain_range_scale_ootf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_PQ` definition domain and range scale support. @@ -465,7 +465,7 @@ def test_domain_range_scale_ootf_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_ootf_BT2100_PQ(self): + def test_nan_ootf_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_PQ` definition nan support. @@ -480,7 +480,7 @@ class TestOotf_inverse_BT2100_PQ: ootf_inverse_BT2100_PQ` definition unit tests methods. """ - def test_ootf_inverse_BT2100_PQ(self): + def test_ootf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_PQ` definition. @@ -502,7 +502,7 @@ def test_ootf_inverse_BT2100_PQ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_inverse_BT2100_PQ(self): + def test_n_dimensional_ootf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_PQ` definition n-dimensional arrays support. @@ -529,7 +529,7 @@ def test_n_dimensional_ootf_inverse_BT2100_PQ(self): ootf_inverse_BT2100_PQ(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_inverse_BT2100_PQ(self): + def test_domain_range_scale_ootf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_PQ` definition domain and range scale support. @@ -548,7 +548,7 @@ def test_domain_range_scale_ootf_inverse_BT2100_PQ(self): ) @ignore_numpy_errors - def test_nan_ootf_inverse_BT2100_PQ(self): + def test_nan_ootf_inverse_BT2100_PQ(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_PQ` definition nan support. @@ -563,7 +563,7 @@ class TestGamma_function_BT2100_HLG: gamma_function_BT2100_HLG` definition unit tests methods. """ - def test_gamma_function_BT2100_HLG(self): + def test_gamma_function_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ gamma_function_BT2100_HLG` definition. @@ -600,7 +600,7 @@ class TestOetf_BT2100_HLG: oetf_BT2100_HLG` definition unit tests methods. """ - def test_oetf_BT2100_HLG(self): + def test_oetf_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_HLG` definition. @@ -622,7 +622,7 @@ def test_oetf_BT2100_HLG(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_BT2100_HLG(self): + def test_n_dimensional_oetf_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_HLG` definition n-dimensional arrays support. @@ -649,7 +649,7 @@ def test_n_dimensional_oetf_BT2100_HLG(self): oetf_BT2100_HLG(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_BT2100_HLG(self): + def test_domain_range_scale_oetf_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_HLG` definition domain and range scale support. @@ -668,7 +668,7 @@ def test_domain_range_scale_oetf_BT2100_HLG(self): ) @ignore_numpy_errors - def test_nan_oetf_BT2100_HLG(self): + def test_nan_oetf_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_BT2100_HLG` definition nan support. @@ -683,7 +683,7 @@ class TestOetf_inverse_BT2100_HLG: oetf_inverse_BT2100_HLG` definition unit tests methods. """ - def test_oetf_inverse_BT2100_HLG(self): + def test_oetf_inverse_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_HLG` definition. @@ -705,7 +705,7 @@ def test_oetf_inverse_BT2100_HLG(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_BT2100_HLG(self): + def test_n_dimensional_oetf_inverse_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_HLG` definition n-dimensional arrays support. @@ -732,7 +732,7 @@ def test_n_dimensional_oetf_inverse_BT2100_HLG(self): oetf_inverse_BT2100_HLG(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT2100_HLG(self): + def test_domain_range_scale_oetf_inverse_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_HLG` definition domain and range scale support. @@ -751,7 +751,7 @@ def test_domain_range_scale_oetf_inverse_BT2100_HLG(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT2100_HLG(self): + def test_nan_oetf_inverse_BT2100_HLG(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ oetf_inverse_BT2100_HLG` definition nan support. @@ -766,7 +766,7 @@ class TestEotf_BT2100_HLG_1: eotf_BT2100_HLG_1` definition unit tests methods. """ - def test_eotf_BT2100_HLG_1(self): + def test_eotf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_1` definition. @@ -794,7 +794,7 @@ def test_eotf_BT2100_HLG_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_BT2100_HLG_1(self): + def test_n_dimensional_eotf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_1` definition n-dimensional arrays support. @@ -845,7 +845,7 @@ def test_n_dimensional_eotf_BT2100_HLG_1(self): eotf_BT2100_HLG_1(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_BT2100_HLG_1(self): + def test_domain_range_scale_eotf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_1` definition domain and range scale support. @@ -864,7 +864,7 @@ def test_domain_range_scale_eotf_BT2100_HLG_1(self): ) @ignore_numpy_errors - def test_nan_eotf_BT2100_HLG_1(self): + def test_nan_eotf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_1` definition nan support. @@ -879,7 +879,7 @@ class TestEotf_BT2100_HLG_2: eotf_BT2100_HLG_2` definition unit tests methods. """ - def test_eotf_BT2100_HLG_2(self): + def test_eotf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_2` definition. @@ -907,7 +907,7 @@ def test_eotf_BT2100_HLG_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_BT2100_HLG_2(self): + def test_n_dimensional_eotf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_2` definition n-dimensional arrays support. @@ -958,7 +958,7 @@ def test_n_dimensional_eotf_BT2100_HLG_2(self): eotf_BT2100_HLG_2(E_p), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_BT2100_HLG_2(self): + def test_domain_range_scale_eotf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_2` definition domain and range scale support. @@ -977,7 +977,7 @@ def test_domain_range_scale_eotf_BT2100_HLG_2(self): ) @ignore_numpy_errors - def test_nan_eotf_BT2100_HLG_2(self): + def test_nan_eotf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_BT2100_HLG_2` definition nan support. @@ -992,7 +992,7 @@ class TestEotf_inverse_BT2100_HLG_1: eotf_inverse_BT2100_HLG_1` definition unit tests methods. """ - def test_eotf_inverse_BT2100_HLG_1(self): + def test_eotf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_1` definition. @@ -1020,7 +1020,7 @@ def test_eotf_inverse_BT2100_HLG_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_inverse_BT2100_HLG_1(self): + def test_n_dimensional_eotf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_1` definition n-dimensional arrays support. @@ -1071,7 +1071,7 @@ def test_n_dimensional_eotf_inverse_BT2100_HLG_1(self): eotf_inverse_BT2100_HLG_1(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_BT2100_HLG_1(self): + def test_domain_range_scale_eotf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_1` definition domain and range scale support. @@ -1090,7 +1090,7 @@ def test_domain_range_scale_eotf_inverse_BT2100_HLG_1(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_BT2100_HLG_1(self): + def test_nan_eotf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_1` definition nan support. @@ -1105,7 +1105,7 @@ class TestEotf_inverse_BT2100_HLG_2: eotf_inverse_BT2100_HLG_2` definition unit tests methods. """ - def test_eotf_inverse_BT2100_HLG_2(self): + def test_eotf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_2` definition. @@ -1133,7 +1133,7 @@ def test_eotf_inverse_BT2100_HLG_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_inverse_BT2100_HLG_2(self): + def test_n_dimensional_eotf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_2` definition n-dimensional arrays support. @@ -1184,7 +1184,7 @@ def test_n_dimensional_eotf_inverse_BT2100_HLG_2(self): eotf_inverse_BT2100_HLG_2(F_D), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_BT2100_HLG_2(self): + def test_domain_range_scale_eotf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_2` definition domain and range scale support. @@ -1203,7 +1203,7 @@ def test_domain_range_scale_eotf_inverse_BT2100_HLG_2(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_BT2100_HLG_2(self): + def test_nan_eotf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ eotf_inverse_BT2100_HLG_2` definition nan support. @@ -1218,7 +1218,7 @@ class TestOotf_BT2100_HLG_1: ootf_BT2100_HLG_1` definition unit tests methods. """ - def test_ootf_BT2100_HLG_1(self): + def test_ootf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition. @@ -1271,7 +1271,7 @@ def test_ootf_BT2100_HLG_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_BT2100_HLG_1(self): + def test_n_dimensional_ootf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition n-dimensional arrays support. @@ -1322,7 +1322,7 @@ def test_n_dimensional_ootf_BT2100_HLG_1(self): ootf_BT2100_HLG_1(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_BT2100_HLG_1(self): + def test_domain_range_scale_ootf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition domain and range scale support. @@ -1341,7 +1341,7 @@ def test_domain_range_scale_ootf_BT2100_HLG_1(self): ) @ignore_numpy_errors - def test_nan_ootf_BT2100_HLG_1(self): + def test_nan_ootf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition nan support. @@ -1356,7 +1356,7 @@ class TestOotf_BT2100_HLG_2: ootf_BT2100_HLG_2` definition unit tests methods. """ - def test_ootf_BT2100_HLG_2(self): + def test_ootf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_2` definition. @@ -1409,7 +1409,7 @@ def test_ootf_BT2100_HLG_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_BT2100_HLG_2(self): + def test_n_dimensional_ootf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_2` definition n-dimensional arrays support. @@ -1460,7 +1460,7 @@ def test_n_dimensional_ootf_BT2100_HLG_2(self): ootf_BT2100_HLG_2(E), F_D, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_BT2100_HLG_2(self): + def test_domain_range_scale_ootf_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_2` definition domain and range scale support. @@ -1479,7 +1479,7 @@ def test_domain_range_scale_ootf_BT2100_HLG_2(self): ) @ignore_numpy_errors - def test_nan_ootf_BT2100_HLG_1(self): + def test_nan_ootf_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_BT2100_HLG_1` definition nan support. @@ -1494,7 +1494,7 @@ class TestOotf_inverse_BT2100_HLG_1: ootf_inverse_BT2100_HLG_1` definition unit tests methods. """ - def test_ootf_inverse_BT2100_HLG_1(self): + def test_ootf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_1` definition. @@ -1547,7 +1547,7 @@ def test_ootf_inverse_BT2100_HLG_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_inverse_BT2100_HLG_1(self): + def test_n_dimensional_ootf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_1` definition n-dimensional arrays support. @@ -1598,7 +1598,7 @@ def test_n_dimensional_ootf_inverse_BT2100_HLG_1(self): ootf_inverse_BT2100_HLG_1(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_inverse_BT2100_HLG_1(self): + def test_domain_range_scale_ootf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_1` definition domain and range scale support. @@ -1617,7 +1617,7 @@ def test_domain_range_scale_ootf_inverse_BT2100_HLG_1(self): ) @ignore_numpy_errors - def test_nan_ootf_inverse_BT2100_HLG_1(self): + def test_nan_ootf_inverse_BT2100_HLG_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_1` definition nan support. @@ -1632,7 +1632,7 @@ class TestOotf_inverse_BT2100_HLG_2: ootf_inverse_BT2100_HLG_2` definition unit tests methods. """ - def test_ootf_inverse_BT2100_HLG_2(self): + def test_ootf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_2` definition. @@ -1685,7 +1685,7 @@ def test_ootf_inverse_BT2100_HLG_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ootf_inverse_BT2100_HLG_2(self): + def test_n_dimensional_ootf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_2` definition n-dimensional arrays support. @@ -1736,7 +1736,7 @@ def test_n_dimensional_ootf_inverse_BT2100_HLG_2(self): ootf_inverse_BT2100_HLG_2(F_D), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ootf_inverse_BT2100_HLG_2(self): + def test_domain_range_scale_ootf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_2` definition domain and range scale support. @@ -1755,7 +1755,7 @@ def test_domain_range_scale_ootf_inverse_BT2100_HLG_2(self): ) @ignore_numpy_errors - def test_nan_ootf_inverse_BT2100_HLG_2(self): + def test_nan_ootf_inverse_BT2100_HLG_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_2100.\ ootf_inverse_BT2100_HLG_2` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py index 5a3651ab4..cff4c5961 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_601.py @@ -28,7 +28,7 @@ class TestOetf_BT601: definition unit tests methods. """ - def test_oetf_BT601(self): + def test_oetf_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_BT601` definition. @@ -46,7 +46,7 @@ def test_oetf_BT601(self): np.testing.assert_allclose(oetf_BT601(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_oetf_BT601(self): + def test_n_dimensional_oetf_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_BT601` definition n-dimensional arrays support. @@ -67,7 +67,7 @@ def test_n_dimensional_oetf_BT601(self): E = np.reshape(E, (2, 3, 1)) np.testing.assert_allclose(oetf_BT601(L), E, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_oetf_BT601(self): + def test_domain_range_scale_oetf_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_BT601` definition domain and range scale support. @@ -86,7 +86,7 @@ def test_domain_range_scale_oetf_BT601(self): ) @ignore_numpy_errors - def test_nan_oetf_BT601(self): + def test_nan_oetf_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_BT601` definition nan support. @@ -101,7 +101,7 @@ class TestOetf_inverse_BT601: oetf_inverse_BT601` definition unit tests methods. """ - def test_oetf_inverse_BT601(self): + def test_oetf_inverse_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_inverse_BT601` definition. @@ -127,7 +127,7 @@ def test_oetf_inverse_BT601(self): oetf_inverse_BT601(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_BT601(self): + def test_n_dimensional_oetf_inverse_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_inverse_BT601` definition n-dimensional arrays support. @@ -154,7 +154,7 @@ def test_n_dimensional_oetf_inverse_BT601(self): oetf_inverse_BT601(E), L, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT601(self): + def test_domain_range_scale_oetf_inverse_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_inverse_BT601` definition domain and range scale support. @@ -173,7 +173,7 @@ def test_domain_range_scale_oetf_inverse_BT601(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT601(self): + def test_nan_oetf_inverse_BT601(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_601.\ oetf_inverse_BT601` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py index 4a1213037..12b628682 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_709.py @@ -28,7 +28,7 @@ class TestOetf_BT709: definition unit tests methods. """ - def test_oetf_BT709(self): + def test_oetf_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_BT709` definition. @@ -46,7 +46,7 @@ def test_oetf_BT709(self): np.testing.assert_allclose(oetf_BT709(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_oetf_BT709(self): + def test_n_dimensional_oetf_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_BT709` definition n-dimensional arrays support. @@ -67,7 +67,7 @@ def test_n_dimensional_oetf_BT709(self): V = np.reshape(V, (2, 3, 1)) np.testing.assert_allclose(oetf_BT709(L), V, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_oetf_BT709(self): + def test_domain_range_scale_oetf_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_BT709` definition domain and range scale support. @@ -86,7 +86,7 @@ def test_domain_range_scale_oetf_BT709(self): ) @ignore_numpy_errors - def test_nan_oetf_BT709(self): + def test_nan_oetf_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_BT709` definition nan support. @@ -101,7 +101,7 @@ class TestOetf_inverse_BT709: oetf_inverse_BT709` definition unit tests methods. """ - def test_oetf_inverse_BT709(self): + def test_oetf_inverse_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_inverse_BT709` definition. @@ -127,7 +127,7 @@ def test_oetf_inverse_BT709(self): oetf_inverse_BT709(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_BT709(self): + def test_n_dimensional_oetf_inverse_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_inverse_BT709` definition n-dimensional arrays support. @@ -154,7 +154,7 @@ def test_n_dimensional_oetf_inverse_BT709(self): oetf_inverse_BT709(V), L, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_BT709(self): + def test_domain_range_scale_oetf_inverse_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_inverse_BT709` definition domain and range scale support. @@ -173,7 +173,7 @@ def test_domain_range_scale_oetf_inverse_BT709(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_BT709(self): + def test_nan_oetf_inverse_BT709(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itur_bt_709.\ oetf_inverse_BT709` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py b/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py index 0ee07ec45..1d825e96c 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py +++ b/colour/models/rgb/transfer_functions/tests/test_itut_h_273.py @@ -43,7 +43,7 @@ class TestOetf_H273_Log: oetf_H273_Log` definition unit tests methods. """ - def test_oetf_H273_Log(self): + def test_oetf_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_Log` definition. @@ -63,7 +63,7 @@ def test_oetf_H273_Log(self): oetf_H273_Log(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_H273_Log(self): + def test_n_dimensional_oetf_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_Log` definition n-dimensional arrays support. @@ -84,7 +84,7 @@ def test_n_dimensional_oetf_H273_Log(self): E_p = np.reshape(E_p, (2, 3, 1)) np.testing.assert_allclose(oetf_H273_Log(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_oetf_H273_Log(self): + def test_domain_range_scale_oetf_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_Log` definition domain and range scale support. @@ -103,7 +103,7 @@ def test_domain_range_scale_oetf_H273_Log(self): ) @ignore_numpy_errors - def test_nan_oetf_H273_Log(self): + def test_nan_oetf_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_Log` definition nan support. @@ -118,7 +118,7 @@ class TestOetf_inverse_H273_Log: oetf_inverse_H273_Log` definition unit tests methods. """ - def test_oetf_inverse_H273_Log(self): + def test_oetf_inverse_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_Log` definition. @@ -140,7 +140,7 @@ def test_oetf_inverse_H273_Log(self): oetf_inverse_H273_Log(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_H273_Log(self): + def test_n_dimensional_oetf_inverse_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_Log` definition n-dimensional arrays support. @@ -167,7 +167,7 @@ def test_n_dimensional_oetf_inverse_H273_Log(self): oetf_inverse_H273_Log(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_H273_Log(self): + def test_domain_range_scale_oetf_inverse_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_Log` definition domain and range scale support. @@ -186,7 +186,7 @@ def test_domain_range_scale_oetf_inverse_H273_Log(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_H273_Log(self): + def test_nan_oetf_inverse_H273_Log(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_Log` definition nan support. @@ -201,7 +201,7 @@ class TestOetf_H273_LogSqrt: oetf_H273_LogSqrt` definition unit tests methods. """ - def test_oetf_H273_LogSqrt(self): + def test_oetf_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_LogSqrt` definition. @@ -221,7 +221,7 @@ def test_oetf_H273_LogSqrt(self): oetf_H273_LogSqrt(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_H273_LogSqrt(self): + def test_n_dimensional_oetf_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_LogSqrt` definition n-dimensional arrays support. @@ -248,7 +248,7 @@ def test_n_dimensional_oetf_H273_LogSqrt(self): oetf_H273_LogSqrt(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_H273_LogSqrt(self): + def test_domain_range_scale_oetf_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_LogSqrt` definition domain and range scale support. @@ -267,7 +267,7 @@ def test_domain_range_scale_oetf_H273_LogSqrt(self): ) @ignore_numpy_errors - def test_nan_oetf_H273_LogSqrt(self): + def test_nan_oetf_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_LogSqrt` definition nan support. @@ -282,7 +282,7 @@ class TestOetf_inverse_H273_LogSqrt: oetf_inverse_H273_LogSqrt` definition unit tests methods. """ - def test_oetf_inverse_H273_LogSqrt(self): + def test_oetf_inverse_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_LogSqrt` definition. @@ -306,7 +306,7 @@ def test_oetf_inverse_H273_LogSqrt(self): oetf_inverse_H273_LogSqrt(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_inverse_H273_LogSqrt(self): + def test_n_dimensional_oetf_inverse_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_LogSqrt` definition n-dimensional arrays support. @@ -333,7 +333,7 @@ def test_n_dimensional_oetf_inverse_H273_LogSqrt(self): oetf_inverse_H273_LogSqrt(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_H273_LogSqrt(self): + def test_domain_range_scale_oetf_inverse_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_LogSqrt` definition domain and range scale support. @@ -352,7 +352,7 @@ def test_domain_range_scale_oetf_inverse_H273_LogSqrt(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_H273_LogSqrt(self): + def test_nan_oetf_inverse_H273_LogSqrt(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_LogSqrt` definition nan support. @@ -367,7 +367,7 @@ class TestOetf_H273_IEC61966_2: oetf_H273_IEC61966_2` definition unit tests methods. """ - def test_oetf_H273_IEC61966_2(self): + def test_oetf_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_IEC61966_2` definition. @@ -393,7 +393,7 @@ def test_oetf_H273_IEC61966_2(self): oetf_H273_IEC61966_2(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_H273_IEC61966_2(self): + def test_n_dimensional_oetf_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_IEC61966_2` definition n-dimensional arrays support. @@ -420,7 +420,7 @@ def test_n_dimensional_oetf_H273_IEC61966_2(self): oetf_H273_IEC61966_2(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_H273_IEC61966_2(self): + def test_domain_range_scale_oetf_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_IEC61966_2` definition domain and range scale support. @@ -439,7 +439,7 @@ def test_domain_range_scale_oetf_H273_IEC61966_2(self): ) @ignore_numpy_errors - def test_nan_oetf_H273_IEC61966_2(self): + def test_nan_oetf_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_H273_IEC61966_2` definition nan support. @@ -454,7 +454,7 @@ class TestOetf_inverse_H273_IEC61966_2: oetf_inverse_H273_IEC61966_2` definition unit tests methods. """ - def test_oetf_inverse_H273_IEC61966_2(self): + def test_oetf_inverse_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_IEC61966_2` definition. @@ -484,7 +484,7 @@ def test_oetf_inverse_H273_IEC61966_2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_oetf_inverse_H273_IEC61966_2(self): + def test_n_dimensional_oetf_inverse_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_IEC61966_2` definition n-dimensional arrays support. @@ -511,7 +511,7 @@ def test_n_dimensional_oetf_inverse_H273_IEC61966_2(self): oetf_inverse_H273_IEC61966_2(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_inverse_H273_IEC61966_2(self): + def test_domain_range_scale_oetf_inverse_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_IEC61966_2` definition domain and range scale support. @@ -530,7 +530,7 @@ def test_domain_range_scale_oetf_inverse_H273_IEC61966_2(self): ) @ignore_numpy_errors - def test_nan_oetf_inverse_H273_IEC61966_2(self): + def test_nan_oetf_inverse_H273_IEC61966_2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ oetf_inverse_H273_IEC61966_2` definition nan support. @@ -547,7 +547,7 @@ class TestEotf_inverse_H273_ST428_1: eotf_inverse_H273_ST428_1` definition unit tests methods. """ - def test_eotf_inverse_H273_ST428_1(self): + def test_eotf_inverse_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_inverse_H273_ST428_1` definition. @@ -569,7 +569,7 @@ def test_eotf_inverse_H273_ST428_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_inverse_H273_ST428_1(self): + def test_n_dimensional_eotf_inverse_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_inverse_H273_ST428_1` definition n-dimensional arrays support. @@ -596,7 +596,7 @@ def test_n_dimensional_eotf_inverse_H273_ST428_1(self): eotf_inverse_H273_ST428_1(E), E_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_H273_ST428_1(self): + def test_domain_range_scale_eotf_inverse_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_inverse_H273_ST428_1` definition domain and range scale support. @@ -615,7 +615,7 @@ def test_domain_range_scale_eotf_inverse_H273_ST428_1(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_H273_ST428_1(self): + def test_nan_eotf_inverse_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_inverse_H273_ST428_1` definition nan support. @@ -630,7 +630,7 @@ class TestEotf_H273_ST428_1: eotf_H273_ST428_1` definition unit tests methods. """ - def test_eotf_H273_ST428_1(self): + def test_eotf_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_H273_ST428_1` definition. @@ -652,7 +652,7 @@ def test_eotf_H273_ST428_1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_eotf_H273_ST428_1(self): + def test_n_dimensional_eotf_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_H273_ST428_1` definition n-dimensional arrays support. @@ -679,7 +679,7 @@ def test_n_dimensional_eotf_H273_ST428_1(self): eotf_H273_ST428_1(E_p), E, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_H273_ST428_1(self): + def test_domain_range_scale_eotf_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_H273_ST428_1` definition domain and range scale support. @@ -698,7 +698,7 @@ def test_domain_range_scale_eotf_H273_ST428_1(self): ) @ignore_numpy_errors - def test_nan_eotf_H273_ST428_1(self): + def test_nan_eotf_H273_ST428_1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.itut_h_273.\ eotf_H273_ST428_1` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py index d9f24bd56..46ca315df 100644 --- a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_LLog: log_encoding_LLog` definition unit tests methods. """ - def test_log_encoding_LLog(self): + def test_log_encoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_encoding_LLog` definition. @@ -73,7 +73,7 @@ def test_log_encoding_LLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_LLog(self): + def test_n_dimensional_log_encoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_encoding_LLog` definition n-dimensional arrays support. @@ -100,7 +100,7 @@ def test_n_dimensional_log_encoding_LLog(self): log_encoding_LLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_LLog(self): + def test_domain_range_scale_log_encoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_encoding_LLog` definition domain and range scale support. @@ -119,7 +119,7 @@ def test_domain_range_scale_log_encoding_LLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_LLog(self): + def test_nan_log_encoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_encoding_LLog` definition nan support. @@ -134,7 +134,7 @@ class TestLogDecoding_LLog: log_decoding_LLog` definition unit tests methods. """ - def test_log_decoding_LLog(self): + def test_log_decoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_decoding_LLog` definition. @@ -176,7 +176,7 @@ def test_log_decoding_LLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_LLog(self): + def test_n_dimensional_log_decoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_decoding_LLog` definition n-dimensional arrays support. @@ -203,7 +203,7 @@ def test_n_dimensional_log_decoding_LLog(self): log_decoding_LLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_LLog(self): + def test_domain_range_scale_log_decoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_decoding_LLog` definition domain and range scale support. @@ -222,7 +222,7 @@ def test_domain_range_scale_log_decoding_LLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_LLog(self): + def test_nan_log_decoding_LLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.leica_l_log.\ log_decoding_LLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_linear.py b/colour/models/rgb/transfer_functions/tests/test_linear.py index d96254cdd..8c828ebe8 100644 --- a/colour/models/rgb/transfer_functions/tests/test_linear.py +++ b/colour/models/rgb/transfer_functions/tests/test_linear.py @@ -27,7 +27,7 @@ class TestLinearFunction: linear_function` definition unit tests methods. """ - def test_linear_function(self): + def test_linear_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.linear.\ linear_function` definition. @@ -39,7 +39,7 @@ def test_linear_function(self): assert linear_function(1.0) == 1.0 - def test_n_dimensional_linear_function(self): + def test_n_dimensional_linear_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.linear.\ linear_function` definition n-dimensional arrays support. @@ -67,7 +67,7 @@ def test_n_dimensional_linear_function(self): ) @ignore_numpy_errors - def test_nan_linear_function(self): + def test_nan_linear_function(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.linear.\ linear_function` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_log.py b/colour/models/rgb/transfer_functions/tests/test_log.py index e766727bd..bce25b756 100644 --- a/colour/models/rgb/transfer_functions/tests/test_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_log.py @@ -37,7 +37,7 @@ class TestLogarithmFunction_Basic: logarithmic_function_basic` definition unit tests methods. """ - def test_logarithmic_function_basic(self): + def test_logarithmic_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_basic` definition. @@ -79,7 +79,7 @@ def test_logarithmic_function_basic(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_logarithmic_function_basic(self): + def test_n_dimensional_logarithmic_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_basic` definition n-dimensional arrays support. @@ -116,7 +116,7 @@ def test_n_dimensional_logarithmic_function_basic(self): ) @ignore_numpy_errors - def test_nan_logarithmic_function_basic(self): + def test_nan_logarithmic_function_basic(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_basic` definition nan support. @@ -134,7 +134,7 @@ class TestLogarithmFunction_Quasilog: logarithmic_function_quasilog` definition unit tests methods. """ - def test_logarithmic_function_quasilog(self): + def test_logarithmic_function_quasilog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_quasilog` definition. @@ -220,7 +220,7 @@ def test_logarithmic_function_quasilog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_logarithmic_function_quasilog(self): + def test_n_dimensional_logarithmic_function_quasilog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_quasilog` definition n-dimensional arrays support. @@ -257,7 +257,7 @@ def test_n_dimensional_logarithmic_function_quasilog(self): ) @ignore_numpy_errors - def test_nan_logarithmic_function_quasilog(self): + def test_nan_logarithmic_function_quasilog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_quasilog` definition nan support. @@ -275,7 +275,7 @@ class TestLogarithmFunction_Camera: logarithmic_function_camera` definition unit tests methods. """ - def test_logarithmic_function_camera(self): + def test_logarithmic_function_camera(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_camera` definition. @@ -432,7 +432,7 @@ def test_logarithmic_function_camera(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_logarithmic_function_camera(self): + def test_n_dimensional_logarithmic_function_camera(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_camera` definition n-dimensional arrays support. @@ -469,7 +469,7 @@ def test_n_dimensional_logarithmic_function_camera(self): ) @ignore_numpy_errors - def test_nan_logarithmic_function_camera(self): + def test_nan_logarithmic_function_camera(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ logarithmic_function_camera` definition nan support. @@ -487,7 +487,7 @@ class TestLogEncoding_Log2: log_encoding_Log2` definition unit tests methods. """ - def test_log_encoding_Log2(self): + def test_log_encoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_encoding_Log2` definition. @@ -525,7 +525,7 @@ def test_log_encoding_Log2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Log2(self): + def test_n_dimensional_log_encoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_encoding_Log2` definition n-dimensional arrays support. @@ -552,7 +552,7 @@ def test_n_dimensional_log_encoding_Log2(self): log_encoding_Log2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Log2(self): + def test_domain_range_scale_log_encoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_encoding_Log2` definition domain and range scale support. @@ -571,7 +571,7 @@ def test_domain_range_scale_log_encoding_Log2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Log2(self): + def test_nan_log_encoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_encoding_Log2` definition nan support. @@ -586,7 +586,7 @@ class TestLogDecoding_Log2: log_decoding_Log2` definition unit tests methods. """ - def test_log_decoding_Log2(self): + def test_log_decoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_decoding_Log2` definition. @@ -626,7 +626,7 @@ def test_log_decoding_Log2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Log2(self): + def test_n_dimensional_log_decoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_decoding_Log2` definition n-dimensional arrays support. @@ -653,7 +653,7 @@ def test_n_dimensional_log_decoding_Log2(self): log_decoding_Log2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Log2(self): + def test_domain_range_scale_log_decoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_decoding_Log2` definition domain and range scale support. @@ -672,7 +672,7 @@ def test_domain_range_scale_log_decoding_Log2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Log2(self): + def test_nan_log_decoding_Log2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.log.\ log_decoding_Log2` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py index 04e75ea83..64e8f3434 100644 --- a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_NLog: log_encoding_NLog` definition unit tests methods. """ - def test_log_encoding_NLog(self): + def test_log_encoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_encoding_NLog` definition. @@ -73,7 +73,7 @@ def test_log_encoding_NLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_NLog(self): + def test_n_dimensional_log_encoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_encoding_NLog` definition n-dimensional arrays support. @@ -100,7 +100,7 @@ def test_n_dimensional_log_encoding_NLog(self): log_encoding_NLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_NLog(self): + def test_domain_range_scale_log_encoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_encoding_NLog` definition domain and range scale support. @@ -119,7 +119,7 @@ def test_domain_range_scale_log_encoding_NLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_NLog(self): + def test_nan_log_encoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_encoding_NLog` definition nan support. @@ -134,7 +134,7 @@ class TestLogDecoding_NLog: log_decoding_NLog` definition unit tests methods. """ - def test_log_decoding_NLog(self): + def test_log_decoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_decoding_NLog` definition. @@ -176,7 +176,7 @@ def test_log_decoding_NLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_NLog(self): + def test_n_dimensional_log_decoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_decoding_NLog` definition n-dimensional arrays support. @@ -203,7 +203,7 @@ def test_n_dimensional_log_decoding_NLog(self): log_decoding_NLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_NLog(self): + def test_domain_range_scale_log_decoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_decoding_NLog` definition domain and range scale support. @@ -222,7 +222,7 @@ def test_domain_range_scale_log_decoding_NLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_NLog(self): + def test_nan_log_decoding_NLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.nikon_n_log.\ log_decoding_NLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_panalog.py b/colour/models/rgb/transfer_functions/tests/test_panalog.py index 59ba916dc..837e53c14 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panalog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panalog.py @@ -31,7 +31,7 @@ class TestLogEncoding_Panalog: log_encoding_Panalog` definition unit tests methods. """ - def test_log_encoding_Panalog(self): + def test_log_encoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_encoding_Panalog` definition. @@ -55,7 +55,7 @@ def test_log_encoding_Panalog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Panalog(self): + def test_n_dimensional_log_encoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_encoding_Panalog` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_Panalog(self): log_encoding_Panalog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Panalog(self): + def test_domain_range_scale_log_encoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_encoding_Panalog` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_Panalog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Panalog(self): + def test_nan_log_encoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_encoding_Panalog` definition nan support. @@ -116,7 +116,7 @@ class TestLogDecoding_Panalog: log_decoding_Panalog` definition unit tests methods. """ - def test_log_decoding_Panalog(self): + def test_log_decoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_decoding_Panalog` definition. @@ -140,7 +140,7 @@ def test_log_decoding_Panalog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Panalog(self): + def test_n_dimensional_log_decoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_decoding_Panalog` definition n-dimensional arrays support. @@ -167,7 +167,7 @@ def test_n_dimensional_log_decoding_Panalog(self): log_decoding_Panalog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Panalog(self): + def test_domain_range_scale_log_decoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_decoding_Panalog` definition domain and range scale support. @@ -186,7 +186,7 @@ def test_domain_range_scale_log_decoding_Panalog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Panalog(self): + def test_nan_log_decoding_Panalog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panalog.\ log_decoding_Panalog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py index fb6cbac08..7e0e39617 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py @@ -31,7 +31,7 @@ class TestLogEncoding_VLog: log_encoding_VLog` definition unit tests methods. """ - def test_log_encoding_VLog(self): + def test_log_encoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_encoding_VLog` definition. @@ -71,7 +71,7 @@ def test_log_encoding_VLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_VLog(self): + def test_n_dimensional_log_encoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_encoding_VLog` definition n-dimensional arrays support. @@ -98,7 +98,7 @@ def test_n_dimensional_log_encoding_VLog(self): log_encoding_VLog(L_in), V_out, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_VLog(self): + def test_domain_range_scale_log_encoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_encoding_VLog` definition domain and range scale support. @@ -117,7 +117,7 @@ def test_domain_range_scale_log_encoding_VLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_VLog(self): + def test_nan_log_encoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_encoding_VLog` definition nan support. @@ -132,7 +132,7 @@ class TestLogDecoding_VLog: log_decoding_VLog` definition unit tests methods. """ - def test_log_decoding_VLog(self): + def test_log_decoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_decoding_VLog` definition. @@ -172,7 +172,7 @@ def test_log_decoding_VLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_VLog(self): + def test_n_dimensional_log_decoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_decoding_VLog` definition n-dimensional arrays support. @@ -199,7 +199,7 @@ def test_n_dimensional_log_decoding_VLog(self): log_decoding_VLog(V_out), L_in, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_VLog(self): + def test_domain_range_scale_log_decoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_decoding_VLog` definition domain and range scale support. @@ -218,7 +218,7 @@ def test_domain_range_scale_log_decoding_VLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_VLog(self): + def test_nan_log_decoding_VLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.panasonic_v_log.\ log_decoding_VLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py index 3c77826d0..65b605416 100644 --- a/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_pivoted_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_PivotedLog: log_encoding_PivotedLog` definition unit tests methods. """ - def test_log_encoding_PivotedLog(self): + def test_log_encoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_encoding_PivotedLog` definition. @@ -55,7 +55,7 @@ def test_log_encoding_PivotedLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_PivotedLog(self): + def test_n_dimensional_log_encoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_encoding_PivotedLog` definition n-dimensional arrays support. @@ -82,7 +82,7 @@ def test_n_dimensional_log_encoding_PivotedLog(self): log_encoding_PivotedLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_PivotedLog(self): + def test_domain_range_scale_log_encoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_encoding_PivotedLog` definition domain and range scale support. @@ -101,7 +101,7 @@ def test_domain_range_scale_log_encoding_PivotedLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_PivotedLog(self): + def test_nan_log_encoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_encoding_PivotedLog` definition nan support. @@ -116,7 +116,7 @@ class TestLogDecoding_PivotedLog: log_decoding_PivotedLog` definition unit tests methods. """ - def test_log_decoding_PivotedLog(self): + def test_log_decoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_decoding_PivotedLog` definition. @@ -140,7 +140,7 @@ def test_log_decoding_PivotedLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_PivotedLog(self): + def test_n_dimensional_log_decoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_decoding_PivotedLog` definition n-dimensional arrays support. @@ -167,7 +167,7 @@ def test_n_dimensional_log_decoding_PivotedLog(self): log_decoding_PivotedLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_PivotedLog(self): + def test_domain_range_scale_log_decoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_decoding_PivotedLog` definition domain and range scale support. @@ -186,7 +186,7 @@ def test_domain_range_scale_log_decoding_PivotedLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_PivotedLog(self): + def test_nan_log_decoding_PivotedLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.pivoted_log.\ log_decoding_PivotedLog` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_red.py b/colour/models/rgb/transfer_functions/tests/test_red.py index e6e6cf654..e4f3a39ae 100644 --- a/colour/models/rgb/transfer_functions/tests/test_red.py +++ b/colour/models/rgb/transfer_functions/tests/test_red.py @@ -53,7 +53,7 @@ class TestLogEncoding_REDLog: log_encoding_REDLog` definition unit tests methods. """ - def test_log_encoding_REDLog(self): + def test_log_encoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLog` definition. @@ -73,7 +73,7 @@ def test_log_encoding_REDLog(self): log_encoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_encoding_REDLog(self): + def test_n_dimensional_log_encoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLog` definition n-dimensional arrays support. @@ -100,7 +100,7 @@ def test_n_dimensional_log_encoding_REDLog(self): log_encoding_REDLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_REDLog(self): + def test_domain_range_scale_log_encoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLog` definition domain and range scale support. @@ -119,7 +119,7 @@ def test_domain_range_scale_log_encoding_REDLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_REDLog(self): + def test_nan_log_encoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLog` definition nan support. @@ -134,7 +134,7 @@ class TestLogDecoding_REDLog: log_decoding_REDLog` definition unit tests methods. """ - def test_log_decoding_REDLog(self): + def test_log_decoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLog` definition. @@ -154,7 +154,7 @@ def test_log_decoding_REDLog(self): log_decoding_REDLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_decoding_REDLog(self): + def test_n_dimensional_log_decoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLog` definition n-dimensional arrays support. @@ -181,7 +181,7 @@ def test_n_dimensional_log_decoding_REDLog(self): log_decoding_REDLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_REDLog(self): + def test_domain_range_scale_log_decoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLog` definition domain and range scale support. @@ -200,7 +200,7 @@ def test_domain_range_scale_log_decoding_REDLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_REDLog(self): + def test_nan_log_decoding_REDLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLog` definition nan support. @@ -215,7 +215,7 @@ class TestLogEncoding_REDLogFilm: log_encoding_REDLogFilm` definition unit tests methods. """ - def test_log_encoding_REDLogFilm(self): + def test_log_encoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLogFilm` definition. @@ -239,7 +239,7 @@ def test_log_encoding_REDLogFilm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_REDLogFilm(self): + def test_n_dimensional_log_encoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLogFilm` definition n-dimensional arrays support. @@ -266,7 +266,7 @@ def test_n_dimensional_log_encoding_REDLogFilm(self): log_encoding_REDLogFilm(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_REDLogFilm(self): + def test_domain_range_scale_log_encoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLogFilm` definition domain and range scale support. @@ -285,7 +285,7 @@ def test_domain_range_scale_log_encoding_REDLogFilm(self): ) @ignore_numpy_errors - def test_nan_log_encoding_REDLogFilm(self): + def test_nan_log_encoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_REDLogFilm` definition nan support. @@ -300,7 +300,7 @@ class TestLogDecoding_REDLogFilm: log_decoding_REDLogFilm` definition unit tests methods. """ - def test_log_decoding_REDLogFilm(self): + def test_log_decoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLogFilm` definition. @@ -324,7 +324,7 @@ def test_log_decoding_REDLogFilm(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_REDLogFilm(self): + def test_n_dimensional_log_decoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLogFilm` definition n-dimensional arrays support. @@ -351,7 +351,7 @@ def test_n_dimensional_log_decoding_REDLogFilm(self): log_decoding_REDLogFilm(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_REDLogFilm(self): + def test_domain_range_scale_log_decoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLogFilm` definition domain and range scale support. @@ -370,7 +370,7 @@ def test_domain_range_scale_log_decoding_REDLogFilm(self): ) @ignore_numpy_errors - def test_nan_log_decoding_REDLogFilm(self): + def test_nan_log_decoding_REDLogFilm(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_REDLogFilm` definition nan support. @@ -385,7 +385,7 @@ class TestLogEncoding_Log3G10_v1: log_encoding_Log3G10_v1` definition unit tests methods. """ - def test_log_encoding_Log3G10_v1(self): + def test_log_encoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v1` definition. @@ -407,7 +407,7 @@ def test_log_encoding_Log3G10_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Log3G10_v1(self): + def test_n_dimensional_log_encoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v1` definition n-dimensional arrays support. @@ -434,7 +434,7 @@ def test_n_dimensional_log_encoding_Log3G10_v1(self): log_encoding_Log3G10_v1(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Log3G10_v1(self): + def test_domain_range_scale_log_encoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v1` definition domain and range scale support. @@ -453,7 +453,7 @@ def test_domain_range_scale_log_encoding_Log3G10_v1(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Log3G10_v1(self): + def test_nan_log_encoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v1` definition nan support. @@ -468,7 +468,7 @@ class TestLogDecoding_Log3G10_v1: log_decoding_Log3G10_v1` definition unit tests methods. """ - def test_log_decoding_Log3G10_v1(self): + def test_log_decoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v1` definition. @@ -490,7 +490,7 @@ def test_log_decoding_Log3G10_v1(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Log3G10_v1(self): + def test_n_dimensional_log_decoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v1` definition n-dimensional arrays support. @@ -517,7 +517,7 @@ def test_n_dimensional_log_decoding_Log3G10_v1(self): log_decoding_Log3G10_v1(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Log3G10_v1(self): + def test_domain_range_scale_log_decoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v1` definition domain and range scale support. @@ -536,7 +536,7 @@ def test_domain_range_scale_log_decoding_Log3G10_v1(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Log3G10_v1(self): + def test_nan_log_decoding_Log3G10_v1(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v1` definition nan support. @@ -551,7 +551,7 @@ class TestLogEncoding_Log3G10_v2: log_encoding_Log3G10_v2` definition unit tests methods. """ - def test_log_encoding_Log3G10_v2(self): + def test_log_encoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v2` definition. @@ -575,7 +575,7 @@ def test_log_encoding_Log3G10_v2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Log3G10_v2(self): + def test_n_dimensional_log_encoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v2` definition n-dimensional arrays support. @@ -602,7 +602,7 @@ def test_n_dimensional_log_encoding_Log3G10_v2(self): log_encoding_Log3G10_v2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Log3G10_v2(self): + def test_domain_range_scale_log_encoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v2` definition domain and range scale support. @@ -621,7 +621,7 @@ def test_domain_range_scale_log_encoding_Log3G10_v2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Log3G10_v2(self): + def test_nan_log_encoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v2` definition nan support. @@ -636,7 +636,7 @@ class TestLogDecoding_Log3G10_v2: log_decoding_Log3G10_v2` definition unit tests methods. """ - def test_log_decoding_Log3G10_v2(self): + def test_log_decoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v2` definition. @@ -660,7 +660,7 @@ def test_log_decoding_Log3G10_v2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Log3G10_v2(self): + def test_n_dimensional_log_decoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v2` definition n-dimensional arrays support. @@ -687,7 +687,7 @@ def test_n_dimensional_log_decoding_Log3G10_v2(self): log_decoding_Log3G10_v2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Log3G10_v2(self): + def test_domain_range_scale_log_decoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v2` definition domain and range scale support. @@ -706,7 +706,7 @@ def test_domain_range_scale_log_decoding_Log3G10_v2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Log3G10_v2(self): + def test_nan_log_decoding_Log3G10_v2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v2` definition nan support. @@ -721,7 +721,7 @@ class TestLogEncoding_Log3G10_v3: log_encoding_Log3G10_v3` definition unit tests methods. """ - def test_log_encoding_Log3G10_v3(self): + def test_log_encoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v3` definition. @@ -745,7 +745,7 @@ def test_log_encoding_Log3G10_v3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Log3G10_v3(self): + def test_n_dimensional_log_encoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v3` definition n-dimensional arrays support. @@ -772,7 +772,7 @@ def test_n_dimensional_log_encoding_Log3G10_v3(self): log_encoding_Log3G10_v3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Log3G10_v3(self): + def test_domain_range_scale_log_encoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v3` definition domain and range scale support. @@ -791,7 +791,7 @@ def test_domain_range_scale_log_encoding_Log3G10_v3(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Log3G10_v3(self): + def test_nan_log_encoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G10_v3` definition nan support. @@ -806,7 +806,7 @@ class TestLogDecoding_Log3G10_v3: log_decoding_Log3G10_v3` definition unit tests methods. """ - def test_log_decoding_Log3G10_v3(self): + def test_log_decoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v3` definition. @@ -830,7 +830,7 @@ def test_log_decoding_Log3G10_v3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Log3G10_v3(self): + def test_n_dimensional_log_decoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v3` definition n-dimensional arrays support. @@ -857,7 +857,7 @@ def test_n_dimensional_log_decoding_Log3G10_v3(self): log_decoding_Log3G10_v3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Log3G10_v3(self): + def test_domain_range_scale_log_decoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v3` definition domain and range scale support. @@ -876,7 +876,7 @@ def test_domain_range_scale_log_decoding_Log3G10_v3(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Log3G10_v3(self): + def test_nan_log_decoding_Log3G10_v3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G10_v3` definition nan support. @@ -891,7 +891,7 @@ class TestLogEncoding_Log3G12: log_encoding_Log3G12` definition unit tests methods. """ - def test_log_encoding_Log3G12(self): + def test_log_encoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G12` definition. @@ -919,7 +919,7 @@ def test_log_encoding_Log3G12(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_Log3G12(self): + def test_n_dimensional_log_encoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G12` definition n-dimensional arrays support. @@ -946,7 +946,7 @@ def test_n_dimensional_log_encoding_Log3G12(self): log_encoding_Log3G12(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_Log3G12(self): + def test_domain_range_scale_log_encoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G12` definition domain and range scale support. @@ -965,7 +965,7 @@ def test_domain_range_scale_log_encoding_Log3G12(self): ) @ignore_numpy_errors - def test_nan_log_encoding_Log3G12(self): + def test_nan_log_encoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_encoding_Log3G12` definition nan support. @@ -980,7 +980,7 @@ class TestLogDecoding_Log3G12: log_decoding_Log3G12` definition unit tests methods. """ - def test_log_decoding_Log3G12(self): + def test_log_decoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G12` definition. @@ -1008,7 +1008,7 @@ def test_log_decoding_Log3G12(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_Log3G12(self): + def test_n_dimensional_log_decoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G12` definition n-dimensional arrays support. @@ -1035,7 +1035,7 @@ def test_n_dimensional_log_decoding_Log3G12(self): log_decoding_Log3G12(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_Log3G12(self): + def test_domain_range_scale_log_decoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G12` definition domain and range scale support. @@ -1054,7 +1054,7 @@ def test_domain_range_scale_log_decoding_Log3G12(self): ) @ignore_numpy_errors - def test_nan_log_decoding_Log3G12(self): + def test_nan_log_decoding_Log3G12(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.red.\ log_decoding_Log3G12` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py index 727fcc736..dc5ce6f8b 100644 --- a/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_rimm_romm_rgb.py @@ -39,7 +39,7 @@ class TestCctfEncoding_ROMMRGB: cctf_encoding_ROMMRGB` definition unit tests methods. """ - def test_cctf_encoding_ROMMRGB(self): + def test_cctf_encoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_ROMMRGB` definition. @@ -63,7 +63,7 @@ def test_cctf_encoding_ROMMRGB(self): assert cctf_encoding_ROMMRGB(0.18, bit_depth=12, out_int=True) == 1579 - def test_n_dimensional_cctf_encoding_ROMMRGB(self): + def test_n_dimensional_cctf_encoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_ROMMRGB` definition n-dimensional arrays support. @@ -90,7 +90,7 @@ def test_n_dimensional_cctf_encoding_ROMMRGB(self): cctf_encoding_ROMMRGB(X), X_ROMM, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_cctf_encoding_ROMMRGB(self): + def test_domain_range_scale_cctf_encoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_ROMMRGB` definition domain and range scale support. @@ -109,7 +109,7 @@ def test_domain_range_scale_cctf_encoding_ROMMRGB(self): ) @ignore_numpy_errors - def test_nan_cctf_encoding_ROMMRGB(self): + def test_nan_cctf_encoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_ROMMRGB` definition nan support. @@ -124,7 +124,7 @@ class TestCctfDecoding_ROMMRGB: cctf_decoding_ROMMRGB` definition unit tests methods. """ - def test_cctf_decoding_ROMMRGB(self): + def test_cctf_decoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_ROMMRGB` definition. @@ -156,7 +156,7 @@ def test_cctf_decoding_ROMMRGB(self): atol=0.001, ) - def test_n_dimensional_cctf_decoding_ROMMRGB(self): + def test_n_dimensional_cctf_decoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_ROMMRGB` definition n-dimensional arrays support. @@ -183,7 +183,7 @@ def test_n_dimensional_cctf_decoding_ROMMRGB(self): cctf_decoding_ROMMRGB(X_p), X, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_cctf_decoding_ROMMRGB(self): + def test_domain_range_scale_cctf_decoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_ROMMRGB` definition domain and range scale support. @@ -202,7 +202,7 @@ def test_domain_range_scale_cctf_decoding_ROMMRGB(self): ) @ignore_numpy_errors - def test_nan_cctf_decoding_ROMMRGB(self): + def test_nan_cctf_decoding_ROMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_ROMMRGB` definition nan support. @@ -217,7 +217,7 @@ class TestCctfEncoding_RIMMRGB: cctf_encoding_RIMMRGB` definition unit tests methods. """ - def test_cctf_encoding_RIMMRGB(self): + def test_cctf_encoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_RIMMRGB` definition. @@ -243,7 +243,7 @@ def test_cctf_encoding_RIMMRGB(self): assert cctf_encoding_RIMMRGB(0.18, bit_depth=12, out_int=True) == 1194 - def test_n_dimensional_cctf_encoding_RIMMRGB(self): + def test_n_dimensional_cctf_encoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_RIMMRGB` definition n-dimensional arrays support. @@ -270,7 +270,7 @@ def test_n_dimensional_cctf_encoding_RIMMRGB(self): cctf_encoding_RIMMRGB(X), X_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_cctf_encoding_RIMMRGB(self): + def test_domain_range_scale_cctf_encoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_RIMMRGB` definition domain and range scale support. @@ -289,7 +289,7 @@ def test_domain_range_scale_cctf_encoding_RIMMRGB(self): ) @ignore_numpy_errors - def test_nan_cctf_encoding_RIMMRGB(self): + def test_nan_cctf_encoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_encoding_RIMMRGB` definition nan support. @@ -304,7 +304,7 @@ class TestCctfDecoding_RIMMRGB: cctf_decoding_RIMMRGB` definition unit tests methods. """ - def test_cctf_decoding_RIMMRGB(self): + def test_cctf_decoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_RIMMRGB` definition. @@ -338,7 +338,7 @@ def test_cctf_decoding_RIMMRGB(self): atol=0.005, ) - def test_n_dimensional_cctf_decoding_RIMMRGB(self): + def test_n_dimensional_cctf_decoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_RIMMRGB` definition n-dimensional arrays support. @@ -365,7 +365,7 @@ def test_n_dimensional_cctf_decoding_RIMMRGB(self): cctf_decoding_RIMMRGB(X_p), X, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_cctf_decoding_RIMMRGB(self): + def test_domain_range_scale_cctf_decoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_RIMMRGB` definition domain and range scale support. @@ -384,7 +384,7 @@ def test_domain_range_scale_cctf_decoding_RIMMRGB(self): ) @ignore_numpy_errors - def test_nan_cctf_decoding_RIMMRGB(self): + def test_nan_cctf_decoding_RIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ cctf_decoding_RIMMRGB` definition nan support. @@ -399,7 +399,7 @@ class TestLog_encoding_ERIMMRGB: log_encoding_ERIMMRGB` definition unit tests methods. """ - def test_log_encoding_ERIMMRGB(self): + def test_log_encoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_encoding_ERIMMRGB` definition. @@ -425,7 +425,7 @@ def test_log_encoding_ERIMMRGB(self): assert log_encoding_ERIMMRGB(0.18, bit_depth=12, out_int=True) == 1679 - def test_n_dimensional_log_encoding_ERIMMRGB(self): + def test_n_dimensional_log_encoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_encoding_ERIMMRGB` definition n-dimensional arrays support. @@ -452,7 +452,7 @@ def test_n_dimensional_log_encoding_ERIMMRGB(self): log_encoding_ERIMMRGB(X), X_p, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_ERIMMRGB(self): + def test_domain_range_scale_log_encoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_encoding_ERIMMRGB` definition domain and range scale support. @@ -471,7 +471,7 @@ def test_domain_range_scale_log_encoding_ERIMMRGB(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ERIMMRGB(self): + def test_nan_log_encoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_encoding_ERIMMRGB` definition nan support. @@ -486,7 +486,7 @@ class TestLog_decoding_ERIMMRGB: log_decoding_ERIMMRGB` definition unit tests methods. """ - def test_log_decoding_ERIMMRGB(self): + def test_log_decoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_decoding_ERIMMRGB` definition. @@ -520,7 +520,7 @@ def test_log_decoding_ERIMMRGB(self): atol=0.005, ) - def test_n_dimensional_log_decoding_ERIMMRGB(self): + def test_n_dimensional_log_decoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_decoding_ERIMMRGB` definition n-dimensional arrays support. @@ -547,7 +547,7 @@ def test_n_dimensional_log_decoding_ERIMMRGB(self): log_decoding_ERIMMRGB(X_p), X, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_ERIMMRGB(self): + def test_domain_range_scale_log_decoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_decoding_ERIMMRGB` definition domain and range scale support. @@ -566,7 +566,7 @@ def test_domain_range_scale_log_decoding_ERIMMRGB(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ERIMMRGB(self): + def test_nan_log_decoding_ERIMMRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.rimm_romm_rgb.\ log_decoding_ERIMMRGB` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py index e60b9b16b..0d49b5fe4 100644 --- a/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py +++ b/colour/models/rgb/transfer_functions/tests/test_smpte_240m.py @@ -28,7 +28,7 @@ class TestOetf_SMPTE240M: oetf_SMPTE240M` definition unit tests methods. """ - def test_oetf_SMPTE240M(self): + def test_oetf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ oetf_SMPTE240M` definition. @@ -54,7 +54,7 @@ def test_oetf_SMPTE240M(self): oetf_SMPTE240M(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_oetf_SMPTE240M(self): + def test_n_dimensional_oetf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ oetf_SMPTE240M` definition n-dimensional arrays support. @@ -81,7 +81,7 @@ def test_n_dimensional_oetf_SMPTE240M(self): oetf_SMPTE240M(L_c), V_c, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_oetf_SMPTE240M(self): + def test_domain_range_scale_oetf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ oetf_SMPTE240M` definition domain and range scale support. @@ -100,7 +100,7 @@ def test_domain_range_scale_oetf_SMPTE240M(self): ) @ignore_numpy_errors - def test_nan_oetf_SMPTE240M(self): + def test_nan_oetf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ oetf_SMPTE240M` definition nan support. @@ -115,7 +115,7 @@ class TestEotf_SMPTE240M: eotf_SMPTE240M` definition unit tests methods. """ - def test_eotf_SMPTE240M(self): + def test_eotf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ eotf_SMPTE240M` definition. @@ -141,7 +141,7 @@ def test_eotf_SMPTE240M(self): eotf_SMPTE240M(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_SMPTE240M(self): + def test_n_dimensional_eotf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ eotf_SMPTE240M` definition n-dimensional arrays support. @@ -168,7 +168,7 @@ def test_n_dimensional_eotf_SMPTE240M(self): eotf_SMPTE240M(V_r), L_r, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_SMPTE240M(self): + def test_domain_range_scale_eotf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ eotf_SMPTE240M` definition domain and range scale support. @@ -187,7 +187,7 @@ def test_domain_range_scale_eotf_SMPTE240M(self): ) @ignore_numpy_errors - def test_nan_eotf_SMPTE240M(self): + def test_nan_eotf_SMPTE240M(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.smpte_240m.\ eotf_SMPTE240M` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_sony.py b/colour/models/rgb/transfer_functions/tests/test_sony.py index c4283a9d3..f82e69ce9 100644 --- a/colour/models/rgb/transfer_functions/tests/test_sony.py +++ b/colour/models/rgb/transfer_functions/tests/test_sony.py @@ -39,7 +39,7 @@ class TestLogEncoding_SLog: log_encoding_SLog` definition unit tests methods. """ - def test_log_encoding_SLog(self): + def test_log_encoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog` definition. @@ -81,7 +81,7 @@ def test_log_encoding_SLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_SLog(self): + def test_n_dimensional_log_encoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog` definition n-dimensional arrays support. @@ -108,7 +108,7 @@ def test_n_dimensional_log_encoding_SLog(self): log_encoding_SLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_SLog(self): + def test_domain_range_scale_log_encoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog` definition domain and range scale support. @@ -127,7 +127,7 @@ def test_domain_range_scale_log_encoding_SLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_SLog(self): + def test_nan_log_encoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog` definition nan support. @@ -142,7 +142,7 @@ class TestLogDecoding_SLog: log_decoding_SLog` definition unit tests methods. """ - def test_log_decoding_SLog(self): + def test_log_decoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog` definition. @@ -184,7 +184,7 @@ def test_log_decoding_SLog(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_SLog(self): + def test_n_dimensional_log_decoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog` definition n-dimensional arrays support. @@ -211,7 +211,7 @@ def test_n_dimensional_log_decoding_SLog(self): log_decoding_SLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_SLog(self): + def test_domain_range_scale_log_decoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog` definition domain and range scale support. @@ -230,7 +230,7 @@ def test_domain_range_scale_log_decoding_SLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_SLog(self): + def test_nan_log_decoding_SLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog` definition nan support. @@ -245,7 +245,7 @@ class TestLogEncoding_SLog2: log_encoding_SLog2` definition unit tests methods. """ - def test_log_encoding_SLog2(self): + def test_log_encoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog2` definition. @@ -287,7 +287,7 @@ def test_log_encoding_SLog2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_SLog2(self): + def test_n_dimensional_log_encoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog2` definition n-dimensional arrays support. @@ -314,7 +314,7 @@ def test_n_dimensional_log_encoding_SLog2(self): log_encoding_SLog2(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_SLog2(self): + def test_domain_range_scale_log_encoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog2` definition domain and range scale support. @@ -333,7 +333,7 @@ def test_domain_range_scale_log_encoding_SLog2(self): ) @ignore_numpy_errors - def test_nan_log_encoding_SLog2(self): + def test_nan_log_encoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog2` definition nan support. @@ -348,7 +348,7 @@ class TestLogDecoding_SLog2: log_decoding_SLog2` definition unit tests methods. """ - def test_log_decoding_SLog2(self): + def test_log_decoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog2` definition. @@ -390,7 +390,7 @@ def test_log_decoding_SLog2(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_SLog2(self): + def test_n_dimensional_log_decoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog2` definition n-dimensional arrays support. @@ -417,7 +417,7 @@ def test_n_dimensional_log_decoding_SLog2(self): log_decoding_SLog2(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_SLog2(self): + def test_domain_range_scale_log_decoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog2` definition domain and range scale support. @@ -436,7 +436,7 @@ def test_domain_range_scale_log_decoding_SLog2(self): ) @ignore_numpy_errors - def test_nan_log_decoding_SLog2(self): + def test_nan_log_decoding_SLog2(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog2` definition nan support. @@ -451,7 +451,7 @@ class TestLogEncoding_SLog3: log_encoding_SLog3` definition unit tests methods. """ - def test_log_encoding_SLog3(self): + def test_log_encoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog3` definition. @@ -493,7 +493,7 @@ def test_log_encoding_SLog3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_encoding_SLog3(self): + def test_n_dimensional_log_encoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog3` definition n-dimensional arrays support. @@ -520,7 +520,7 @@ def test_n_dimensional_log_encoding_SLog3(self): log_encoding_SLog3(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_SLog3(self): + def test_domain_range_scale_log_encoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog3` definition domain and range scale support. @@ -539,7 +539,7 @@ def test_domain_range_scale_log_encoding_SLog3(self): ) @ignore_numpy_errors - def test_nan_log_encoding_SLog3(self): + def test_nan_log_encoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_encoding_SLog3` definition nan support. @@ -554,7 +554,7 @@ class TestLogDecoding_SLog3: log_decoding_SLog3` definition unit tests methods. """ - def test_log_decoding_SLog3(self): + def test_log_decoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog3` definition. @@ -596,7 +596,7 @@ def test_log_decoding_SLog3(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_log_decoding_SLog3(self): + def test_n_dimensional_log_decoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog3` definition n-dimensional arrays support. @@ -623,7 +623,7 @@ def test_n_dimensional_log_decoding_SLog3(self): log_decoding_SLog3(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_SLog3(self): + def test_domain_range_scale_log_decoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog3` definition domain and range scale support. @@ -642,7 +642,7 @@ def test_domain_range_scale_log_decoding_SLog3(self): ) @ignore_numpy_errors - def test_nan_log_decoding_SLog3(self): + def test_nan_log_decoding_SLog3(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sony.\ log_decoding_SLog3` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_srgb.py b/colour/models/rgb/transfer_functions/tests/test_srgb.py index 9808d4827..99a38393d 100644 --- a/colour/models/rgb/transfer_functions/tests/test_srgb.py +++ b/colour/models/rgb/transfer_functions/tests/test_srgb.py @@ -28,7 +28,7 @@ class TestEotf_inverse_sRGB: definition unit tests methods. """ - def test_eotf_inverse_sRGB(self): + def test_eotf_inverse_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_inverse_sRGB` definition. @@ -48,7 +48,7 @@ def test_eotf_inverse_sRGB(self): eotf_inverse_sRGB(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_inverse_sRGB(self): + def test_n_dimensional_eotf_inverse_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_inverse_sRGB` definition n-dimensional arrays support. @@ -75,7 +75,7 @@ def test_n_dimensional_eotf_inverse_sRGB(self): eotf_inverse_sRGB(L), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_sRGB(self): + def test_domain_range_scale_eotf_inverse_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_inverse_sRGB` definition domain and range scale support. @@ -94,7 +94,7 @@ def test_domain_range_scale_eotf_inverse_sRGB(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_sRGB(self): + def test_nan_eotf_inverse_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_inverse_sRGB` definition nan support. @@ -109,7 +109,7 @@ class TestEotf_sRGB: definition unit tests methods. """ - def test_eotf_sRGB(self): + def test_eotf_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_sRGB` definition. @@ -123,7 +123,7 @@ def test_eotf_sRGB(self): np.testing.assert_allclose(eotf_sRGB(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_n_dimensional_eotf_sRGB(self): + def test_n_dimensional_eotf_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_sRGB` definition n-dimensional arrays support. @@ -144,7 +144,7 @@ def test_n_dimensional_eotf_sRGB(self): L = np.reshape(L, (2, 3, 1)) np.testing.assert_allclose(eotf_sRGB(V), L, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_eotf_sRGB(self): + def test_domain_range_scale_eotf_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_sRGB` definition domain and range scale support. @@ -163,7 +163,7 @@ def test_domain_range_scale_eotf_sRGB(self): ) @ignore_numpy_errors - def test_nan_eotf_sRGB(self): + def test_nan_eotf_sRGB(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.sRGB.\ eotf_sRGB` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_st_2084.py b/colour/models/rgb/transfer_functions/tests/test_st_2084.py index d12b1cf81..4c052cb65 100644 --- a/colour/models/rgb/transfer_functions/tests/test_st_2084.py +++ b/colour/models/rgb/transfer_functions/tests/test_st_2084.py @@ -31,7 +31,7 @@ class TestEotf_inverse_ST2084: eotf_inverse_ST2084` definition unit tests methods. """ - def test_eotf_inverse_ST2084(self): + def test_eotf_inverse_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_inverse_ST2084` definition. @@ -59,7 +59,7 @@ def test_eotf_inverse_ST2084(self): eotf_inverse_ST2084(5000, 5000), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_inverse_ST2084(self): + def test_n_dimensional_eotf_inverse_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_inverse_ST2084` definition n-dimensional arrays support. @@ -86,7 +86,7 @@ def test_n_dimensional_eotf_inverse_ST2084(self): eotf_inverse_ST2084(C), N, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_eotf_inverse_ST2084(self): + def test_domain_range_scale_eotf_inverse_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_inverse_ST2084` definition domain and range scale support. @@ -105,7 +105,7 @@ def test_domain_range_scale_eotf_inverse_ST2084(self): ) @ignore_numpy_errors - def test_nan_eotf_inverse_ST2084(self): + def test_nan_eotf_inverse_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_inverse_ST2084` definition nan support. @@ -120,7 +120,7 @@ class TestEotf_ST2084: definition unit tests methods. """ - def test_eotf_ST2084(self): + def test_eotf_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_ST2084` definition. @@ -140,7 +140,7 @@ def test_eotf_ST2084(self): eotf_ST2084(1.0, 5000), 5000.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_eotf_ST2084(self): + def test_n_dimensional_eotf_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_ST2084` definition n-dimensional arrays support. @@ -161,7 +161,7 @@ def test_n_dimensional_eotf_ST2084(self): C = np.reshape(C, (2, 3, 1)) np.testing.assert_allclose(eotf_ST2084(N), C, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_eotf_ST2084(self): + def test_domain_range_scale_eotf_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_ST2084` definition domain and range scale support. @@ -180,7 +180,7 @@ def test_domain_range_scale_eotf_ST2084(self): ) @ignore_numpy_errors - def test_nan_eotf_ST2084(self): + def test_nan_eotf_ST2084(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.st_2084.\ eotf_ST2084` definition nan support. diff --git a/colour/models/rgb/transfer_functions/tests/test_viper_log.py b/colour/models/rgb/transfer_functions/tests/test_viper_log.py index 3f235ff00..394a55d53 100644 --- a/colour/models/rgb/transfer_functions/tests/test_viper_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_viper_log.py @@ -31,7 +31,7 @@ class TestLogEncoding_ViperLog: log_encoding_ViperLog` definition unit tests methods. """ - def test_log_encoding_ViperLog(self): + def test_log_encoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_encoding_ViperLog` definition. @@ -51,7 +51,7 @@ def test_log_encoding_ViperLog(self): log_encoding_ViperLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_encoding_ViperLog(self): + def test_n_dimensional_log_encoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_encoding_ViperLog` definition n-dimensional arrays support. @@ -78,7 +78,7 @@ def test_n_dimensional_log_encoding_ViperLog(self): log_encoding_ViperLog(x), y, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_encoding_ViperLog(self): + def test_domain_range_scale_log_encoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_encoding_ViperLog` definition domain and range scale support. @@ -97,7 +97,7 @@ def test_domain_range_scale_log_encoding_ViperLog(self): ) @ignore_numpy_errors - def test_nan_log_encoding_ViperLog(self): + def test_nan_log_encoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_encoding_ViperLog` definition nan support. @@ -112,7 +112,7 @@ class TestLogDecoding_ViperLog: log_decoding_ViperLog` definition unit tests methods. """ - def test_log_decoding_ViperLog(self): + def test_log_decoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_decoding_ViperLog` definition. @@ -132,7 +132,7 @@ def test_log_decoding_ViperLog(self): log_decoding_ViperLog(1.0), 1.0, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_n_dimensional_log_decoding_ViperLog(self): + def test_n_dimensional_log_decoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_decoding_ViperLog` definition n-dimensional arrays support. @@ -159,7 +159,7 @@ def test_n_dimensional_log_decoding_ViperLog(self): log_decoding_ViperLog(y), x, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_log_decoding_ViperLog(self): + def test_domain_range_scale_log_decoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_decoding_ViperLog` definition domain and range scale support. @@ -178,7 +178,7 @@ def test_domain_range_scale_log_decoding_ViperLog(self): ) @ignore_numpy_errors - def test_nan_log_decoding_ViperLog(self): + def test_nan_log_decoding_ViperLog(self) -> None: """ Test :func:`colour.models.rgb.transfer_functions.viper_log.\ log_decoding_ViperLog` definition nan support. diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index a34c09eaa..764d54424 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cam02_ucs` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -54,7 +56,7 @@ class TestJMh_CIECAM02_to_UCS_Luo2006: definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" XYZ = np.array([19.01, 20.00, 21.78]) @@ -66,7 +68,7 @@ def setup_method(self): self._JMh = np.array([specification.J, specification.M, specification.h]) - def test_JMh_CIECAM02_to_UCS_Luo2006(self): + def test_JMh_CIECAM02_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` definition. @@ -120,7 +122,7 @@ def test_JMh_CIECAM02_to_UCS_Luo2006(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self): + def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` definition n-dimensional support. @@ -145,7 +147,7 @@ def test_n_dimensional_JMh_CIECAM02_to_UCS_Luo2006(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_JMh_CIECAM02_to_UCS_Luo2006(self): + def test_domain_range_scale_JMh_CIECAM02_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` definition domain and range scale support. @@ -170,7 +172,7 @@ def test_domain_range_scale_JMh_CIECAM02_to_UCS_Luo2006(self): ) @ignore_numpy_errors - def test_nan_JMh_CIECAM02_to_UCS_Luo2006(self): + def test_nan_JMh_CIECAM02_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.JMh_CIECAM02_to_UCS_Luo2006` definition nan support. @@ -187,7 +189,7 @@ class TestUCS_Luo2006_to_JMh_CIECAM02: definition unit tests methods. """ - def test_UCS_Luo2006_to_JMh_CIECAM02(self): + def test_UCS_Luo2006_to_JMh_CIECAM02(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` definition. @@ -247,7 +249,7 @@ def test_UCS_Luo2006_to_JMh_CIECAM02(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self): + def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` definition n-dimensional support. @@ -272,7 +274,7 @@ def test_n_dimensional_UCS_Luo2006_to_JMh_CIECAM02(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_UCS_Luo2006_to_JMh_CIECAM02(self): + def test_domain_range_scale_UCS_Luo2006_to_JMh_CIECAM02(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` definition domain and range scale support. @@ -298,7 +300,7 @@ def test_domain_range_scale_UCS_Luo2006_to_JMh_CIECAM02(self): ) @ignore_numpy_errors - def test_nan_UCS_Luo2006_to_JMh_CIECAM02(self): + def test_nan_UCS_Luo2006_to_JMh_CIECAM02(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_JMh_CIECAM02` definition nan support. @@ -315,7 +317,7 @@ class TestXYZ_to_UCS_Luo2006: unit tests methods. """ - def test_XYZ_to_UCS_Luo2006(self): + def test_XYZ_to_UCS_Luo2006(self) -> None: """Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition.""" np.testing.assert_allclose( @@ -372,7 +374,7 @@ def test_XYZ_to_UCS_Luo2006(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_UCS_Luo2006(self): + def test_n_dimensional_XYZ_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition n-dimensional support. @@ -397,7 +399,7 @@ def test_n_dimensional_XYZ_to_UCS_Luo2006(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_UCS_Luo2006(self): + def test_domain_range_scale_XYZ_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition domain and range scale support. @@ -421,7 +423,7 @@ def test_domain_range_scale_XYZ_to_UCS_Luo2006(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_UCS_Luo2006(self): + def test_nan_XYZ_to_UCS_Luo2006(self) -> None: """ Test :func:`colour.models.cam02_ucs.XYZ_to_UCS_Luo2006` definition nan support. @@ -438,7 +440,7 @@ class TestUCS_Luo2006_to_XYZ: unit tests methods. """ - def test_UCS_Luo2006_to_XYZ(self): + def test_UCS_Luo2006_to_XYZ(self) -> None: """Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition.""" np.testing.assert_allclose( @@ -495,7 +497,7 @@ def test_UCS_Luo2006_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UCS_Luo2006_to_XYZ(self): + def test_n_dimensional_UCS_Luo2006_to_XYZ(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition n-dimensional support. @@ -520,7 +522,7 @@ def test_n_dimensional_UCS_Luo2006_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_UCS_Luo2006_to_XYZ(self): + def test_domain_range_scale_UCS_Luo2006_to_XYZ(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition domain and range scale support. @@ -544,7 +546,7 @@ def test_domain_range_scale_UCS_Luo2006_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_UCS_Luo2006_to_XYZ(self): + def test_nan_UCS_Luo2006_to_XYZ(self) -> None: """ Test :func:`colour.models.cam02_ucs.UCS_Luo2006_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_cam16_ucs.py b/colour/models/tests/test_cam16_ucs.py index 9c776ae2a..b58d16b87 100644 --- a/colour/models/tests/test_cam16_ucs.py +++ b/colour/models/tests/test_cam16_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cam16_ucs` module.""" +from __future__ import annotations + from colour.models.tests.test_cam02_ucs import ( TestJMh_CIECAM02_to_UCS_Luo2006, TestUCS_Luo2006_to_JMh_CIECAM02, diff --git a/colour/models/tests/test_cie_lab.py b/colour/models/tests/test_cie_lab.py index 82c5c02bc..2a3e056a7 100644 --- a/colour/models/tests/test_cie_lab.py +++ b/colour/models/tests/test_cie_lab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cie_lab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_Lab: methods. """ - def test_XYZ_to_Lab(self): + def test_XYZ_to_Lab(self) -> None: """Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition.""" np.testing.assert_allclose( @@ -75,7 +77,7 @@ def test_XYZ_to_Lab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Lab(self): + def test_n_dimensional_XYZ_to_Lab(self) -> None: """ Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition n-dimensional support. @@ -103,7 +105,7 @@ def test_n_dimensional_XYZ_to_Lab(self): XYZ_to_Lab(XYZ, illuminant), Lab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_Lab(self): + def test_domain_range_scale_XYZ_to_Lab(self) -> None: """ Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition domain and range scale support. @@ -123,7 +125,7 @@ def test_domain_range_scale_XYZ_to_Lab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Lab(self): + def test_nan_XYZ_to_Lab(self) -> None: """Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -137,7 +139,7 @@ class TestLab_to_XYZ: methods. """ - def test_Lab_to_XYZ(self): + def test_Lab_to_XYZ(self) -> None: """Test :func:`colour.models.cie_lab.Lab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -185,7 +187,7 @@ def test_Lab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Lab_to_XYZ(self): + def test_n_dimensional_Lab_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_lab.Lab_to_XYZ` definition n-dimensional support. @@ -213,7 +215,7 @@ def test_n_dimensional_Lab_to_XYZ(self): Lab_to_XYZ(Lab, illuminant), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Lab_to_XYZ(self): + def test_domain_range_scale_Lab_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_lab.Lab_to_XYZ` definition domain and range scale support. @@ -233,7 +235,7 @@ def test_domain_range_scale_Lab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Lab_to_XYZ(self): + def test_nan_Lab_to_XYZ(self) -> None: """Test :func:`colour.models.cie_lab.Lab_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_cie_luv.py b/colour/models/tests/test_cie_luv.py index 47acc2dcc..7d6c6ada5 100644 --- a/colour/models/tests/test_cie_luv.py +++ b/colour/models/tests/test_cie_luv.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cie_luv` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -42,7 +44,7 @@ class TestXYZ_to_Luv: methods. """ - def test_XYZ_to_Luv(self): + def test_XYZ_to_Luv(self) -> None: """Test :func:`colour.models.cie_luv.XYZ_to_Luv` definition.""" np.testing.assert_allclose( @@ -90,7 +92,7 @@ def test_XYZ_to_Luv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Luv(self): + def test_n_dimensional_XYZ_to_Luv(self) -> None: """ Test :func:`colour.models.cie_luv.XYZ_to_Luv` definition n-dimensional support. @@ -118,7 +120,7 @@ def test_n_dimensional_XYZ_to_Luv(self): XYZ_to_Luv(XYZ, illuminant), Luv, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_Luv(self): + def test_domain_range_scale_XYZ_to_Luv(self) -> None: """ Test :func:`colour.models.cie_luv.XYZ_to_Luv` definition domain and range scale support. @@ -138,7 +140,7 @@ def test_domain_range_scale_XYZ_to_Luv(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Luv(self): + def test_nan_XYZ_to_Luv(self) -> None: """Test :func:`colour.models.cie_luv.XYZ_to_Luv` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -152,7 +154,7 @@ class TestLuv_to_XYZ: methods. """ - def test_Luv_to_XYZ(self): + def test_Luv_to_XYZ(self) -> None: """Test :func:`colour.models.cie_luv.Luv_to_XYZ` definition.""" np.testing.assert_allclose( @@ -200,7 +202,7 @@ def test_Luv_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Luv_to_XYZ(self): + def test_n_dimensional_Luv_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_to_XYZ` definition n-dimensional support. @@ -228,7 +230,7 @@ def test_n_dimensional_Luv_to_XYZ(self): Luv_to_XYZ(Luv, illuminant), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Luv_to_XYZ(self): + def test_domain_range_scale_Luv_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_to_XYZ` definition domain and range scale support. @@ -248,7 +250,7 @@ def test_domain_range_scale_Luv_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Luv_to_XYZ(self): + def test_nan_Luv_to_XYZ(self) -> None: """Test :func:`colour.models.cie_luv.Luv_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -262,7 +264,7 @@ class TestLuv_to_uv: methods. """ - def test_Luv_to_uv(self): + def test_Luv_to_uv(self) -> None: """Test :func:`colour.models.cie_luv.Luv_to_uv` definition.""" np.testing.assert_allclose( @@ -310,7 +312,7 @@ def test_Luv_to_uv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Luv_to_uv(self): + def test_n_dimensional_Luv_to_uv(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_to_uv` definition n-dimensional support. @@ -338,7 +340,7 @@ def test_n_dimensional_Luv_to_uv(self): Luv_to_uv(Luv, illuminant), uv, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Luv_to_uv(self): + def test_domain_range_scale_Luv_to_uv(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_to_uv` definition domain and range scale support. @@ -358,7 +360,7 @@ def test_domain_range_scale_Luv_to_uv(self): ) @ignore_numpy_errors - def test_nan_Luv_to_uv(self): + def test_nan_Luv_to_uv(self) -> None: """Test :func:`colour.models.cie_luv.Luv_to_uv` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -372,7 +374,7 @@ class Testuv_to_Luv: methods. """ - def test_uv_to_Luv(self): + def test_uv_to_Luv(self) -> None: """Test :func:`colour.models.cie_luv.uv_to_Luv` definition.""" np.testing.assert_allclose( @@ -426,7 +428,7 @@ def test_uv_to_Luv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_uv_to_Luv(self): + def test_n_dimensional_uv_to_Luv(self) -> None: """ Test :func:`colour.models.cie_luv.uv_to_Luv` definition n-dimensional support. @@ -454,7 +456,7 @@ def test_n_dimensional_uv_to_Luv(self): uv_to_Luv(uv, illuminant), Luv, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_uv_to_Luv(self): + def test_domain_range_scale_uv_to_Luv(self) -> None: """ Test :func:`colour.models.cie_luv.uv_to_Luv` definition domain and range scale support. @@ -475,7 +477,7 @@ def test_domain_range_scale_uv_to_Luv(self): ) @ignore_numpy_errors - def test_nan_uv_to_Luv(self): + def test_nan_uv_to_Luv(self) -> None: """Test :func:`colour.models.cie_luv.uv_to_Luv` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -489,7 +491,7 @@ class TestLuv_uv_to_xy: methods. """ - def test_Luv_uv_to_xy(self): + def test_Luv_uv_to_xy(self) -> None: """Test :func:`colour.models.cie_luv.Luv_uv_to_xy` definition.""" np.testing.assert_allclose( @@ -510,7 +512,7 @@ def test_Luv_uv_to_xy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Luv_uv_to_xy(self): + def test_n_dimensional_Luv_uv_to_xy(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_uv_to_xy` definition n-dimensional arrays support. @@ -528,7 +530,7 @@ def test_n_dimensional_Luv_uv_to_xy(self): np.testing.assert_allclose(Luv_uv_to_xy(uv), xy, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_Luv_uv_to_xy(self): + def test_nan_Luv_uv_to_xy(self) -> None: """ Test :func:`colour.models.cie_luv.Luv_uv_to_xy` definition nan support. @@ -545,7 +547,7 @@ class TestXy_to_Luv_uv: methods. """ - def test_xy_to_Luv_uv(self): + def test_xy_to_Luv_uv(self) -> None: """Test :func:`colour.models.cie_luv.xy_to_Luv_uv` definition.""" np.testing.assert_allclose( @@ -566,7 +568,7 @@ def test_xy_to_Luv_uv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_Luv_uv(self): + def test_n_dimensional_xy_to_Luv_uv(self) -> None: """ Test :func:`colour.models.cie_luv.xy_to_Luv_uv` definition n-dimensional arrays support. @@ -584,7 +586,7 @@ def test_n_dimensional_xy_to_Luv_uv(self): np.testing.assert_allclose(xy_to_Luv_uv(xy), uv, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_xy_to_Luv_uv(self): + def test_nan_xy_to_Luv_uv(self) -> None: """ Test :func:`colour.models.cie_luv.xy_to_Luv_uv` definition nan support. @@ -601,7 +603,7 @@ class TestXYZ_to_CIE1976UCS: methods. """ - def test_XYZ_to_CIE1976UCS(self): + def test_XYZ_to_CIE1976UCS(self) -> None: """Test :func:`colour.models.cie_luv.XYZ_to_CIE1976UCS` definition.""" np.testing.assert_allclose( @@ -649,7 +651,7 @@ def test_XYZ_to_CIE1976UCS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_CIE1976UCS(self): + def test_n_dimensional_XYZ_to_CIE1976UCS(self) -> None: """ Test :func:`colour.models.cie_luv.XYZ_to_CIE1976UCS` definition n-dimensional support. @@ -677,7 +679,7 @@ def test_n_dimensional_XYZ_to_CIE1976UCS(self): XYZ_to_CIE1976UCS(XYZ, illuminant), Luv, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_CIE1976UCS(self): + def test_domain_range_scale_XYZ_to_CIE1976UCS(self) -> None: """ Test :func:`colour.models.cie_luv.XYZ_to_CIE1976UCS` definition domain and range scale support. @@ -697,7 +699,7 @@ def test_domain_range_scale_XYZ_to_CIE1976UCS(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CIE1976UCS(self): + def test_nan_XYZ_to_CIE1976UCS(self) -> None: """ Test :func:`colour.models.cie_luv.XYZ_to_CIE1976UCS` definition nan support. @@ -714,7 +716,7 @@ class TestCIE1976UCS_to_XYZ: methods. """ - def test_CIE1976UCS_to_XYZ(self): + def test_CIE1976UCS_to_XYZ(self) -> None: """Test :func:`colour.models.cie_luv.CIE1976UCS_to_XYZ` definition.""" np.testing.assert_allclose( @@ -762,7 +764,7 @@ def test_CIE1976UCS_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CIE1976UCS_to_XYZ(self): + def test_n_dimensional_CIE1976UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_luv.CIE1976UCS_to_XYZ` definition n-dimensional support. @@ -790,7 +792,7 @@ def test_n_dimensional_CIE1976UCS_to_XYZ(self): CIE1976UCS_to_XYZ(Luv, illuminant), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_CIE1976UCS_to_XYZ(self): + def test_domain_range_scale_CIE1976UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_luv.CIE1976UCS_to_XYZ` definition domain and range scale support. @@ -810,7 +812,7 @@ def test_domain_range_scale_CIE1976UCS_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_CIE1976UCS_to_XYZ(self): + def test_nan_CIE1976UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_luv.CIE1976UCS_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_cie_ucs.py b/colour/models/tests/test_cie_ucs.py index 969a14195..463b55a5f 100644 --- a/colour/models/tests/test_cie_ucs.py +++ b/colour/models/tests/test_cie_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cie_ucs` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -42,7 +44,7 @@ class TestXYZ_to_UCS: methods. """ - def test_XYZ_to_UCS(self): + def test_XYZ_to_UCS(self) -> None: """Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition.""" np.testing.assert_allclose( @@ -63,7 +65,7 @@ def test_XYZ_to_UCS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_UCS(self): + def test_n_dimensional_XYZ_to_UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition n-dimensional support. @@ -80,7 +82,7 @@ def test_n_dimensional_XYZ_to_UCS(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(XYZ_to_UCS(XYZ), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_XYZ_to_UCS(self): + def test_domain_range_scale_XYZ_to_UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition domain and range scale support. @@ -99,7 +101,7 @@ def test_domain_range_scale_XYZ_to_UCS(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_UCS(self): + def test_nan_XYZ_to_UCS(self) -> None: """Test :func:`colour.models.cie_ucs.XYZ_to_UCS` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -113,7 +115,7 @@ class TestUCS_to_XYZ: methods. """ - def test_UCS_to_XYZ(self): + def test_UCS_to_XYZ(self) -> None: """Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition.""" np.testing.assert_allclose( @@ -134,7 +136,7 @@ def test_UCS_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UCS_to_XYZ(self): + def test_n_dimensional_UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition n-dimensional support. @@ -151,7 +153,7 @@ def test_n_dimensional_UCS_to_XYZ(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(UCS_to_XYZ(UCS), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_UCS_to_XYZ(self): + def test_domain_range_scale_UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition domain and range scale support. @@ -170,7 +172,7 @@ def test_domain_range_scale_UCS_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_UCS_to_XYZ(self): + def test_nan_UCS_to_XYZ(self) -> None: """Test :func:`colour.models.cie_ucs.UCS_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -184,7 +186,7 @@ class TestUCS_to_uv: methods. """ - def test_UCS_to_uv(self): + def test_UCS_to_uv(self) -> None: """Test :func:`colour.models.cie_ucs.UCS_to_uv` definition.""" np.testing.assert_allclose( @@ -205,7 +207,7 @@ def test_UCS_to_uv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UCS_to_uv(self): + def test_n_dimensional_UCS_to_uv(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_to_uv` definition n-dimensional support. @@ -222,7 +224,7 @@ def test_n_dimensional_UCS_to_uv(self): uv = np.reshape(uv, (2, 3, 2)) np.testing.assert_allclose(UCS_to_uv(UCS), uv, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_UCS_to_uv(self): + def test_domain_range_scale_UCS_to_uv(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_to_uv` definition domain and range scale support. @@ -239,7 +241,7 @@ def test_domain_range_scale_UCS_to_uv(self): ) @ignore_numpy_errors - def test_nan_UCS_to_uv(self): + def test_nan_UCS_to_uv(self) -> None: """Test :func:`colour.models.cie_ucs.UCS_to_uv` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -253,7 +255,7 @@ class Testuv_to_UCS: methods. """ - def test_uv_to_UCS(self): + def test_uv_to_UCS(self) -> None: """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition.""" np.testing.assert_allclose( @@ -280,7 +282,7 @@ def test_uv_to_UCS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_uv_to_UCS(self): + def test_n_dimensional_uv_to_UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.uv_to_UCS` definition n-dimensional support. @@ -297,7 +299,7 @@ def test_n_dimensional_uv_to_UCS(self): UCS = np.reshape(UCS, (2, 3, 3)) np.testing.assert_allclose(uv_to_UCS(uv), UCS, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_uv_to_UCS(self): + def test_domain_range_scale_uv_to_UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.uv_to_UCS` definition domain and range scale support. @@ -317,7 +319,7 @@ def test_domain_range_scale_uv_to_UCS(self): ) @ignore_numpy_errors - def test_nan_uv_to_UCS(self): + def test_nan_uv_to_UCS(self) -> None: """Test :func:`colour.models.cie_ucs.uv_to_UCS` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -331,7 +333,7 @@ class TestUCS_uv_to_xy: methods. """ - def test_UCS_uv_to_xy(self): + def test_UCS_uv_to_xy(self) -> None: """Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition.""" np.testing.assert_allclose( @@ -352,7 +354,7 @@ def test_UCS_uv_to_xy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UCS_uv_to_xy(self): + def test_n_dimensional_UCS_uv_to_xy(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition n-dimensional arrays support. @@ -370,7 +372,7 @@ def test_n_dimensional_UCS_uv_to_xy(self): np.testing.assert_allclose(UCS_uv_to_xy(uv), xy, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_UCS_uv_to_xy(self): + def test_nan_UCS_uv_to_xy(self) -> None: """ Test :func:`colour.models.cie_ucs.UCS_uv_to_xy` definition nan support. @@ -387,7 +389,7 @@ class TestXy_to_UCS_uv: methods. """ - def test_xy_to_UCS_uv(self): + def test_xy_to_UCS_uv(self) -> None: """Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition.""" np.testing.assert_allclose( @@ -408,7 +410,7 @@ def test_xy_to_UCS_uv(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_UCS_uv(self): + def test_n_dimensional_xy_to_UCS_uv(self) -> None: """ Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition n-dimensional arrays support. @@ -426,7 +428,7 @@ def test_n_dimensional_xy_to_UCS_uv(self): np.testing.assert_allclose(xy_to_UCS_uv(xy), uv, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_xy_to_UCS_uv(self): + def test_nan_xy_to_UCS_uv(self) -> None: """ Test :func:`colour.models.cie_ucs.xy_to_UCS_uv` definition nan support. @@ -443,7 +445,7 @@ class TestXYZ_to_CIE1960UCS: methods. """ - def test_XYZ_to_CIE1960UCS(self): + def test_XYZ_to_CIE1960UCS(self) -> None: """Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition.""" np.testing.assert_allclose( @@ -464,7 +466,7 @@ def test_XYZ_to_CIE1960UCS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_CIE1960UCS(self): + def test_n_dimensional_XYZ_to_CIE1960UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition n-dimensional support. @@ -485,7 +487,7 @@ def test_n_dimensional_XYZ_to_CIE1960UCS(self): XYZ_to_CIE1960UCS(XYZ), uvV, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_CIE1960UCS(self): + def test_domain_range_scale_XYZ_to_CIE1960UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition domain and range scale support. @@ -504,7 +506,7 @@ def test_domain_range_scale_XYZ_to_CIE1960UCS(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CIE1960UCS(self): + def test_nan_XYZ_to_CIE1960UCS(self) -> None: """ Test :func:`colour.models.cie_ucs.XYZ_to_CIE1960UCS` definition nan support. @@ -521,7 +523,7 @@ class TestCIE1960UCS_to_XYZ: methods. """ - def test_CIE1960UCS_to_XYZ(self): + def test_CIE1960UCS_to_XYZ(self) -> None: """Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition.""" np.testing.assert_allclose( @@ -542,7 +544,7 @@ def test_CIE1960UCS_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CIE1960UCS_to_XYZ(self): + def test_n_dimensional_CIE1960UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition n-dimensional support. @@ -563,7 +565,7 @@ def test_n_dimensional_CIE1960UCS_to_XYZ(self): CIE1960UCS_to_XYZ(uvV), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_CIE1960UCS_to_XYZ(self): + def test_domain_range_scale_CIE1960UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition domain and range scale support. @@ -582,7 +584,7 @@ def test_domain_range_scale_CIE1960UCS_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_CIE1960UCS_to_XYZ(self): + def test_nan_CIE1960UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_ucs.CIE1960UCS_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_cie_uvw.py b/colour/models/tests/test_cie_uvw.py index 1b7331862..49048f635 100644 --- a/colour/models/tests/test_cie_uvw.py +++ b/colour/models/tests/test_cie_uvw.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cie_uvw` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_UVW: methods. """ - def test_XYZ_to_UVW(self): + def test_XYZ_to_UVW(self) -> None: """Test :func:`colour.models.cie_uvw.XYZ_to_UVW` definition.""" np.testing.assert_allclose( @@ -75,7 +77,7 @@ def test_XYZ_to_UVW(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_UVW(self): + def test_n_dimensional_XYZ_to_UVW(self) -> None: """ Test :func:`colour.models.cie_uvw.XYZ_to_UVW` definition n-dimensional support. @@ -103,7 +105,7 @@ def test_n_dimensional_XYZ_to_UVW(self): XYZ_to_UVW(XYZ, illuminant), UVW, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_UVW(self): + def test_domain_range_scale_XYZ_to_UVW(self) -> None: """ Test :func:`colour.models.cie_uvw.XYZ_to_UVW` definition domain and range scale support. @@ -123,7 +125,7 @@ def test_domain_range_scale_XYZ_to_UVW(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_UVW(self): + def test_nan_XYZ_to_UVW(self) -> None: """Test :func:`colour.models.cie_uvw.XYZ_to_UVW` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -137,7 +139,7 @@ class TestUVW_to_XYZ: methods. """ - def test_UVW_to_XYZ(self): + def test_UVW_to_XYZ(self) -> None: """Test :func:`colour.models.cie_uvw.UVW_to_XYZ` definition.""" np.testing.assert_allclose( @@ -185,7 +187,7 @@ def test_UVW_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_UVW_to_XYZ(self): + def test_n_dimensional_UVW_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_uvw.UVW_to_XYZ` definition n-dimensional support. @@ -213,7 +215,7 @@ def test_n_dimensional_UVW_to_XYZ(self): UVW_to_XYZ(UVW, illuminant), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_UVW_to_XYZ(self): + def test_domain_range_scale_UVW_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_uvw.UVW_to_XYZ` definition domain and range scale support. @@ -233,7 +235,7 @@ def test_domain_range_scale_UVW_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_UVW_to_XYZ(self): + def test_nan_UVW_to_XYZ(self) -> None: """Test :func:`colour.models.cie_uvw.UVW_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_cie_xyy.py b/colour/models/tests/test_cie_xyy.py index d9f5ffc19..809d610ae 100644 --- a/colour/models/tests/test_cie_xyy.py +++ b/colour/models/tests/test_cie_xyy.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.cie_xyy` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -38,7 +40,7 @@ class TestXYZ_to_xyY: methods. """ - def test_XYZ_to_xyY(self): + def test_XYZ_to_xyY(self) -> None: """Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition.""" np.testing.assert_allclose( @@ -85,7 +87,7 @@ def test_XYZ_to_xyY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_xyY(self): + def test_n_dimensional_XYZ_to_xyY(self) -> None: """ Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition n-dimensional support. @@ -102,7 +104,7 @@ def test_n_dimensional_XYZ_to_xyY(self): xyY = np.reshape(xyY, (2, 3, 3)) np.testing.assert_allclose(XYZ_to_xyY(XYZ), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_XYZ_to_xyY(self): + def test_domain_range_scale_XYZ_to_xyY(self) -> None: """ Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition domain and range scale support. @@ -127,7 +129,7 @@ def test_domain_range_scale_XYZ_to_xyY(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_xyY(self): + def test_nan_XYZ_to_xyY(self) -> None: """Test :func:`colour.models.cie_xyy.XYZ_to_xyY` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -141,7 +143,7 @@ class TestxyY_to_XYZ: methods. """ - def test_xyY_to_XYZ(self): + def test_xyY_to_XYZ(self) -> None: """Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition.""" np.testing.assert_allclose( @@ -188,7 +190,7 @@ def test_xyY_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xyY_to_XYZ(self): + def test_n_dimensional_xyY_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition n-dimensional support. @@ -205,7 +207,7 @@ def test_n_dimensional_xyY_to_XYZ(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(xyY_to_XYZ(xyY), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_xyY_to_XYZ(self): + def test_domain_range_scale_xyY_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition domain and range scale support. @@ -230,7 +232,7 @@ def test_domain_range_scale_xyY_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_xyY_to_XYZ(self): + def test_nan_xyY_to_XYZ(self) -> None: """Test :func:`colour.models.cie_xyy.xyY_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -244,7 +246,7 @@ class TestxyY_to_xy: methods. """ - def test_xyY_to_xy(self): + def test_xyY_to_xy(self) -> None: """Test :func:`colour.models.cie_xyy.xyY_to_xy` definition.""" np.testing.assert_allclose( @@ -271,7 +273,7 @@ def test_xyY_to_xy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xyY_to_xy(self): + def test_n_dimensional_xyY_to_xy(self) -> None: """ Test :func:`colour.models.cie_xyy.xyY_to_xy` definition n-dimensional support. @@ -288,7 +290,7 @@ def test_n_dimensional_xyY_to_xy(self): xy = np.reshape(xy, (2, 3, 2)) np.testing.assert_allclose(xyY_to_xy(xyY), xy, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_xyY_to_xy(self): + def test_domain_range_scale_xyY_to_xy(self) -> None: """ Test :func:`colour.models.cie_xyy.xyY_to_xy` definition domain and range scale support. @@ -313,7 +315,7 @@ def test_domain_range_scale_xyY_to_xy(self): ) @ignore_numpy_errors - def test_nan_xyY_to_xy(self): + def test_nan_xyY_to_xy(self) -> None: """Test :func:`colour.models.cie_xyy.xyY_to_xy` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -327,7 +329,7 @@ class Testxy_to_xyY: methods. """ - def test_xy_to_xyY(self): + def test_xy_to_xyY(self) -> None: """Test :func:`colour.models.cie_xyy.xy_to_xyY` definition.""" np.testing.assert_allclose( @@ -360,7 +362,7 @@ def test_xy_to_xyY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_xyY(self): + def test_n_dimensional_xy_to_xyY(self) -> None: """ Test :func:`colour.models.cie_xyy.xy_to_xyY` definition n-dimensional support. @@ -377,7 +379,7 @@ def test_n_dimensional_xy_to_xyY(self): xyY = np.reshape(xyY, (2, 3, 3)) np.testing.assert_allclose(xy_to_xyY(xy), xyY, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_xy_to_xyY(self): + def test_domain_range_scale_xy_to_xyY(self) -> None: """ Test :func:`colour.models.cie_xyy.xy_to_xyY` definition domain and range scale support. @@ -390,9 +392,9 @@ def test_domain_range_scale_xy_to_xyY(self): d_r = ( ("reference", 1, 1), - (1, 1, 1), + ("1", 1, 1), ( - 100, + "100", np.array([1, 1, 100]), np.array([1, 1, 100]), ), @@ -406,7 +408,7 @@ def test_domain_range_scale_xy_to_xyY(self): ) @ignore_numpy_errors - def test_nan_xy_to_xyY(self): + def test_nan_xy_to_xyY(self) -> None: """Test :func:`colour.models.cie_xyy.xy_to_xyY` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -420,7 +422,7 @@ class TestXYZ_to_xy: methods. """ - def test_XYZ_to_xy(self): + def test_XYZ_to_xy(self) -> None: """Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition.""" np.testing.assert_allclose( @@ -447,7 +449,7 @@ def test_XYZ_to_xy(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_xy(self): + def test_n_dimensional_XYZ_to_xy(self) -> None: """ Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition n-dimensional support. @@ -464,7 +466,7 @@ def test_n_dimensional_XYZ_to_xy(self): xy = np.reshape(xy, (2, 3, 2)) np.testing.assert_allclose(XYZ_to_xy(XYZ), xy, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_XYZ_to_xy(self): + def test_domain_range_scale_XYZ_to_xy(self) -> None: """ Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition domain and range scale support. @@ -483,7 +485,7 @@ def test_domain_range_scale_XYZ_to_xy(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_xy(self): + def test_nan_XYZ_to_xy(self) -> None: """Test :func:`colour.models.cie_xyy.XYZ_to_xy` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -497,7 +499,7 @@ class Testxy_to_XYZ: methods. """ - def test_xy_to_XYZ(self): + def test_xy_to_XYZ(self) -> None: """Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition.""" np.testing.assert_allclose( @@ -524,7 +526,7 @@ def test_xy_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_XYZ(self): + def test_n_dimensional_xy_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition n-dimensional support. @@ -541,7 +543,7 @@ def test_n_dimensional_xy_to_XYZ(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(xy_to_XYZ(xy), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_xy_to_XYZ(self): + def test_domain_range_scale_xy_to_XYZ(self) -> None: """ Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition domain and range scale support. @@ -566,7 +568,7 @@ def test_domain_range_scale_xy_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_xy_to_XYZ(self): + def test_nan_xy_to_XYZ(self) -> None: """Test :func:`colour.models.cie_xyy.xy_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_common.py b/colour/models/tests/test_common.py index d3ced869c..c874bf85e 100644 --- a/colour/models/tests/test_common.py +++ b/colour/models/tests/test_common.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.common` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -29,7 +31,7 @@ class TestJab_to_JCh: methods. """ - def test_Jab_to_JCh(self): + def test_Jab_to_JCh(self) -> None: """Test :func:`colour.models.common.Jab_to_JCh` definition.""" np.testing.assert_allclose( @@ -50,7 +52,7 @@ def test_Jab_to_JCh(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Jab_to_JCh(self): + def test_n_dimensional_Jab_to_JCh(self) -> None: """ Test :func:`colour.models.common.Jab_to_JCh` definition n-dimensional arrays support. @@ -71,7 +73,7 @@ def test_n_dimensional_Jab_to_JCh(self): Jab_to_JCh(Lab), LCHab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Jab_to_JCh(self): + def test_domain_range_scale_Jab_to_JCh(self) -> None: """ Test :func:`colour.models.common.Jab_to_JCh` definition domain and range scale support. @@ -94,7 +96,7 @@ def test_domain_range_scale_Jab_to_JCh(self): ) @ignore_numpy_errors - def test_nan_Jab_to_JCh(self): + def test_nan_Jab_to_JCh(self) -> None: """Test :func:`colour.models.common.Jab_to_JCh` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -108,7 +110,7 @@ class TestJCh_to_Jab: methods. """ - def test_JCh_to_Jab(self): + def test_JCh_to_Jab(self) -> None: """Test :func:`colour.models.common.JCh_to_Jab` definition.""" np.testing.assert_allclose( @@ -129,7 +131,7 @@ def test_JCh_to_Jab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_JCh_to_Jab(self): + def test_n_dimensional_JCh_to_Jab(self) -> None: """ Test :func:`colour.models.common.JCh_to_Jab` definition n-dimensional arrays support. @@ -150,7 +152,7 @@ def test_n_dimensional_JCh_to_Jab(self): JCh_to_Jab(LCHab), Lab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_JCh_to_Jab(self): + def test_domain_range_scale_JCh_to_Jab(self) -> None: """ Test :func:`colour.models.common.JCh_to_Jab` definition domain and range scale support. @@ -173,7 +175,7 @@ def test_domain_range_scale_JCh_to_Jab(self): ) @ignore_numpy_errors - def test_nan_JCh_to_Jab(self): + def test_nan_JCh_to_Jab(self) -> None: """Test :func:`colour.models.common.JCh_to_Jab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -184,7 +186,7 @@ def test_nan_JCh_to_Jab(self): class TestXYZ_to_Iab: """Define :func:`colour.models.common.XYZ_to_Iab` definition unit tests methods.""" - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self.LMS_to_LMS_p = lambda x: x**0.43 @@ -203,7 +205,7 @@ def setup_method(self): ] ) - def test_XYZ_to_Iab(self): + def test_XYZ_to_Iab(self) -> None: """Test :func:`colour.models.common.XYZ_to_Iab` definition.""" np.testing.assert_allclose( @@ -239,7 +241,7 @@ def test_XYZ_to_Iab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Iab(self): + def test_n_dimensional_XYZ_to_Iab(self) -> None: """ Test :func:`colour.models.common.XYZ_to_Iab` definition n-dimensional support. @@ -264,7 +266,7 @@ def test_n_dimensional_XYZ_to_Iab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Iab(self): + def test_domain_range_scale_XYZ_to_Iab(self) -> None: """ Test :func:`colour.models.common.XYZ_to_Iab` definition domain and range scale support. @@ -288,7 +290,7 @@ def test_domain_range_scale_XYZ_to_Iab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Iab(self): + def test_nan_XYZ_to_Iab(self) -> None: """Test :func:`colour.models.common.XYZ_to_Iab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -302,7 +304,7 @@ class TestIab_to_XYZ: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self.LMS_p_to_LMS = lambda x: x ** (1 / 0.43) @@ -325,7 +327,7 @@ def setup_method(self): ) ) - def test_Iab_to_XYZ(self): + def test_Iab_to_XYZ(self) -> None: """Test :func:`colour.models.common.Iab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -361,7 +363,7 @@ def test_Iab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Iab_to_XYZ(self): + def test_n_dimensional_Iab_to_XYZ(self) -> None: """ Test :func:`colour.models.common.Iab_to_XYZ` definition n-dimensional support. @@ -386,7 +388,7 @@ def test_n_dimensional_Iab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_Iab_to_XYZ(self): + def test_domain_range_scale_Iab_to_XYZ(self) -> None: """ Test :func:`colour.models.common.Iab_to_XYZ` definition domain and range scale support. @@ -410,7 +412,7 @@ def test_domain_range_scale_Iab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Iab_to_XYZ(self): + def test_nan_Iab_to_XYZ(self) -> None: """Test :func:`colour.models.common.Iab_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_din99.py b/colour/models/tests/test_din99.py index b9039cbf2..e870852e9 100644 --- a/colour/models/tests/test_din99.py +++ b/colour/models/tests/test_din99.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.din99` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestLab_to_DIN99: methods. """ - def test_Lab_to_DIN99(self): + def test_Lab_to_DIN99(self) -> None: """Test :func:`colour.models.din99.Lab_to_DIN99` definition.""" np.testing.assert_allclose( @@ -82,7 +84,7 @@ def test_Lab_to_DIN99(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Lab_to_DIN99(self): + def test_n_dimensional_Lab_to_DIN99(self) -> None: """ Test :func:`colour.models.din99.Lab_to_DIN99` definition n-dimensional support. @@ -103,7 +105,7 @@ def test_n_dimensional_Lab_to_DIN99(self): Lab_to_DIN99(Lab), Lab_99, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Lab_to_DIN99(self): + def test_domain_range_scale_Lab_to_DIN99(self) -> None: """ Test :func:`colour.models.din99.Lab_to_DIN99` definition domain and range scale support. @@ -140,7 +142,7 @@ def test_domain_range_scale_Lab_to_DIN99(self): ) @ignore_numpy_errors - def test_nan_Lab_to_DIN99(self): + def test_nan_Lab_to_DIN99(self) -> None: """Test :func:`colour.models.din99.Lab_to_DIN99` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -157,7 +159,7 @@ class TestDIN99_to_Lab: methods. """ - def test_DIN99_to_Lab(self): + def test_DIN99_to_Lab(self) -> None: """Test :func:`colour.models.din99.DIN99_to_Lab` definition.""" np.testing.assert_allclose( @@ -205,7 +207,7 @@ def test_DIN99_to_Lab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_DIN99_to_Lab(self): + def test_n_dimensional_DIN99_to_Lab(self) -> None: """ Test :func:`colour.models.din99.DIN99_to_Lab` definition n-dimensional support. @@ -226,7 +228,7 @@ def test_n_dimensional_DIN99_to_Lab(self): DIN99_to_Lab(Lab_99), Lab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_DIN99_to_Lab(self): + def test_domain_range_scale_DIN99_to_Lab(self) -> None: """ Test :func:`colour.models.din99.DIN99_to_Lab` definition domain and range scale support. @@ -263,7 +265,7 @@ def test_domain_range_scale_DIN99_to_Lab(self): ) @ignore_numpy_errors - def test_nan_DIN99_to_Lab(self): + def test_nan_DIN99_to_Lab(self) -> None: """Test :func:`colour.models.din99.DIN99_to_Lab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -280,7 +282,7 @@ class TestXYZ_to_DIN99: methods. """ - def test_XYZ_to_DIN99(self): + def test_XYZ_to_DIN99(self) -> None: """Test :func:`colour.models.din99.XYZ_to_DIN99` definition.""" np.testing.assert_allclose( @@ -309,7 +311,7 @@ def test_XYZ_to_DIN99(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_DIN99(self): + def test_n_dimensional_XYZ_to_DIN99(self) -> None: """ Test :func:`colour.models.din99.XYZ_to_DIN99` definition n-dimensional support. @@ -330,7 +332,7 @@ def test_n_dimensional_XYZ_to_DIN99(self): XYZ_to_DIN99(XYZ), Lab_99, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_DIN99(self): + def test_domain_range_scale_XYZ_to_DIN99(self) -> None: """ Test :func:`colour.models.din99.XYZ_to_DIN99` definition domain and range scale support. @@ -349,7 +351,7 @@ def test_domain_range_scale_XYZ_to_DIN99(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_DIN99(self): + def test_nan_XYZ_to_DIN99(self) -> None: """Test :func:`colour.models.din99.XYZ_to_DIN99` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -363,7 +365,7 @@ class TestDIN99_to_XYZ: methods. """ - def test_DIN99_to_XYZ(self): + def test_DIN99_to_XYZ(self) -> None: """Test :func:`colour.models.din99.DIN99_to_XYZ` definition.""" np.testing.assert_allclose( @@ -393,7 +395,7 @@ def test_DIN99_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_DIN99_to_XYZ(self): + def test_n_dimensional_DIN99_to_XYZ(self) -> None: """ Test :func:`colour.models.din99.DIN99_to_XYZ` definition n-dimensional support. @@ -414,7 +416,7 @@ def test_n_dimensional_DIN99_to_XYZ(self): DIN99_to_XYZ(Lab_99), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_DIN99_to_XYZ(self): + def test_domain_range_scale_DIN99_to_XYZ(self) -> None: """ Test :func:`colour.models.din99.DIN99_to_XYZ` definition domain and range scale support. @@ -433,7 +435,7 @@ def test_domain_range_scale_DIN99_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_DIN99_to_XYZ(self): + def test_nan_DIN99_to_XYZ(self) -> None: """Test :func:`colour.models.din99.DIN99_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_hdr_cie_lab.py b/colour/models/tests/test_hdr_cie_lab.py index fab0e55cc..55fffffa8 100644 --- a/colour/models/tests/test_hdr_cie_lab.py +++ b/colour/models/tests/test_hdr_cie_lab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.hdr_cie_lab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -29,7 +31,7 @@ class TestExponent_hdr_CIELab: definition unit tests methods. """ - def test_exponent_hdr_CIELab(self): + def test_exponent_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.exponent_hdr_CIELab` definition. @@ -59,7 +61,7 @@ def test_exponent_hdr_CIELab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_exponent_hdr_CIELab(self): + def test_n_dimensional_exponent_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.exponent_hdr_CIELab` definition n-dimensional arrays support. @@ -96,7 +98,7 @@ def test_n_dimensional_exponent_hdr_CIELab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_exponent_hdr_CIELab(self): + def test_domain_range_scale_exponent_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.exponent_hdr_CIELab` definition domain and range scale support. @@ -116,7 +118,7 @@ def test_domain_range_scale_exponent_hdr_CIELab(self): ) @ignore_numpy_errors - def test_nan_exponent_hdr_CIELab(self): + def test_nan_exponent_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.exponent_hdr_CIELab` definition nan support. @@ -132,7 +134,7 @@ class TestXYZ_to_hdr_CIELab: tests methods. """ - def test_XYZ_to_hdr_CIELab(self): + def test_XYZ_to_hdr_CIELab(self) -> None: """Test :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition.""" np.testing.assert_allclose( @@ -174,7 +176,7 @@ def test_XYZ_to_hdr_CIELab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_hdr_CIELab(self): + def test_n_dimensional_XYZ_to_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition n-dimensional support. @@ -214,7 +216,7 @@ def test_n_dimensional_XYZ_to_hdr_CIELab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_hdr_CIELab(self): + def test_domain_range_scale_XYZ_to_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition domain and range scale support. @@ -238,7 +240,7 @@ def test_domain_range_scale_XYZ_to_hdr_CIELab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_hdr_CIELab(self): + def test_nan_XYZ_to_hdr_CIELab(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.XYZ_to_hdr_CIELab` definition nan support. @@ -255,7 +257,7 @@ class TestHdr_CIELab_to_XYZ: tests methods. """ - def test_hdr_CIELab_to_XYZ(self): + def test_hdr_CIELab_to_XYZ(self) -> None: """Test :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -299,7 +301,7 @@ def test_hdr_CIELab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_hdr_CIELab_to_XYZ(self): + def test_n_dimensional_hdr_CIELab_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition n-dimensional support. @@ -339,7 +341,7 @@ def test_n_dimensional_hdr_CIELab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_hdr_CIELab_to_XYZ(self): + def test_domain_range_scale_hdr_CIELab_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition domain and range scale support. @@ -363,7 +365,7 @@ def test_domain_range_scale_hdr_CIELab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_hdr_CIELab_to_XYZ(self): + def test_nan_hdr_CIELab_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_cie_lab.hdr_CIELab_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_hdr_ipt.py b/colour/models/tests/test_hdr_ipt.py index 777d21f79..9274186d1 100644 --- a/colour/models/tests/test_hdr_ipt.py +++ b/colour/models/tests/test_hdr_ipt.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.hdr_ipt` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -29,7 +31,7 @@ class TestExponent_hdr_IPT: definition unit tests methods. """ - def test_exponent_hdr_IPT(self): + def test_exponent_hdr_IPT(self) -> None: """Test :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition.""" np.testing.assert_allclose( @@ -56,7 +58,7 @@ def test_exponent_hdr_IPT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_exponent_hdr_IPT(self): + def test_n_dimensional_exponent_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition n-dimensional arrays support. @@ -93,7 +95,7 @@ def test_n_dimensional_exponent_hdr_IPT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_exponent_hdr_IPT(self): + def test_domain_range_scale_exponent_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition domain and range scale support. @@ -113,7 +115,7 @@ def test_domain_range_scale_exponent_hdr_IPT(self): ) @ignore_numpy_errors - def test_nan_exponent_hdr_IPT(self): + def test_nan_exponent_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.exponent_hdr_IPT` definition nan support. @@ -129,7 +131,7 @@ class TestXYZ_to_hdr_IPT: methods. """ - def test_XYZ_to_hdr_IPT(self): + def test_XYZ_to_hdr_IPT(self) -> None: """Test :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition.""" np.testing.assert_allclose( @@ -159,7 +161,7 @@ def test_XYZ_to_hdr_IPT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_hdr_IPT(self): + def test_n_dimensional_XYZ_to_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition n-dimensional support. @@ -196,7 +198,7 @@ def test_n_dimensional_XYZ_to_hdr_IPT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_hdr_IPT(self): + def test_domain_range_scale_XYZ_to_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition domain and range scale support. @@ -217,7 +219,7 @@ def test_domain_range_scale_XYZ_to_hdr_IPT(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_hdr_IPT(self): + def test_nan_XYZ_to_hdr_IPT(self) -> None: """ Test :func:`colour.models.hdr_ipt.XYZ_to_hdr_IPT` definition nan support. @@ -234,7 +236,7 @@ class TestHdr_IPT_to_XYZ: methods. """ - def test_hdr_IPT_to_XYZ(self): + def test_hdr_IPT_to_XYZ(self) -> None: """Test :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition.""" np.testing.assert_allclose( @@ -266,7 +268,7 @@ def test_hdr_IPT_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_hdr_IPT_to_XYZ(self): + def test_n_dimensional_hdr_IPT_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition n-dimensional support. @@ -303,7 +305,7 @@ def test_n_dimensional_hdr_IPT_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_hdr_IPT_to_XYZ(self): + def test_domain_range_scale_hdr_IPT_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition domain and range scale support. @@ -324,7 +326,7 @@ def test_domain_range_scale_hdr_IPT_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_hdr_IPT_to_XYZ(self): + def test_nan_hdr_IPT_to_XYZ(self) -> None: """ Test :func:`colour.models.hdr_ipt.hdr_IPT_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_hunter_lab.py b/colour/models/tests/test_hunter_lab.py index 869566e12..698b3a04b 100644 --- a/colour/models/tests/test_hunter_lab.py +++ b/colour/models/tests/test_hunter_lab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.hunter_lab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -33,7 +35,7 @@ class TestXYZ_to_K_ab_HunterLab1966: definition unit tests methods. """ - def test_XYZ_to_K_ab_HunterLab1966(self): + def test_XYZ_to_K_ab_HunterLab1966(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_K_ab_HunterLab1966` definition. @@ -63,7 +65,7 @@ def test_XYZ_to_K_ab_HunterLab1966(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_K_ab_HunterLab1966(self): + def test_n_dimensional_XYZ_to_K_ab_HunterLab1966(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_K_ab_HunterLab1966` definition n-dimensional support. @@ -85,7 +87,7 @@ def test_n_dimensional_XYZ_to_K_ab_HunterLab1966(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_K_ab_HunterLab1966(self): + def test_nan_XYZ_to_K_ab_HunterLab1966(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_K_ab_HunterLab1966` definition nan support. @@ -102,7 +104,7 @@ class TestXYZ_to_Hunter_Lab: tests methods. """ - def test_XYZ_to_Hunter_Lab(self): + def test_XYZ_to_Hunter_Lab(self) -> None: """Test :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition.""" np.testing.assert_allclose( @@ -156,7 +158,7 @@ def test_XYZ_to_Hunter_Lab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Hunter_Lab(self): + def test_n_dimensional_XYZ_to_Hunter_Lab(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition n-dimensional support. @@ -196,7 +198,7 @@ def test_n_dimensional_XYZ_to_Hunter_Lab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Hunter_Lab(self): + def test_domain_range_scale_XYZ_to_Hunter_Lab(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition domain and range scale support. @@ -220,7 +222,7 @@ def test_domain_range_scale_XYZ_to_Hunter_Lab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Hunter_Lab(self): + def test_nan_XYZ_to_Hunter_Lab(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_Hunter_Lab` definition nan support. @@ -237,7 +239,7 @@ class TestHunter_Lab_to_XYZ: tests methods. """ - def test_Hunter_Lab_to_XYZ(self): + def test_Hunter_Lab_to_XYZ(self) -> None: """Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -291,7 +293,7 @@ def test_Hunter_Lab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Hunter_Lab_to_XYZ(self): + def test_n_dimensional_Hunter_Lab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition n-dimensional support. @@ -331,7 +333,7 @@ def test_n_dimensional_Hunter_Lab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_Hunter_Lab_to_XYZ(self): + def test_domain_range_scale_Hunter_Lab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition domain and range scale support. @@ -355,7 +357,7 @@ def test_domain_range_scale_Hunter_Lab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Hunter_Lab_to_XYZ(self): + def test_nan_Hunter_Lab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_lab.Hunter_Lab_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_hunter_rdab.py b/colour/models/tests/test_hunter_rdab.py index 76c348e2a..103af7749 100644 --- a/colour/models/tests/test_hunter_rdab.py +++ b/colour/models/tests/test_hunter_rdab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.hunter_rdab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -28,7 +30,7 @@ class TestXYZ_to_Hunter_Rdab: unit tests methods. """ - def test_XYZ_to_Hunter_Rdab(self): + def test_XYZ_to_Hunter_Rdab(self) -> None: """Test :func:`colour.models.hunter_rdab.XYZ_to_Hunter_Rdab` definition.""" np.testing.assert_allclose( @@ -82,7 +84,7 @@ def test_XYZ_to_Hunter_Rdab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Hunter_Rdab(self): + def test_n_dimensional_XYZ_to_Hunter_Rdab(self) -> None: """ Test :func:`colour.models.hunter_rdab.XYZ_to_Hunter_Rdab` definition n-dimensional support. @@ -122,7 +124,7 @@ def test_n_dimensional_XYZ_to_Hunter_Rdab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_XYZ_to_Hunter_Rdab(self): + def test_domain_range_scale_XYZ_to_Hunter_Rdab(self) -> None: """ Test :func:`colour.models.hunter_lab.XYZ_to_Hunter_Rdab` definition domain and range scale support. @@ -146,7 +148,7 @@ def test_domain_range_scale_XYZ_to_Hunter_Rdab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Hunter_Rdab(self): + def test_nan_XYZ_to_Hunter_Rdab(self) -> None: """ Test :func:`colour.models.hunter_rdab.XYZ_to_Hunter_Rdab` definition nan support. @@ -163,7 +165,7 @@ class TestHunter_Rdab_to_XYZ: unit tests methods. """ - def test_Hunter_Rdab_to_XYZ(self): + def test_Hunter_Rdab_to_XYZ(self) -> None: """Test :func:`colour.models.hunter_rdab.Hunter_Rdab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -217,7 +219,7 @@ def test_Hunter_Rdab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_Hunter_Rdab_to_XYZ(self): + def test_n_dimensional_Hunter_Rdab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_rdab.Hunter_Rdab_to_XYZ` definition n-dimensional support. @@ -257,7 +259,7 @@ def test_n_dimensional_Hunter_Rdab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_Hunter_Rdab_to_XYZ(self): + def test_domain_range_scale_Hunter_Rdab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_lab.Hunter_Rdab_to_XYZ` definition domain and range scale support. @@ -281,7 +283,7 @@ def test_domain_range_scale_Hunter_Rdab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Hunter_Rdab_to_XYZ(self): + def test_nan_Hunter_Rdab_to_XYZ(self) -> None: """ Test :func:`colour.models.hunter_rdab.Hunter_Rdab_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_icacb.py b/colour/models/tests/test_icacb.py index 263f981a8..328a79bfb 100644 --- a/colour/models/tests/test_icacb.py +++ b/colour/models/tests/test_icacb.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.hunter_rdab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_ICaCb: methods. """ - def test_XYZ_to_ICaCb(self): + def test_XYZ_to_ICaCb(self) -> None: """Test :func:`colour.models.icacb.XYZ_to_ICaCb` definition.""" np.testing.assert_allclose( @@ -54,7 +56,7 @@ def test_XYZ_to_ICaCb(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_ICaCb(self): + def test_n_dimensional_XYZ_to_ICaCb(self) -> None: """ Test :func:`colour.models.icacb.XYZ_to_ICaCb` definition n-dimensional support. @@ -75,7 +77,7 @@ def test_n_dimensional_XYZ_to_ICaCb(self): XYZ_to_ICaCb(XYZ), ICaCb, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_ICaCb(self): + def test_domain_range_scale_XYZ_to_ICaCb(self) -> None: """ Test :func:`colour.models.icacb.XYZ_to_ICaCb` definition domain and range scale support. @@ -94,7 +96,7 @@ def test_domain_range_scale_XYZ_to_ICaCb(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_ICaCb(self): + def test_nan_XYZ_to_ICaCb(self) -> None: """Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -105,7 +107,7 @@ def test_nan_XYZ_to_ICaCb(self): class TestICaCb_to_XYZ: """Test :func:`colour.models.icacb.ICaCb_to_XYZ` definition.""" - def test_XYZ_to_ICaCb(self): + def test_XYZ_to_ICaCb(self) -> None: """Test :func:`colour.models.icacb.ICaCb_to_XYZ` definition.""" np.testing.assert_allclose( @@ -132,7 +134,7 @@ def test_XYZ_to_ICaCb(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_ICaCb_to_XYZ(self): + def test_n_dimensional_ICaCb_to_XYZ(self) -> None: """ Test :func:`colour.models.icacb.ICaCb_to_XYZ` definition n-dimensional support. @@ -153,7 +155,7 @@ def test_n_dimensional_ICaCb_to_XYZ(self): ICaCb_to_XYZ(ICaCb), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_ICaCb_to_XYZ(self): + def test_domain_range_scale_ICaCb_to_XYZ(self) -> None: """ Test :func:`colour.models.icacb.ICaCb_to_XYZ` definition domain and range scale support. @@ -172,7 +174,7 @@ def test_domain_range_scale_ICaCb_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_ICaCb_to_XYZ(self): + def test_nan_ICaCb_to_XYZ(self) -> None: """Test :func:`colour.models.cie_lab.XYZ_to_Lab` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_igpgtg.py b/colour/models/tests/test_igpgtg.py index fd7ff49e2..bf3524e37 100644 --- a/colour/models/tests/test_igpgtg.py +++ b/colour/models/tests/test_igpgtg.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.igpgtg` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_IgPgTg: methods. """ - def test_XYZ_to_IgPgTg(self): + def test_XYZ_to_IgPgTg(self) -> None: """Test :func:`colour.models.igpgtg.XYZ_to_IgPgTg` definition.""" np.testing.assert_allclose( @@ -48,7 +50,7 @@ def test_XYZ_to_IgPgTg(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_IgPgTg(self): + def test_n_dimensional_XYZ_to_IgPgTg(self) -> None: """ Test :func:`colour.models.igpgtg.XYZ_to_IgPgTg` definition n-dimensional support. @@ -69,7 +71,7 @@ def test_n_dimensional_XYZ_to_IgPgTg(self): XYZ_to_IgPgTg(XYZ), IgPgTg, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_IgPgTg(self): + def test_domain_range_scale_XYZ_to_IgPgTg(self) -> None: """ Test :func:`colour.models.igpgtg.XYZ_to_IgPgTg` definition domain and range scale support. @@ -88,7 +90,7 @@ def test_domain_range_scale_XYZ_to_IgPgTg(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_IgPgTg(self): + def test_nan_XYZ_to_IgPgTg(self) -> None: """ Test :func:`colour.models.igpgtg.XYZ_to_IgPgTg` definition nan support. @@ -105,7 +107,7 @@ class TestIgPgTg_to_XYZ: methods. """ - def test_IgPgTg_to_XYZ(self): + def test_IgPgTg_to_XYZ(self) -> None: """Test :func:`colour.models.igpgtg.IgPgTg_to_XYZ` definition.""" np.testing.assert_allclose( @@ -126,7 +128,7 @@ def test_IgPgTg_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_IgPgTg_to_XYZ(self): + def test_n_dimensional_IgPgTg_to_XYZ(self) -> None: """ Test :func:`colour.models.igpgtg.IgPgTg_to_XYZ` definition n-dimensional support. @@ -147,7 +149,7 @@ def test_n_dimensional_IgPgTg_to_XYZ(self): IgPgTg_to_XYZ(IgPgTg), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_IgPgTg_to_XYZ(self): + def test_domain_range_scale_IgPgTg_to_XYZ(self) -> None: """ Test :func:`colour.models.igpgtg.IgPgTg_to_XYZ` definition domain and range scale support. @@ -166,7 +168,7 @@ def test_domain_range_scale_IgPgTg_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_IgPgTg_to_XYZ(self): + def test_nan_IgPgTg_to_XYZ(self) -> None: """ Test :func:`colour.models.igpgtg.IgPgTg_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_ipt.py b/colour/models/tests/test_ipt.py index c8e29bfe5..ab2aa9b7b 100644 --- a/colour/models/tests/test_ipt.py +++ b/colour/models/tests/test_ipt.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.ipt` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -25,7 +27,7 @@ class TestXYZ_to_IPT: """Define :func:`colour.models.ipt.XYZ_to_IPT` definition unit tests methods.""" - def test_XYZ_to_IPT(self): + def test_XYZ_to_IPT(self) -> None: """Test :func:`colour.models.ipt.XYZ_to_IPT` definition.""" np.testing.assert_allclose( @@ -46,7 +48,7 @@ def test_XYZ_to_IPT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_IPT(self): + def test_n_dimensional_XYZ_to_IPT(self) -> None: """ Test :func:`colour.models.ipt.XYZ_to_IPT` definition n-dimensional support. @@ -63,7 +65,7 @@ def test_n_dimensional_XYZ_to_IPT(self): IPT = np.reshape(IPT, (2, 3, 3)) np.testing.assert_allclose(XYZ_to_IPT(XYZ), IPT, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_XYZ_to_IPT(self): + def test_domain_range_scale_XYZ_to_IPT(self) -> None: """ Test :func:`colour.models.ipt.XYZ_to_IPT` definition domain and range scale support. @@ -82,7 +84,7 @@ def test_domain_range_scale_XYZ_to_IPT(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_IPT(self): + def test_nan_XYZ_to_IPT(self) -> None: """Test :func:`colour.models.ipt.XYZ_to_IPT` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -96,7 +98,7 @@ class TestIPT_to_XYZ: methods. """ - def test_IPT_to_XYZ(self): + def test_IPT_to_XYZ(self) -> None: """Test :func:`colour.models.ipt.IPT_to_XYZ` definition.""" np.testing.assert_allclose( @@ -117,7 +119,7 @@ def test_IPT_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_IPT_to_XYZ(self): + def test_n_dimensional_IPT_to_XYZ(self) -> None: """ Test :func:`colour.models.ipt.IPT_to_XYZ` definition n-dimensional support. @@ -134,7 +136,7 @@ def test_n_dimensional_IPT_to_XYZ(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(IPT_to_XYZ(IPT), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_IPT_to_XYZ(self): + def test_domain_range_scale_IPT_to_XYZ(self) -> None: """ Test :func:`colour.models.ipt.IPT_to_XYZ` definition domain and range scale support. @@ -153,7 +155,7 @@ def test_domain_range_scale_IPT_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_IPT_to_XYZ(self): + def test_nan_IPT_to_XYZ(self) -> None: """Test :func:`colour.models.ipt.IPT_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -167,7 +169,7 @@ class TestIPTHueAngle: methods. """ - def test_IPT_hue_angle(self): + def test_IPT_hue_angle(self) -> None: """Test :func:`colour.models.ipt.IPT_hue_angle` definition.""" np.testing.assert_allclose( @@ -188,7 +190,7 @@ def test_IPT_hue_angle(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_IPT_hue_angle(self): + def test_n_dimensional_IPT_hue_angle(self) -> None: """ Test :func:`colour.models.ipt.IPT_hue_angle` definition n-dimensional support. @@ -209,7 +211,7 @@ def test_n_dimensional_IPT_hue_angle(self): IPT_hue_angle(IPT), hue, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_IPT_hue_angle(self): + def test_domain_range_scale_IPT_hue_angle(self) -> None: """ Test :func:`colour.models.ipt.IPT_hue_angle` definition domain and range scale support. @@ -228,7 +230,7 @@ def test_domain_range_scale_IPT_hue_angle(self): ) @ignore_numpy_errors - def test_nan_IPT_hue_angle(self): + def test_nan_IPT_hue_angle(self) -> None: """Test :func:`colour.models.ipt.IPT_hue_angle` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/models/tests/test_jzazbz.py b/colour/models/tests/test_jzazbz.py index 72ec17603..9b2a2cc46 100644 --- a/colour/models/tests/test_jzazbz.py +++ b/colour/models/tests/test_jzazbz.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.jzazbz` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestXYZ_to_Izazbz: tests methods. """ - def test_XYZ_to_Izazbz(self): + def test_XYZ_to_Izazbz(self) -> None: """Test :func:`colour.models.jzazbz.XYZ_to_Izazbz` definition.""" np.testing.assert_allclose( @@ -74,7 +76,7 @@ def test_XYZ_to_Izazbz(self): ), ) - def test_n_dimensional_XYZ_to_Izazbz(self): + def test_n_dimensional_XYZ_to_Izazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Izazbz` definition n-dimensional support. @@ -95,7 +97,7 @@ def test_n_dimensional_XYZ_to_Izazbz(self): XYZ_to_Izazbz(XYZ), Izazbz, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_Izazbz(self): + def test_domain_range_scale_XYZ_to_Izazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Izazbz` definition domain and range scale support. @@ -114,7 +116,7 @@ def test_domain_range_scale_XYZ_to_Izazbz(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Izazbz(self): + def test_nan_XYZ_to_Izazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Izazbz` definition nan support. @@ -131,7 +133,7 @@ class TestIzazbz_to_XYZ: methods. """ - def test_Izazbz_to_XYZ(self): + def test_Izazbz_to_XYZ(self) -> None: """Test :func:`colour.models.jzazbz.Izazbz_to_XYZ` definition.""" np.testing.assert_allclose( @@ -177,7 +179,7 @@ def test_Izazbz_to_XYZ(self): ), ) - def test_n_dimensional_Izazbz_to_XYZ(self): + def test_n_dimensional_Izazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Izazbz_to_XYZ` definition n-dimensional support. @@ -198,7 +200,7 @@ def test_n_dimensional_Izazbz_to_XYZ(self): Izazbz_to_XYZ(Izazbz), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Izazbz_to_XYZ(self): + def test_domain_range_scale_Izazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Izazbz_to_XYZ` definition domain and range scale support. @@ -217,7 +219,7 @@ def test_domain_range_scale_Izazbz_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Izazbz_to_XYZ(self): + def test_nan_Izazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Izazbz_to_XYZ` definition nan support. @@ -234,7 +236,7 @@ class TestXYZ_to_Jzazbz: tests methods. """ - def test_XYZ_to_Jzazbz(self): + def test_XYZ_to_Jzazbz(self) -> None: """Test :func:`colour.models.jzazbz.XYZ_to_Jzazbz` definition.""" np.testing.assert_allclose( @@ -255,7 +257,7 @@ def test_XYZ_to_Jzazbz(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Jzazbz(self): + def test_n_dimensional_XYZ_to_Jzazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Jzazbz` definition n-dimensional support. @@ -276,7 +278,7 @@ def test_n_dimensional_XYZ_to_Jzazbz(self): XYZ_to_Jzazbz(XYZ), Jzazbz, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_Jzazbz(self): + def test_domain_range_scale_XYZ_to_Jzazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Jzazbz` definition domain and range scale support. @@ -293,7 +295,7 @@ def test_domain_range_scale_XYZ_to_Jzazbz(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Jzazbz(self): + def test_nan_XYZ_to_Jzazbz(self) -> None: """ Test :func:`colour.models.jzazbz.XYZ_to_Jzazbz` definition nan support. @@ -310,7 +312,7 @@ class TestJzazbz_to_XYZ: methods. """ - def test_Jzazbz_to_XYZ(self): + def test_Jzazbz_to_XYZ(self) -> None: """Test :func:`colour.models.jzazbz.Jzazbz_to_XYZ` definition.""" np.testing.assert_allclose( @@ -331,7 +333,7 @@ def test_Jzazbz_to_XYZ(self): atol=1e-6, ) - def test_n_dimensional_Jzazbz_to_XYZ(self): + def test_n_dimensional_Jzazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Jzazbz_to_XYZ` definition n-dimensional support. @@ -352,7 +354,7 @@ def test_n_dimensional_Jzazbz_to_XYZ(self): Jzazbz_to_XYZ(Jzazbz), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Jzazbz_to_XYZ(self): + def test_domain_range_scale_Jzazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Jzazbz_to_XYZ` definition domain and range scale support. @@ -371,7 +373,7 @@ def test_domain_range_scale_Jzazbz_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Jzazbz_to_XYZ(self): + def test_nan_Jzazbz_to_XYZ(self) -> None: """ Test :func:`colour.models.jzazbz.Jzazbz_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_oklab.py b/colour/models/tests/test_oklab.py index 9c0edef2f..c6524e2e9 100644 --- a/colour/models/tests/test_oklab.py +++ b/colour/models/tests/test_oklab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.oklab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_Oklab: tests methods. """ - def test_XYZ_to_Oklab(self): + def test_XYZ_to_Oklab(self) -> None: """Test :func:`colour.models.oklab.XYZ_to_Oklab` definition.""" np.testing.assert_allclose( @@ -48,7 +50,7 @@ def test_XYZ_to_Oklab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Oklab(self): + def test_n_dimensional_XYZ_to_Oklab(self) -> None: """ Test :func:`colour.models.oklab.XYZ_to_Oklab` definition n-dimensional support. @@ -69,7 +71,7 @@ def test_n_dimensional_XYZ_to_Oklab(self): XYZ_to_Oklab(XYZ), Oklab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_Oklab(self): + def test_domain_range_scale_XYZ_to_Oklab(self) -> None: """ Test :func:`colour.models.oklab.XYZ_to_Oklab` definition domain and range scale support. @@ -88,7 +90,7 @@ def test_domain_range_scale_XYZ_to_Oklab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Oklab(self): + def test_nan_XYZ_to_Oklab(self) -> None: """ Test :func:`colour.models.oklab.XYZ_to_Oklab` definition nan support. @@ -105,7 +107,7 @@ class TestOklab_to_XYZ: methods. """ - def test_Oklab_to_XYZ(self): + def test_Oklab_to_XYZ(self) -> None: """Test :func:`colour.models.oklab.Oklab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -126,7 +128,7 @@ def test_Oklab_to_XYZ(self): atol=1e-6, ) - def test_n_dimensional_Oklab_to_XYZ(self): + def test_n_dimensional_Oklab_to_XYZ(self) -> None: """ Test :func:`colour.models.oklab.Oklab_to_XYZ` definition n-dimensional support. @@ -147,7 +149,7 @@ def test_n_dimensional_Oklab_to_XYZ(self): Oklab_to_XYZ(Oklab), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_Oklab_to_XYZ(self): + def test_domain_range_scale_Oklab_to_XYZ(self) -> None: """ Test :func:`colour.models.oklab.Oklab_to_XYZ` definition domain and range scale support. @@ -165,7 +167,7 @@ def test_domain_range_scale_Oklab_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Oklab_to_XYZ(self): + def test_nan_Oklab_to_XYZ(self) -> None: """ Test :func:`colour.models.oklab.Oklab_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_osa_ucs.py b/colour/models/tests/test_osa_ucs.py index 589a0f1dc..ce3a9ce88 100644 --- a/colour/models/tests/test_osa_ucs.py +++ b/colour/models/tests/test_osa_ucs.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.osa_ucs` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_OSA_UCS: methods. """ - def test_XYZ_to_OSA_UCS(self): + def test_XYZ_to_OSA_UCS(self) -> None: """Test :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition.""" np.testing.assert_allclose( @@ -48,7 +50,7 @@ def test_XYZ_to_OSA_UCS(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_OSA_UCS(self): + def test_n_dimensional_XYZ_to_OSA_UCS(self) -> None: """ Test :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition n-dimensional support. @@ -69,7 +71,7 @@ def test_n_dimensional_XYZ_to_OSA_UCS(self): XYZ_to_OSA_UCS(XYZ), Ljg, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_OSA_UCS(self): + def test_domain_range_scale_XYZ_to_OSA_UCS(self) -> None: """ Test :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition domain and range scale support. @@ -88,7 +90,7 @@ def test_domain_range_scale_XYZ_to_OSA_UCS(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_OSA_UCS(self): + def test_nan_XYZ_to_OSA_UCS(self) -> None: """ Test :func:`colour.models.osa_ucs.XYZ_to_OSA_UCS` definition nan support. @@ -105,7 +107,7 @@ class TestOSA_UCS_to_XYZ: methods. """ - def test_OSA_UCS_to_XYZ(self): + def test_OSA_UCS_to_XYZ(self) -> None: """Test :func:`colour.models.osa_ucs.OSA_UCS_to_XYZ` definition.""" np.testing.assert_allclose( @@ -135,7 +137,7 @@ def test_OSA_UCS_to_XYZ(self): atol=5e-5, ) - def test_n_dimensional_OSA_UCS_to_XYZ(self): + def test_n_dimensional_OSA_UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.osa_ucs.OSA_UCS_to_XYZ` definition n-dimensional support. @@ -156,7 +158,7 @@ def test_n_dimensional_OSA_UCS_to_XYZ(self): OSA_UCS_to_XYZ(Ljg), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_OSA_UCS_to_XYZ(self): + def test_domain_range_scale_OSA_UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.osa_ucs.OSA_UCS_to_XYZ` definition domain and range scale support. @@ -173,7 +175,7 @@ def test_domain_range_scale_OSA_UCS_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_OSA_UCS_to_XYZ(self): + def test_nan_OSA_UCS_to_XYZ(self) -> None: """ Test :func:`colour.models.osa_ucs.OSA_UCS_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_prolab.py b/colour/models/tests/test_prolab.py index 70f934ba0..cc5e77cd5 100644 --- a/colour/models/tests/test_prolab.py +++ b/colour/models/tests/test_prolab.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.prolab` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_ProLab: tests methods. """ - def test_XYZ_to_ProLab(self): + def test_XYZ_to_ProLab(self) -> None: """Test :func:`colour.models.ProLab.XYZ_to_ProLab` definition.""" np.testing.assert_allclose( @@ -48,7 +50,7 @@ def test_XYZ_to_ProLab(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_ProLab(self): + def test_n_dimensional_XYZ_to_ProLab(self) -> None: """ Test :func:`colour.models.prolab.XYZ_to_ProLab` definition n-dimensional support. @@ -69,7 +71,7 @@ def test_n_dimensional_XYZ_to_ProLab(self): XYZ_to_ProLab(XYZ), ProLab, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_ProLab(self): + def test_domain_range_scale_XYZ_to_ProLab(self) -> None: """ Test :func:`colour.models.prolab.XYZ_to_ProLab` definition domain and range scale support. @@ -88,7 +90,7 @@ def test_domain_range_scale_XYZ_to_ProLab(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_ProLab(self): + def test_nan_XYZ_to_ProLab(self) -> None: """ Test :func:`colour.models.ProLab.XYZ_to_ProLab` definition nan support. @@ -105,7 +107,7 @@ class TestProLab_to_XYZ: methods. """ - def test_ProLab_to_XYZ(self): + def test_ProLab_to_XYZ(self) -> None: """Test :func:`colour.models.ProLab.ProLab_to_XYZ` definition.""" np.testing.assert_allclose( @@ -126,7 +128,7 @@ def test_ProLab_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_ProLab(self): + def test_n_dimensional_XYZ_to_ProLab(self) -> None: """ Test :func:`colour.models.prolab.XYZ_to_ProLab` definition n-dimensional support. @@ -147,7 +149,7 @@ def test_n_dimensional_XYZ_to_ProLab(self): ProLab_to_XYZ(ProLab), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_ProLab(self): + def test_domain_range_scale_XYZ_to_ProLab(self) -> None: """ Test :func:`colour.models.prolab.XYZ_to_ProLab` definition domain and range scale support. @@ -166,7 +168,7 @@ def test_domain_range_scale_XYZ_to_ProLab(self): ) @ignore_numpy_errors - def test_nan_ProLab_to_XYZ(self): + def test_nan_ProLab_to_XYZ(self) -> None: """ Test :func:`colour.models.ProLab.ProLab_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_ragoo2021.py b/colour/models/tests/test_ragoo2021.py index 8f7ccb92d..096f0f6b3 100644 --- a/colour/models/tests/test_ragoo2021.py +++ b/colour/models/tests/test_ragoo2021.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.ragoo2021` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXYZ_to_IPT_Ragoo2021: unit tests methods. """ - def test_XYZ_to_IPT_Ragoo2021(self): + def test_XYZ_to_IPT_Ragoo2021(self) -> None: """ Test :func:`colour.models.ragoo2021.XYZ_to_IPT_Ragoo2021` definition. """ @@ -50,7 +52,7 @@ def test_XYZ_to_IPT_Ragoo2021(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_IPT_Ragoo2021(self): + def test_n_dimensional_XYZ_to_IPT_Ragoo2021(self) -> None: """ Test :func:`colour.models.ragoo2021.XYZ_to_IPT_Ragoo2021` definition n-dimensional support. @@ -71,7 +73,7 @@ def test_n_dimensional_XYZ_to_IPT_Ragoo2021(self): XYZ_to_IPT_Ragoo2021(XYZ), IPT, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_XYZ_to_IPT_Ragoo2021(self): + def test_domain_range_scale_XYZ_to_IPT_Ragoo2021(self) -> None: """ Test :func:`colour.models.ragoo2021.XYZ_to_IPT_Ragoo2021` definition domain and range scale support. @@ -90,7 +92,7 @@ def test_domain_range_scale_XYZ_to_IPT_Ragoo2021(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_IPT_Ragoo2021(self): + def test_nan_XYZ_to_IPT_Ragoo2021(self) -> None: """ Test :func:`colour.models.ragoo2021.XYZ_to_IPT_Ragoo2021` definition nan support. @@ -107,7 +109,7 @@ class TestIPT_Ragoo2021_to_XYZ: unit tests methods. """ - def test_IPT_Ragoo2021_to_XYZ(self): + def test_IPT_Ragoo2021_to_XYZ(self) -> None: """ Test :func:`colour.models.ragoo2021.IPT_Ragoo2021_to_XYZ` definition. """ @@ -130,7 +132,7 @@ def test_IPT_Ragoo2021_to_XYZ(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_IPT_Ragoo2021_to_XYZ(self): + def test_n_dimensional_IPT_Ragoo2021_to_XYZ(self) -> None: """ Test :func:`colour.models.ragoo2021.IPT_Ragoo2021_to_XYZ` definition n-dimensional support. @@ -151,7 +153,7 @@ def test_n_dimensional_IPT_Ragoo2021_to_XYZ(self): IPT_Ragoo2021_to_XYZ(IPT), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_IPT_Ragoo2021_to_XYZ(self): + def test_domain_range_scale_IPT_Ragoo2021_to_XYZ(self) -> None: """ Test :func:`colour.models.ragoo2021.IPT_Ragoo2021_to_XYZ` definition domain and range scale support. @@ -170,7 +172,7 @@ def test_domain_range_scale_IPT_Ragoo2021_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_IPT_Ragoo2021_to_XYZ(self): + def test_nan_IPT_Ragoo2021_to_XYZ(self) -> None: """ Test :func:`colour.models.ragoo2021.IPT_Ragoo2021_to_XYZ` definition nan support. diff --git a/colour/models/tests/test_yrg.py b/colour/models/tests/test_yrg.py index c8d069b60..3df1f5f53 100644 --- a/colour/models/tests/test_yrg.py +++ b/colour/models/tests/test_yrg.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.models.yrg` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -34,7 +36,7 @@ class TestLMS_to_Yrg: methods. """ - def test_LMS_to_Yrg(self): + def test_LMS_to_Yrg(self) -> None: """Test :func:`colour.models.yrg.LMS_to_Yrg` definition.""" np.testing.assert_allclose( @@ -55,7 +57,7 @@ def test_LMS_to_Yrg(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_LMS_to_Yrg(self): + def test_n_dimensional_LMS_to_Yrg(self) -> None: """ Test :func:`colour.models.yrg.LMS_to_Yrg` definition n-dimensional support. @@ -72,7 +74,7 @@ def test_n_dimensional_LMS_to_Yrg(self): Yrg = np.reshape(Yrg, (2, 3, 3)) np.testing.assert_allclose(LMS_to_Yrg(LMS), Yrg, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_LMS_to_Yrg(self): + def test_domain_range_scale_LMS_to_Yrg(self) -> None: """ Test :func:`colour.models.yrg.LMS_to_Yrg` definition domain and range scale support. @@ -91,7 +93,7 @@ def test_domain_range_scale_LMS_to_Yrg(self): ) @ignore_numpy_errors - def test_nan_LMS_to_Yrg(self): + def test_nan_LMS_to_Yrg(self) -> None: """Test :func:`colour.models.yrg.LMS_to_Yrg` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -104,7 +106,7 @@ class TestYrg_to_LMS: Define :func:`colour.models.yrg.Yrg_to_LMS` definition unit tests methods. """ - def test_Yrg_to_LMS(self): + def test_Yrg_to_LMS(self) -> None: """Test :func:`colour.models.yrg.Yrg_to_LMS` definition.""" np.testing.assert_allclose( @@ -125,7 +127,7 @@ def test_Yrg_to_LMS(self): atol=1e-4, ) - def test_n_dimensional_Yrg_to_LMS(self): + def test_n_dimensional_Yrg_to_LMS(self) -> None: """ Test :func:`colour.models.yrg.Yrg_to_LMS` definition n-dimensional support. @@ -142,7 +144,7 @@ def test_n_dimensional_Yrg_to_LMS(self): LMS = np.reshape(LMS, (2, 3, 3)) np.testing.assert_allclose(Yrg_to_LMS(Yrg), LMS, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_Yrg_to_LMS(self): + def test_domain_range_scale_Yrg_to_LMS(self) -> None: """ Test :func:`colour.models.yrg.Yrg_to_LMS` definition domain and range scale support. @@ -161,7 +163,7 @@ def test_domain_range_scale_Yrg_to_LMS(self): ) @ignore_numpy_errors - def test_nan_Yrg_to_LMS(self): + def test_nan_Yrg_to_LMS(self) -> None: """Test :func:`colour.models.yrg.Yrg_to_LMS` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -175,7 +177,7 @@ class TestXYZ_to_Yrg: methods. """ - def test_XYZ_to_Yrg(self): + def test_XYZ_to_Yrg(self) -> None: """Test :func:`colour.models.yrg.XYZ_to_Yrg` definition.""" np.testing.assert_allclose( @@ -196,7 +198,7 @@ def test_XYZ_to_Yrg(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_Yrg(self): + def test_n_dimensional_XYZ_to_Yrg(self) -> None: """ Test :func:`colour.models.yrg.XYZ_to_Yrg` definition n-dimensional support. @@ -213,7 +215,7 @@ def test_n_dimensional_XYZ_to_Yrg(self): Yrg = np.reshape(Yrg, (2, 3, 3)) np.testing.assert_allclose(XYZ_to_Yrg(XYZ), Yrg, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_XYZ_to_Yrg(self): + def test_domain_range_scale_XYZ_to_Yrg(self) -> None: """ Test :func:`colour.models.yrg.XYZ_to_Yrg` definition domain and range scale support. @@ -232,7 +234,7 @@ def test_domain_range_scale_XYZ_to_Yrg(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_Yrg(self): + def test_nan_XYZ_to_Yrg(self) -> None: """Test :func:`colour.models.yrg.XYZ_to_Yrg` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] @@ -245,7 +247,7 @@ class TestYrg_to_XYZ: Define :func:`colour.models.yrg.Yrg_to_XYZ` definition unit tests methods. """ - def test_Yrg_to_XYZ(self): + def test_Yrg_to_XYZ(self) -> None: """Test :func:`colour.models.yrg.Yrg_to_XYZ` definition.""" np.testing.assert_allclose( @@ -266,7 +268,7 @@ def test_Yrg_to_XYZ(self): atol=2e-4, ) - def test_n_dimensional_Yrg_to_XYZ(self): + def test_n_dimensional_Yrg_to_XYZ(self) -> None: """ Test :func:`colour.models.yrg.Yrg_to_XYZ` definition n-dimensional support. @@ -283,7 +285,7 @@ def test_n_dimensional_Yrg_to_XYZ(self): XYZ = np.reshape(XYZ, (2, 3, 3)) np.testing.assert_allclose(Yrg_to_XYZ(Yrg), XYZ, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_Yrg_to_XYZ(self): + def test_domain_range_scale_Yrg_to_XYZ(self) -> None: """ Test :func:`colour.models.yrg.Yrg_to_XYZ` definition domain and range scale support. @@ -302,7 +304,7 @@ def test_domain_range_scale_Yrg_to_XYZ(self): ) @ignore_numpy_errors - def test_nan_Yrg_to_XYZ(self): + def test_nan_Yrg_to_XYZ(self) -> None: """Test :func:`colour.models.yrg.Yrg_to_XYZ` definition nan support.""" cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan] diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 5867bcb62..a26bd322e 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -1949,7 +1949,7 @@ def hue_angle_to_hue(hue_angle: float) -> NDArrayFloat: return tstack(cast(ArrayLike, [hue, code])) -def hue_to_ASTM_hue(hue_and_code) -> float: +def hue_to_ASTM_hue(hue_and_code: ArrayLike) -> float: """ Convert from the *Munsell* *Colorlab* specification hue and *Munsell* *Colorlab* specification codeto *ASTM* hue number. diff --git a/colour/notation/tests/test_css_color_3.py b/colour/notation/tests/test_css_color_3.py index cdf898b18..d3f5bc037 100644 --- a/colour/notation/tests/test_css_color_3.py +++ b/colour/notation/tests/test_css_color_3.py @@ -25,7 +25,7 @@ class TestKeywordToRGBCSSColor3: definition unit tests methods. """ - def test_keyword_to_RGB_CSSColor3(self): + def test_keyword_to_RGB_CSSColor3(self) -> None: """ Test :func:`colour.notation.css_color_3.keyword_to_RGB_CSSColor3` definition. diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index 46c0719a0..ca97f3867 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.notation.hexadecimal` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -30,7 +32,7 @@ class TestRGB_to_HEX: tests methods. """ - def test_RGB_to_HEX(self): + def test_RGB_to_HEX(self) -> None: """Test :func:`colour.notation.hexadecimal.RGB_to_HEX` definition.""" assert RGB_to_HEX(np.array([0.45620519, 0.03081071, 0.04091952])) == "#74070a" @@ -52,7 +54,7 @@ def test_RGB_to_HEX(self): ["#fe0e0e", "#0e0e0e", "#000e00"], ) - def test_n_dimensional_RGB_to_HEX(self): + def test_n_dimensional_RGB_to_HEX(self) -> None: """ Test :func:`colour.notation.hexadecimal.RGB_to_HEX` definition n-dimensional arrays support. @@ -69,7 +71,7 @@ def test_n_dimensional_RGB_to_HEX(self): HEX = np.reshape(HEX, (2, 3)) assert RGB_to_HEX(RGB).tolist() == HEX.tolist() - def test_domain_range_scale_RGB_to_HEX(self): + def test_domain_range_scale_RGB_to_HEX(self) -> None: """ Test :func:`colour.notation.hexadecimal.RGB_to_HEX` definition domain and range scale support. @@ -84,7 +86,7 @@ def test_domain_range_scale_RGB_to_HEX(self): assert RGB_to_HEX(RGB * factor) == HEX @ignore_numpy_errors - def test_nan_RGB_to_HEX(self): + def test_nan_RGB_to_HEX(self) -> None: """ Test :func:`colour.notation.hexadecimal.RGB_to_HEX` definition nan support. @@ -101,7 +103,7 @@ class TestHEX_to_RGB: tests methods. """ - def test_HEX_to_RGB(self): + def test_HEX_to_RGB(self) -> None: """Test :func:`colour.notation.hexadecimal.HEX_to_RGB` definition.""" np.testing.assert_allclose( @@ -122,7 +124,7 @@ def test_HEX_to_RGB(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_HEX_to_RGB(self): + def test_n_dimensional_HEX_to_RGB(self) -> None: """ Test :func:`colour.notation.hexadecimal.HEX_to_RGB` definition n-dimensional arrays support. @@ -139,7 +141,7 @@ def test_n_dimensional_HEX_to_RGB(self): RGB = np.reshape(RGB, (2, 3, 3)) np.testing.assert_allclose(HEX_to_RGB(HEX), RGB, atol=TOLERANCE_ABSOLUTE_TESTS) - def test_domain_range_scale_HEX_to_RGB(self): + def test_domain_range_scale_HEX_to_RGB(self) -> None: """ Test :func:`colour.notation.hexadecimal.HEX_to_RGB` definition domain and range scale support. diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index c5af0a8cf..a5723d2a6 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -1106,7 +1106,7 @@ class TestMunsellValuePriest1920: unit tests methods. """ - def test_munsell_value_Priest1920(self): + def test_munsell_value_Priest1920(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Priest1920` definition. @@ -1130,7 +1130,7 @@ def test_munsell_value_Priest1920(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_Priest1920(self): + def test_n_dimensional_munsell_value_Priest1920(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Priest1920` definition n-dimensional arrays support. @@ -1157,7 +1157,7 @@ def test_n_dimensional_munsell_value_Priest1920(self): munsell_value_Priest1920(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_Priest1920(self): + def test_domain_range_scale_munsell_value_Priest1920(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Priest1920` definition domain and range scale support. @@ -1176,7 +1176,7 @@ def test_domain_range_scale_munsell_value_Priest1920(self): ) @ignore_numpy_errors - def test_nan_munsell_value_Priest1920(self): + def test_nan_munsell_value_Priest1920(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Priest1920` definition nan support. @@ -1191,7 +1191,7 @@ class TestMunsellValueMunsell1933: definition unit tests methods. """ - def test_munsell_value_Munsell1933(self): + def test_munsell_value_Munsell1933(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Munsell1933` definition. @@ -1215,7 +1215,7 @@ def test_munsell_value_Munsell1933(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_Munsell1933(self): + def test_n_dimensional_munsell_value_Munsell1933(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Munsell1933` definition n-dimensional arrays support. @@ -1242,7 +1242,7 @@ def test_n_dimensional_munsell_value_Munsell1933(self): munsell_value_Munsell1933(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_Munsell1933(self): + def test_domain_range_scale_munsell_value_Munsell1933(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Munsell1933` definition domain and range scale support. @@ -1261,7 +1261,7 @@ def test_domain_range_scale_munsell_value_Munsell1933(self): ) @ignore_numpy_errors - def test_nan_munsell_value_Munsell1933(self): + def test_nan_munsell_value_Munsell1933(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Munsell1933` definition nan support. @@ -1276,7 +1276,7 @@ class TestMunsellValueMoon1943: unit tests methods. """ - def test_munsell_value_Moon1943(self): + def test_munsell_value_Moon1943(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Moon1943` definition. @@ -1300,7 +1300,7 @@ def test_munsell_value_Moon1943(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_Moon1943(self): + def test_n_dimensional_munsell_value_Moon1943(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Moon1943` definition n-dimensional arrays support. @@ -1327,7 +1327,7 @@ def test_n_dimensional_munsell_value_Moon1943(self): munsell_value_Moon1943(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_Moon1943(self): + def test_domain_range_scale_munsell_value_Moon1943(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Moon1943` definition domain and range scale support. @@ -1346,7 +1346,7 @@ def test_domain_range_scale_munsell_value_Moon1943(self): ) @ignore_numpy_errors - def test_nan_munsell_value_Moon1943(self): + def test_nan_munsell_value_Moon1943(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Moon1943` definition nan support. @@ -1361,7 +1361,7 @@ class TestMunsellValueSaunderson1944: definition unit tests methods. """ - def test_munsell_value_Saunderson1944(self): + def test_munsell_value_Saunderson1944(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Saunderson1944` definition. @@ -1385,7 +1385,7 @@ def test_munsell_value_Saunderson1944(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_Saunderson1944(self): + def test_n_dimensional_munsell_value_Saunderson1944(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Saunderson1944` definition n-dimensional arrays support. @@ -1412,7 +1412,7 @@ def test_n_dimensional_munsell_value_Saunderson1944(self): munsell_value_Saunderson1944(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_Saunderson1944(self): + def test_domain_range_scale_munsell_value_Saunderson1944(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Saunderson1944` definition domain and range scale support. @@ -1431,7 +1431,7 @@ def test_domain_range_scale_munsell_value_Saunderson1944(self): ) @ignore_numpy_errors - def test_nan_munsell_value_Saunderson1944(self): + def test_nan_munsell_value_Saunderson1944(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Saunderson1944` definition nan support. @@ -1448,7 +1448,7 @@ class TestMunsellValueLadd1955: unit tests methods. """ - def test_munsell_value_Ladd1955(self): + def test_munsell_value_Ladd1955(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Ladd1955` definition. @@ -1472,7 +1472,7 @@ def test_munsell_value_Ladd1955(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_Ladd1955(self): + def test_n_dimensional_munsell_value_Ladd1955(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Ladd1955` definition n-dimensional arrays support. @@ -1499,7 +1499,7 @@ def test_n_dimensional_munsell_value_Ladd1955(self): munsell_value_Ladd1955(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_Ladd1955(self): + def test_domain_range_scale_munsell_value_Ladd1955(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Ladd1955` definition domain and range scale support. @@ -1518,7 +1518,7 @@ def test_domain_range_scale_munsell_value_Ladd1955(self): ) @ignore_numpy_errors - def test_nan_munsell_value_Ladd1955(self): + def test_nan_munsell_value_Ladd1955(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_Ladd1955` definition nan support. @@ -1533,7 +1533,7 @@ class TestMunsellValueMcCamy1992: unit tests methods. """ - def test_munsell_value_McCamy1987(self): + def test_munsell_value_McCamy1987(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_McCamy1987` definition. @@ -1557,7 +1557,7 @@ def test_munsell_value_McCamy1987(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_McCamy1987(self): + def test_n_dimensional_munsell_value_McCamy1987(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_McCamy1987` definition n-dimensional arrays support. @@ -1584,7 +1584,7 @@ def test_n_dimensional_munsell_value_McCamy1987(self): munsell_value_McCamy1987(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_McCamy1987(self): + def test_domain_range_scale_munsell_value_McCamy1987(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_McCamy1987` definition domain and range scale support. @@ -1603,7 +1603,7 @@ def test_domain_range_scale_munsell_value_McCamy1987(self): ) @ignore_numpy_errors - def test_nan_munsell_value_McCamy1987(self): + def test_nan_munsell_value_McCamy1987(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_McCamy1987` definition nan support. @@ -1618,7 +1618,7 @@ class TestMunsellValueASTMD1535: definition unit tests methods. """ - def test_munsell_value_ASTMD1535(self): + def test_munsell_value_ASTMD1535(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_ASTMD1535` definition. @@ -1642,7 +1642,7 @@ def test_munsell_value_ASTMD1535(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_value_ASTMD1535(self): + def test_n_dimensional_munsell_value_ASTMD1535(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_ASTMD1535` definition n-dimensional arrays support. @@ -1669,7 +1669,7 @@ def test_n_dimensional_munsell_value_ASTMD1535(self): munsell_value_ASTMD1535(Y), V, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_domain_range_scale_munsell_value_ASTMD1535(self): + def test_domain_range_scale_munsell_value_ASTMD1535(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_ASTMD1535` definition domain and range scale support. @@ -1688,7 +1688,7 @@ def test_domain_range_scale_munsell_value_ASTMD1535(self): ) @ignore_numpy_errors - def test_nan_munsell_value_ASTMD1535(self): + def test_nan_munsell_value_ASTMD1535(self) -> None: """ Test :func:`colour.notation.munsell.munsell_value_ASTMD1535` definition nan support. @@ -1703,7 +1703,7 @@ class TestMunsellSpecification_to_xyY: definition unit tests methods. """ - def test_munsell_specification_to_xyY(self): + def test_munsell_specification_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_specification_to_xyY` definition. @@ -1733,7 +1733,7 @@ def test_munsell_specification_to_xyY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_specification_to_xyY(self): + def test_n_dimensional_munsell_specification_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_specification_to_xyY` definition n-dimensional arrays support. @@ -1777,7 +1777,7 @@ def test_n_dimensional_munsell_specification_to_xyY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_munsell_specification_to_xyY(self): + def test_domain_range_scale_munsell_specification_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_specification_to_xyY` definition domain and range scale support. @@ -1800,7 +1800,7 @@ def test_domain_range_scale_munsell_specification_to_xyY(self): ) @ignore_numpy_errors - def test_nan_munsell_specification_to_xyY(self): + def test_nan_munsell_specification_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_specification_to_xyY` definition nan support. @@ -1819,7 +1819,7 @@ class TestMunsellColour_to_xyY: unit tests methods. """ - def test_domain_range_scale_munsell_colour_to_xyY(self): + def test_domain_range_scale_munsell_colour_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_colour_to_xyY` definition domain and range scale support. @@ -1841,7 +1841,7 @@ def test_domain_range_scale_munsell_colour_to_xyY(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_munsell_colour_to_xyY(self): + def test_n_dimensional_munsell_colour_to_xyY(self) -> None: """ Test :func:`colour.notation.munsell.munsell_colour_to_xyY` definition n-dimensional arrays support. @@ -1892,7 +1892,7 @@ class TestxyY_to_munsell_specification: definition unit tests methods. """ - def test_xyY_to_munsell_specification(self): + def test_xyY_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_specification` definition. @@ -1923,7 +1923,7 @@ def test_xyY_to_munsell_specification(self): atol=0.00001, ) - def test_n_dimensional_xyY_to_munsell_specification(self): + def test_n_dimensional_xyY_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_specification` definition n-dimensional arrays support. @@ -1948,7 +1948,7 @@ def test_n_dimensional_xyY_to_munsell_specification(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_xyY_to_munsell_specification(self): + def test_raise_exception_xyY_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_specification` definition raised exception. @@ -1960,7 +1960,7 @@ def test_raise_exception_xyY_to_munsell_specification(self): np.array([0.90615118, 0.57945103, 0.91984064]), ) - def test_domain_range_scale_xyY_to_munsell_specification(self): + def test_domain_range_scale_xyY_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_specification` definition domain and range scale support. @@ -1983,7 +1983,7 @@ def test_domain_range_scale_xyY_to_munsell_specification(self): ) @ignore_numpy_errors - def test_nan_xyY_to_munsell_specification(self): + def test_nan_xyY_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_specification` definition nan support. @@ -2002,7 +2002,7 @@ class TestxyY_to_munsell_colour: unit tests methods. """ - def test_domain_range_scale_xyY_to_munsell_colour(self): + def test_domain_range_scale_xyY_to_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_colour` definition domain and range scale support. @@ -2020,7 +2020,7 @@ def test_domain_range_scale_xyY_to_munsell_colour(self): with domain_range_scale(scale): assert xyY_to_munsell_colour(xyY * factor) == munsell_colour - def test_n_dimensional_xyY_to_munsell_colour(self): + def test_n_dimensional_xyY_to_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.xyY_to_munsell_colour` definition n-dimensional arrays support. @@ -2055,7 +2055,7 @@ class TestParseMunsellColour: unit tests methods. """ - def test_parse_munsell_colour(self): + def test_parse_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.is_grey_munsell_colour` definition. @@ -2079,7 +2079,7 @@ def test_parse_munsell_colour(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_parse_munsell_colour(self): + def test_raise_exception_parse_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.is_grey_munsell_colour` definition raised exception. @@ -2094,7 +2094,7 @@ class TestIsGreyMunsellColour: unit tests methods. """ - def test_is_grey_munsell_colour(self): + def test_is_grey_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.is_grey_munsell_colour` definition. @@ -2115,7 +2115,7 @@ class TestNormaliseMunsellSpecification: definition unit tests methods. """ - def test_normalise_munsell_specification(self): + def test_normalise_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.normalise_munsell_specification` definition. @@ -2152,7 +2152,7 @@ class TestMunsellColourToMunsellSpecification: munsell_colour_to_munsell_specification` definition unit tests methods. """ - def test_munsell_colour_to_munsell_specification(self): + def test_munsell_colour_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.\ munsell_colour_to_munsell_specification` definition. @@ -2195,7 +2195,7 @@ class TestMunsellSpecificationToMunsellColour: munsell_specification_to_munsell_colour` definition unit tests methods. """ - def test_munsell_specification_to_munsell_colour(self): + def test_munsell_specification_to_munsell_colour(self) -> None: """ Test :func:`colour.notation.munsell.\ munsell_specification_to_munsell_colour` definition. @@ -2240,7 +2240,7 @@ class Test_xyY_fromRenotation: unit tests methods. """ - def test_xyY_from_renotation(self): + def test_xyY_from_renotation(self) -> None: """ Test :func:`colour.notation.munsell.xyY_from_renotation` definition. @@ -2268,7 +2268,7 @@ class TestIsSpecificationInRenotation: definition unit tests methods. """ - def test_is_specification_in_renotation(self): + def test_is_specification_in_renotation(self) -> None: """ Test :func:`colour.notation.munsell.is_specification_in_renotation` definition. @@ -2287,7 +2287,7 @@ class TestBoundingHuesFromRenotation: definition unit tests methods. """ - def test_bounding_hues_from_renotation(self): + def test_bounding_hues_from_renotation(self) -> None: """ Test :func:`colour.notation.munsell.bounding_hues_from_renotation` definition. @@ -2307,7 +2307,7 @@ class TestHueToHueAngle: tests methods. """ - def test_hue_to_hue_angle(self): + def test_hue_to_hue_angle(self) -> None: """Test :func:`colour.notation.munsell.hue_to_hue_angle` definition.""" for hue, code, angle in MUNSELL_HUE_TO_ANGLE: @@ -2320,7 +2320,7 @@ class TestHueAngleToHue: tests methods. """ - def test_hue_angle_to_hue(self): + def test_hue_angle_to_hue(self) -> None: """Test :func:`colour.notation.munsell.hue_angle_to_hue` definition.""" for hue, code, angle in MUNSELL_HUE_TO_ANGLE: @@ -2333,7 +2333,7 @@ class TestHueTo_ASTM_hue: tests methods. """ - def test_hue_to_ASTM_hue(self): + def test_hue_to_ASTM_hue(self) -> None: """Test :func:`colour.notation.munsell.hue_to_ASTM_hue` definition.""" for hue, code, angle in MUNSELL_HUE_TO_ASTM_HUE: @@ -2346,7 +2346,7 @@ class TestInterpolationMethodFromRenotationOvoid: interpolation_method_from_renotation_ovoid` definition unit tests methods. """ - def test_interpolation_method_from_renotation_ovoid(self): + def test_interpolation_method_from_renotation_ovoid(self) -> None: """ Test :func:`colour.notation.munsell.\ interpolation_method_from_renotation_ovoid` definition. @@ -2377,7 +2377,7 @@ class Test_xy_fromRenotationOvoid: unit tests methods. """ - def test_xy_from_renotation_ovoid(self): + def test_xy_from_renotation_ovoid(self) -> None: """ Test :func:`colour.notation.munsell.xy_from_renotation_ovoid` definition. @@ -2398,7 +2398,7 @@ class TestLCHabToMunsellSpecification: definition unit tests methods. """ - def test_LCHab_to_munsell_specification(self): + def test_LCHab_to_munsell_specification(self) -> None: """ Test :func:`colour.notation.munsell.LCHab_to_munsell_specification` definition. @@ -2451,7 +2451,7 @@ class TestMaximumChromaFromRenotation: definition unit tests methods. """ - def test_maximum_chroma_from_renotation(self): + def test_maximum_chroma_from_renotation(self) -> None: """ Test :func:`colour.notation.munsell.maximum_chroma_from_renotation` definition. @@ -2470,7 +2470,7 @@ class TestMunsellSpecification_to_xy: definition unit tests methods. """ - def test_munsell_specification_to_xy(self): + def test_munsell_specification_to_xy(self) -> None: """ Test :func:`colour.notation.munsell.munsell_specification_to_xy` definition. diff --git a/colour/phenomena/tests/test_rayleigh.py b/colour/phenomena/tests/test_rayleigh.py index 7680c311a..75dc4b393 100644 --- a/colour/phenomena/tests/test_rayleigh.py +++ b/colour/phenomena/tests/test_rayleigh.py @@ -485,7 +485,7 @@ class TestAirRefractionIndexPenndorf1957: air_refraction_index_Penndorf1957` definition unit tests methods. """ - def test_air_refraction_index_Penndorf1957(self): + def test_air_refraction_index_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Penndorf1957` definition. @@ -509,7 +509,7 @@ def test_air_refraction_index_Penndorf1957(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_air_refraction_index_Penndorf1957(self): + def test_n_dimensional_air_refraction_index_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Penndorf1957` definition n-dimensional arrays support. @@ -543,7 +543,7 @@ def test_n_dimensional_air_refraction_index_Penndorf1957(self): ) @ignore_numpy_errors - def test_nan_air_refraction_index_Penndorf1957(self): + def test_nan_air_refraction_index_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Penndorf1957` definition nan support. @@ -560,7 +560,7 @@ class TestAirRefractionIndexEdlen1966: definition unit tests methods. """ - def test_air_refraction_index_Edlen1966(self): + def test_air_refraction_index_Edlen1966(self) -> None: """ Test :func:`colour.phenomena.\ rayleigh.air_refraction_index_Edlen1966` definition. @@ -584,7 +584,7 @@ def test_air_refraction_index_Edlen1966(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_air_refraction_index_Edlen1966(self): + def test_n_dimensional_air_refraction_index_Edlen1966(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Edlen1966` definition n-dimensional arrays support. @@ -618,7 +618,7 @@ def test_n_dimensional_air_refraction_index_Edlen1966(self): ) @ignore_numpy_errors - def test_nan_air_refraction_index_Edlen1966(self): + def test_nan_air_refraction_index_Edlen1966(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Edlen1966` definition nan support. @@ -635,7 +635,7 @@ class TestAirRefractionIndexPeck1972: definition unit tests methods. """ - def test_air_refraction_index_Peck1972(self): + def test_air_refraction_index_Peck1972(self) -> None: """ Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972` definition. @@ -659,7 +659,7 @@ def test_air_refraction_index_Peck1972(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_air_refraction_index_Peck1972(self): + def test_n_dimensional_air_refraction_index_Peck1972(self) -> None: """ Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972` definition n-dimensional arrays support. @@ -687,7 +687,7 @@ def test_n_dimensional_air_refraction_index_Peck1972(self): ) @ignore_numpy_errors - def test_nan_air_refraction_index_Peck1972(self): + def test_nan_air_refraction_index_Peck1972(self) -> None: """ Test :func:`colour.phenomena.rayleigh.air_refraction_index_Peck1972` definition nan support. @@ -704,7 +704,7 @@ class TestAirRefractionIndexBodhaine1999: air_refraction_index_Bodhaine1999` definition unit tests methods. """ - def test_air_refraction_index_Bodhaine1999(self): + def test_air_refraction_index_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Bodhaine1999` definition. @@ -746,7 +746,7 @@ def test_air_refraction_index_Bodhaine1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_air_refraction_index_Bodhaine1999(self): + def test_n_dimensional_air_refraction_index_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Bodhaine1999` definition n-dimensional arrays support. @@ -780,7 +780,7 @@ def test_n_dimensional_air_refraction_index_Bodhaine1999(self): ) @ignore_numpy_errors - def test_nan_air_refraction_index_Bodhaine1999(self): + def test_nan_air_refraction_index_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.\ air_refraction_index_Bodhaine1999` definition nan support. @@ -796,7 +796,7 @@ class TestN2Depolarisation: unit tests methods. """ - def test_N2_depolarisation(self): + def test_N2_depolarisation(self) -> None: """Test :func:`colour.phenomena.rayleigh.N2_depolarisation` definition.""" np.testing.assert_allclose( @@ -817,7 +817,7 @@ def test_N2_depolarisation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_N2_depolarisation(self): + def test_n_dimensional_N2_depolarisation(self) -> None: """ Test :func:`colour.phenomena.rayleigh.N2_depolarisation` definition n-dimensional arrays support. @@ -845,7 +845,7 @@ def test_n_dimensional_N2_depolarisation(self): ) @ignore_numpy_errors - def test_nan_N2_depolarisation(self): + def test_nan_N2_depolarisation(self) -> None: """ Test :func:`colour.phenomena.rayleigh.N2_depolarisation` definition nan support. @@ -860,7 +860,7 @@ class TestO2Depolarisation: unit tests methods. """ - def test_O2_depolarisation(self): + def test_O2_depolarisation(self) -> None: """Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition.""" np.testing.assert_allclose( @@ -881,7 +881,7 @@ def test_O2_depolarisation(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_O2_depolarisation(self): + def test_n_dimensional_O2_depolarisation(self) -> None: """ Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition n-dimensional arrays support. @@ -909,7 +909,7 @@ def test_n_dimensional_O2_depolarisation(self): ) @ignore_numpy_errors - def test_nan_O2_depolarisation(self): + def test_nan_O2_depolarisation(self) -> None: """ Test :func:`colour.phenomena.rayleigh.O2_depolarisation` definition nan support. @@ -924,7 +924,7 @@ class TestF_airPenndorf1957: unit tests methods. """ - def test_F_air_Penndorf1957(self): + def test_F_air_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition. @@ -932,7 +932,7 @@ def test_F_air_Penndorf1957(self): assert F_air_Penndorf1957(0.360) == 1.0608 - def test_n_dimensional_F_air_Penndorf1957(self): + def test_n_dimensional_F_air_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition n-dimensional arrays support. @@ -960,7 +960,7 @@ def test_n_dimensional_F_air_Penndorf1957(self): ) @ignore_numpy_errors - def test_nan_F_air_Penndorf1957(self): + def test_nan_F_air_Penndorf1957(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Penndorf1957` definition nan support. @@ -975,12 +975,12 @@ class TestF_airYoung1981: unit tests methods. """ - def test_F_air_Young1981(self): + def test_F_air_Young1981(self) -> None: """Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition.""" assert F_air_Young1981(0.360) == 1.0480 - def test_n_dimensional_F_air_Young1981(self): + def test_n_dimensional_F_air_Young1981(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition n-dimensional arrays support. @@ -1008,7 +1008,7 @@ def test_n_dimensional_F_air_Young1981(self): ) @ignore_numpy_errors - def test_nan_F_air_Young1981(self): + def test_nan_F_air_Young1981(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Young1981` definition nan support. @@ -1023,7 +1023,7 @@ class TestF_airBates1984: tests methods. """ - def test_F_air_Bates1984(self): + def test_F_air_Bates1984(self) -> None: """Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition.""" np.testing.assert_allclose( @@ -1044,7 +1044,7 @@ def test_F_air_Bates1984(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_F_air_Bates1984(self): + def test_n_dimensional_F_air_Bates1984(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition n-dimensional arrays support. @@ -1072,7 +1072,7 @@ def test_n_dimensional_F_air_Bates1984(self): ) @ignore_numpy_errors - def test_nan_F_air_Bates1984(self): + def test_nan_F_air_Bates1984(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Bates1984` definition nan support. @@ -1087,7 +1087,7 @@ class TestF_airBodhaine1999: unit tests methods. """ - def test_F_air_Bodhaine1999(self): + def test_F_air_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition. @@ -1129,7 +1129,7 @@ def test_F_air_Bodhaine1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_F_air_Bodhaine1999(self): + def test_n_dimensional_F_air_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition n-dimensional arrays support. @@ -1157,7 +1157,7 @@ def test_n_dimensional_F_air_Bodhaine1999(self): ) @ignore_numpy_errors - def test_nan_F_air_Bodhaine1999(self): + def test_nan_F_air_Bodhaine1999(self) -> None: """ Test :func:`colour.phenomena.rayleigh.F_air_Bodhaine1999` definition nan support. @@ -1173,7 +1173,7 @@ class TestMolecularDensity: unit tests methods. """ - def test_molecular_density(self): + def test_molecular_density(self) -> None: """Test :func:`colour.phenomena.rayleigh.molecular_density` definition.""" np.testing.assert_allclose( @@ -1188,7 +1188,7 @@ def test_molecular_density(self): molecular_density(400), 1.834724604086825e19, atol=10000 ) - def test_n_dimensional_molecular_density(self): + def test_n_dimensional_molecular_density(self) -> None: """ Test :func:`colour.phenomena.rayleigh.molecular_density` definition n-dimensional arrays support. @@ -1216,7 +1216,7 @@ def test_n_dimensional_molecular_density(self): ) @ignore_numpy_errors - def test_nan_molecular_density(self): + def test_nan_molecular_density(self) -> None: """ Test :func:`colour.phenomena.rayleigh.molecular_density` definition nan support. @@ -1231,7 +1231,7 @@ class TestMeanMolecularWeights: definition unit tests methods. """ - def test_mean_molecular_weights(self): + def test_mean_molecular_weights(self) -> None: """ Test :func:`colour.phenomena.rayleigh.mean_molecular_weights` definition. @@ -1253,7 +1253,7 @@ def test_mean_molecular_weights(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_mean_molecular_weights(self): + def test_n_dimensional_mean_molecular_weights(self) -> None: """ Test :func:`colour.phenomena.rayleigh.mean_molecular_weights` definition n-dimensional arrays support. @@ -1281,7 +1281,7 @@ def test_n_dimensional_mean_molecular_weights(self): ) @ignore_numpy_errors - def test_nan_mean_molecular_weights(self): + def test_nan_mean_molecular_weights(self) -> None: """ Test :func:`colour.phenomena.rayleigh.mean_molecular_weights` definition nan support. @@ -1296,7 +1296,7 @@ class TestGravityList1968: unit tests methods. """ - def test_gravity_List1968(self): + def test_gravity_List1968(self) -> None: """Test :func:`colour.phenomena.rayleigh.gravity_List1968` definition.""" np.testing.assert_allclose( @@ -1317,7 +1317,7 @@ def test_gravity_List1968(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_gravity_List1968(self): + def test_n_dimensional_gravity_List1968(self) -> None: """ Test :func:`colour.phenomena.rayleigh.gravity_List1968` definition n-dimensional arrays support. @@ -1336,7 +1336,7 @@ def test_n_dimensional_gravity_List1968(self): np.testing.assert_allclose(gravity_List1968(), g, atol=TOLERANCE_ABSOLUTE_TESTS) @ignore_numpy_errors - def test_nan_gravity_List1968(self): + def test_nan_gravity_List1968(self) -> None: """ Test :func:`colour.phenomena.rayleigh.gravity_List1968` definition nan support. @@ -1352,7 +1352,7 @@ class TestScatteringCrossSection: definition unit tests methods. """ - def test_scattering_cross_section(self): + def test_scattering_cross_section(self) -> None: """ Test :func:`colour.phenomena.rayleigh.scattering_cross_section` definition. @@ -1412,7 +1412,7 @@ def test_scattering_cross_section(self): atol=1e-30, ) - def test_n_dimensional_scattering_cross_section(self): + def test_n_dimensional_scattering_cross_section(self) -> None: """ Test :func:`colour.phenomena.rayleigh.scattering_cross_section` definition n-dimensional arrays support. @@ -1437,7 +1437,7 @@ def test_n_dimensional_scattering_cross_section(self): ) @ignore_numpy_errors - def test_nan_scattering_cross_section(self): + def test_nan_scattering_cross_section(self) -> None: """ Test :func:`colour.phenomena.rayleigh.scattering_cross_section` definition nan support. @@ -1453,7 +1453,7 @@ class TestRayleighOpticalDepth: definition unit tests methods. """ - def test_rayleigh_optical_depth(self): + def test_rayleigh_optical_depth(self) -> None: """ Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth` definition. @@ -1549,7 +1549,7 @@ def test_rayleigh_optical_depth(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_rayleigh_optical_depth(self): + def test_n_dimensional_rayleigh_optical_depth(self) -> None: """ Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth` definition n-dimensional arrays support. @@ -1574,7 +1574,7 @@ def test_n_dimensional_rayleigh_optical_depth(self): ) @ignore_numpy_errors - def test_nan_rayleigh_optical_depth(self): + def test_nan_rayleigh_optical_depth(self) -> None: """ Test :func:`colour.phenomena.rayleigh.rayleigh_optical_depth` definition nan support. @@ -1590,7 +1590,7 @@ class TestSdRayleighScattering: definition unit tests methods. """ - def test_sd_rayleigh_scattering(self): + def test_sd_rayleigh_scattering(self) -> None: """ Test :func:`colour.phenomena.rayleigh.sd_rayleigh_scattering` definition. diff --git a/colour/plotting/colorimetry.py b/colour/plotting/colorimetry.py index 105a5d65e..28b2dfff6 100644 --- a/colour/plotting/colorimetry.py +++ b/colour/plotting/colorimetry.py @@ -26,6 +26,7 @@ from __future__ import annotations +from collections.abc import ValuesView from functools import reduce import matplotlib.pyplot as plt @@ -268,6 +269,7 @@ def plot_multi_sds( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), plot_kwargs: dict | List[dict] | None = None, **kwargs: Any, diff --git a/colour/plotting/common.py b/colour/plotting/common.py index 89fb76221..cf6696982 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -68,6 +68,7 @@ LiteralRGBColourspace, Mapping, NDArrayFloat, + Real, Sequence, Tuple, TypedDict, @@ -776,7 +777,7 @@ def render( def label_rectangles( - labels: Sequence[str], + labels: Sequence[str | Real], rectangles: Sequence[Patch], rotation: Literal["horizontal", "vertical"] | str = "vertical", text_size: float = CONSTANTS_COLOUR_STYLE.font.scaling.medium, @@ -847,7 +848,7 @@ def label_rectangles( return figure, axes -def uniform_axes3d(**kwargs: Any) -> Tuple[Figure, Axes]: +def uniform_axes3d(**kwargs: Any) -> Tuple[Figure, Axes3D]: """ Set equal aspect ratio to given 3d axes. @@ -1133,7 +1134,7 @@ def update_settings_collection( settings_collection: dict | List[dict], keyword_arguments: dict | List[dict], expected_count: int, -): +) -> None: """ Update given settings collection, *in-place*, with given keyword arguments and expected count of settings collection elements. @@ -1233,7 +1234,7 @@ def plot_single_colour_swatch( } ) def plot_multi_colour_swatches( - colour_swatches: Sequence[ArrayLike | ColourSwatch], + colour_swatches: ArrayLike | Sequence[ArrayLike | ColourSwatch], width: float = 1, height: float = 1, spacing: float = 0, @@ -1318,7 +1319,7 @@ def plot_multi_colour_swatches( _figure, axes = artist(**kwargs) # Handling case where `colour_swatches` is a regular *ArrayLike*. - colour_swatches = list(colour_swatches) + colour_swatches = list(colour_swatches) # pyright: ignore colour_swatches_converted = [] if not isinstance(first_item(colour_swatches), ColourSwatch): for _i, colour_swatch in enumerate( diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index bfe10c4e3..f74619748 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -16,6 +16,7 @@ from __future__ import annotations import bisect +from collections.abc import ValuesView import numpy as np from matplotlib.axes import Axes @@ -881,6 +882,7 @@ def plot_sds_in_chromaticity_diagram( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), cmfs: ( MultiSpectralDistributions | str | Sequence[MultiSpectralDistributions | str] @@ -1103,7 +1105,9 @@ def plot_sds_in_chromaticity_diagram( def plot_sds_in_chromaticity_diagram_CIE1931( sds: ( Sequence[SpectralDistribution | MultiSpectralDistributions] + | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), cmfs: ( MultiSpectralDistributions | str | Sequence[MultiSpectralDistributions | str] @@ -1213,7 +1217,9 @@ class instances or a list of :class:`colour.SpectralDistribution` class def plot_sds_in_chromaticity_diagram_CIE1960UCS( sds: ( Sequence[SpectralDistribution | MultiSpectralDistributions] + | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), cmfs: ( MultiSpectralDistributions | str | Sequence[MultiSpectralDistributions | str] @@ -1324,7 +1330,9 @@ class instances or a list of :class:`colour.SpectralDistribution` class def plot_sds_in_chromaticity_diagram_CIE1976UCS( sds: ( Sequence[SpectralDistribution | MultiSpectralDistributions] + | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), cmfs: ( MultiSpectralDistributions | str | Sequence[MultiSpectralDistributions | str] diff --git a/colour/plotting/models.py b/colour/plotting/models.py index 3bc8d3147..e2e256543 100644 --- a/colour/plotting/models.py +++ b/colour/plotting/models.py @@ -70,6 +70,7 @@ Literal, LiteralColourspaceModel, LiteralRGBColourspace, + NDArray, NDArrayFloat, Sequence, Tuple, @@ -264,7 +265,7 @@ def colourspace_model_axis_reorder( def lines_pointer_gamut( method: (Literal["CIE 1931", "CIE 1960 UCS", "CIE 1976 UCS"] | str) = "CIE 1931", -): +) -> tuple[NDArray, NDArray]: """ Return the *Pointer's Gamut* line vertices, i.e., positions, normals and colours, according to given method. diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index 5bbd3ac55..5bc3af990 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -12,6 +12,7 @@ from __future__ import annotations +from collections.abc import ValuesView from itertools import cycle import numpy as np @@ -288,6 +289,7 @@ def plot_multi_sds_colour_rendering_indexes_bars( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), **kwargs: Any, ) -> Tuple[Figure, Axes]: @@ -422,6 +424,7 @@ def plot_multi_sds_colour_quality_scales_bars( Sequence[SpectralDistribution | MultiSpectralDistributions] | SpectralDistribution | MultiSpectralDistributions + | ValuesView ), method: Literal["NIST CQS 7.4", "NIST CQS 9.0"] | str = "NIST CQS 9.0", **kwargs: Any, diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index aa5361f1d..b7bd5d12e 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -33,6 +33,7 @@ List, Literal, NDArray, + NDArrayFloat, Sequence, Tuple, cast, @@ -123,7 +124,7 @@ def lines_daylight_locus( xy_to_ij = METHODS_CHROMATICITY_DIAGRAM[method]["xy_to_ij"] - def CCT_to_plotting_colourspace(CCT): + def CCT_to_plotting_colourspace(CCT: ArrayLike) -> NDArrayFloat: """ Convert given correlated colour temperature :math:`T_{cp}` to the default plotting colourspace. @@ -305,7 +306,7 @@ def lines_planckian_locus( uv_to_ij = METHODS_CHROMATICITY_DIAGRAM[method]["uv_to_ij"] - def CCT_D_uv_to_plotting_colourspace(CCT_D_uv): + def CCT_D_uv_to_plotting_colourspace(CCT_D_uv: ArrayLike) -> NDArrayFloat: """ Convert given correlated colour temperature :math:`T_{cp}` and :math:`\\Delta_{uv}` to the default plotting colourspace. diff --git a/colour/plotting/tests/test_blindness.py b/colour/plotting/tests/test_blindness.py index 77e82d004..d9eb076d9 100644 --- a/colour/plotting/tests/test_blindness.py +++ b/colour/plotting/tests/test_blindness.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.blindness` module.""" +from __future__ import annotations + import numpy as np from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -24,7 +26,7 @@ class TestPlotCvdSimulationMachado2009: definition unit tests methods. """ - def test_plot_cvd_simulation_Machado2009(self): + def test_plot_cvd_simulation_Machado2009(self) -> None: """ Test :func:`colour.plotting.blindness.plot_cvd_simulation_Machado2009` definition. diff --git a/colour/plotting/tests/test_characterisation.py b/colour/plotting/tests/test_characterisation.py index 0fa362031..5186bd32a 100644 --- a/colour/plotting/tests/test_characterisation.py +++ b/colour/plotting/tests/test_characterisation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.characterisation` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -27,7 +29,7 @@ class TestPlotSingleColourChecker: definition unit tests methods. """ - def test_plot_single_colour_checker(self): + def test_plot_single_colour_checker(self) -> None: """ Test :func:`colour.plotting.characterisation.\ plot_single_colour_checker` definition. @@ -45,7 +47,7 @@ class TestPlotMultiColourCheckers: definition unit tests methods. """ - def test_plot_multi_colour_checkers(self): + def test_plot_multi_colour_checkers(self) -> None: """ Test :func:`colour.plotting.characterisation.\ plot_multi_colour_checkers` definition. diff --git a/colour/plotting/tests/test_colorimetry.py b/colour/plotting/tests/test_colorimetry.py index 9b82c9405..5dc208872 100644 --- a/colour/plotting/tests/test_colorimetry.py +++ b/colour/plotting/tests/test_colorimetry.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.colorimetry` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -50,7 +52,7 @@ class TestPlotSingleSd: tests methods. """ - def test_plot_single_sd(self): + def test_plot_single_sd(self) -> None: """Test :func:`colour.plotting.colorimetry.plot_single_sd` definition.""" sd = SpectralDistribution( @@ -83,7 +85,7 @@ class TestPlotMultiSds: tests methods. """ - def test_plot_multi_sds(self): + def test_plot_multi_sds(self) -> None: """Test :func:`colour.plotting.colorimetry.plot_multi_sds` definition.""" sd_1 = SpectralDistribution( @@ -134,7 +136,7 @@ class TestPlotSingleCmfs: unit tests methods. """ - def test_plot_single_cmfs(self): + def test_plot_single_cmfs(self) -> None: """Test :func:`colour.plotting.colorimetry.plot_single_cmfs` definition.""" figure, axes = plot_single_cmfs() @@ -149,7 +151,7 @@ class TestPlotMultiCmfs: tests methods. """ - def test_plot_multi_cmfs(self): + def test_plot_multi_cmfs(self) -> None: """Test :func:`colour.plotting.colorimetry.plot_multi_cmfs` definition.""" figure, axes = plot_multi_cmfs( @@ -169,7 +171,7 @@ class TestPlotSingleIlluminantSd: definition unit tests methods. """ - def test_plot_single_illuminant_sd(self): + def test_plot_single_illuminant_sd(self) -> None: """ Test :func:`colour.plotting.colorimetry.plot_single_illuminant_sd` definition. @@ -187,7 +189,7 @@ class TestPlotMultiIlluminantSds: definition unit tests methods. """ - def test_plot_multi_illuminant_sds(self): + def test_plot_multi_illuminant_sds(self) -> None: """ Test :func:`colour.plotting.colorimetry.plot_multi_illuminant_sds` definition. @@ -213,7 +215,7 @@ class TestPlotVisibleSpectrum: definition unit tests methods. """ - def test_plot_visible_spectrum(self): + def test_plot_visible_spectrum(self) -> None: """ Test :func:`colour.plotting.colorimetry.plot_visible_spectrum` definition. @@ -231,7 +233,7 @@ class TestPlotSingleLightnessFunction: definition unit tests methods. """ - def test_plot_single_lightness_function(self): + def test_plot_single_lightness_function(self) -> None: """ Test :func:`colour.plotting.colorimetry.\ plot_single_lightness_function` definition. @@ -249,7 +251,7 @@ class TestPlotMultiLightnessFunctions: definition unit tests methods. """ - def test_plot_multi_lightness_functions(self): + def test_plot_multi_lightness_functions(self) -> None: """ Test :func:`colour.plotting.colorimetry.\ plot_multi_lightness_functions` definition. @@ -267,7 +269,7 @@ class TestPlotSingleLuminanceFunction: definition unit tests methods. """ - def test_plot_single_luminance_function(self): + def test_plot_single_luminance_function(self) -> None: """ Test :func:`colour.plotting.colorimetry.\ plot_single_luminance_function` definition. @@ -285,7 +287,7 @@ class TestPlotMultiLuminanceFunctions: definition unit tests methods. """ - def test_plot_multi_luminance_functions(self): + def test_plot_multi_luminance_functions(self) -> None: """ Test :func:`colour.plotting.colorimetry.\ plot_multi_luminance_functions` definition. @@ -303,7 +305,7 @@ class TestPlotBlackbodySpectralRadiance: plot_blackbody_spectral_radiance` definition unit tests methods. """ - def test_plot_blackbody_spectral_radiance(self): + def test_plot_blackbody_spectral_radiance(self) -> None: """ Test :func:`colour.plotting.colorimetry.\ plot_blackbody_spectral_radiance` definition. @@ -321,7 +323,7 @@ class TestPlotBlackbodyColours: definition unit tests methods. """ - def test_plot_blackbody_colours(self): + def test_plot_blackbody_colours(self) -> None: """ Test :func:`colour.plotting.colorimetry.plot_blackbody_colours` definition. diff --git a/colour/plotting/tests/test_common.py b/colour/plotting/tests/test_common.py index 350f3b54a..52ffae485 100644 --- a/colour/plotting/tests/test_common.py +++ b/colour/plotting/tests/test_common.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.common` module.""" +from __future__ import annotations + import os import shutil import tempfile @@ -10,10 +12,12 @@ import numpy as np from matplotlib.axes import Axes from matplotlib.figure import Figure +from mpl_toolkits.mplot3d.axes3d import Axes3D import colour from colour.colorimetry import SDS_ILLUMINANTS from colour.constants import TOLERANCE_ABSOLUTE_TESTS +from colour.hints import List, cast from colour.io import read_image from colour.models import RGB_COLOURSPACES, XYZ_to_sRGB, gamma_function from colour.plotting import ( @@ -80,7 +84,7 @@ class TestColourStyle: methods. """ - def test_colour_style(self): + def test_colour_style(self) -> None: """Test :func:`colour.plotting.common.colour_style` definition.""" assert isinstance(colour_style(use_style=False), dict) @@ -92,14 +96,14 @@ class TestOverrideStyle: methods. """ - def test_override_style(self): + def test_override_style(self) -> None: """Test :func:`colour.plotting.common.override_style` definition.""" text_color = plt.rcParams["text.color"] try: @override_style(**{"text.color": "red"}) - def test_text_color_override(): + def test_text_color_override() -> None: """Test :func:`colour.plotting.common.override_style` definition.""" attest(plt.rcParams["text.color"] == "red") @@ -115,7 +119,7 @@ class TestFontScaling: methods. """ - def test_font_scaling(self): + def test_font_scaling(self) -> None: """Test :func:`colour.plotting.common.font_scaling` definition.""" with font_scaling("medium-colour-science", 2): @@ -130,7 +134,7 @@ class TestXYZToPlottingColourspace: definition unit tests methods. """ - def test_XYZ_to_plotting_colourspace(self): + def test_XYZ_to_plotting_colourspace(self) -> None: """ Test :func:`colour.plotting.common.XYZ_to_plotting_colourspace` definition. @@ -150,7 +154,7 @@ class TestColourCycle: methods. """ - def test_colour_cycle(self): + def test_colour_cycle(self) -> None: """Test :func:`colour.plotting.common.colour_cycle` definition.""" cycler = colour_cycle() @@ -188,26 +192,20 @@ class TestArtist: methods. """ - def test_axes_args(self): - """ - Test `colour.plotting.common.artist` figure / axis association - """ - fig1 = plt.figure() - fig_sub1 = fig1.subfigures() - fig_sub2 = fig_sub1.subfigures() - ax1 = fig_sub2.gca() + def test_artist(self) -> None: + """Test :func:`colour.plotting.common.artist` definition.""" - fig_result1, _ = artist(axes=ax1) + figure_1 = plt.figure() + axes = figure_1.subfigures().subfigures().gca() # pyright: ignore - assert fig1 is fig_result1 + figure_2, _axes = artist(axes=axes) - _ = plt.figure() + assert figure_1 is figure_2 - fig_result2, _ = artist(axes=ax1) - assert fig1 is fig_result2 + plt.figure() - def test_artist(self): - """Test :func:`colour.plotting.common.artist` definition.""" + figure_2, _axes = artist(axes=axes) + assert figure_1 is figure_2 figure_1, axes_1 = artist() @@ -227,7 +225,7 @@ class TestCamera: methods. """ - def test_camera(self): + def test_camera(self) -> None: """Test :func:`colour.plotting.common.camera` definition.""" figure, _axes = artist() @@ -245,17 +243,17 @@ class TestRender: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._temporary_directory = tempfile.mkdtemp() - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_render(self): + def test_render(self) -> None: """Test :func:`colour.plotting.common.render` definition.""" figure, axes = artist() @@ -293,7 +291,7 @@ class TestLabelRectangles: tests methods. """ - def test_label_rectangles(self): + def test_label_rectangles(self) -> None: """Test :func:`colour.plotting.common.label_rectangles` definition.""" figure, axes = artist() @@ -301,7 +299,10 @@ def test_label_rectangles(self): samples = np.linspace(0, 1, 10) _figure, axes = label_rectangles( - samples, axes.bar(samples, 1), figure=figure, axes=axes + cast(List[float], samples.tolist()), + axes.bar(samples, 1), + figure=figure, + axes=axes, ) assert len(axes.texts) == len(samples) @@ -313,11 +314,11 @@ class TestUniformAxes3d: methods. """ - def test_uniform_axes3d(self): + def test_uniform_axes3d(self) -> None: """Test :func:`colour.plotting.common.uniform_axes3d` definition.""" figure, _axes = artist() - axes = figure.add_subplot(111, projection="3d") + axes = cast(Axes3D, figure.add_subplot(111, projection="3d")) uniform_axes3d(axes=axes) @@ -331,7 +332,7 @@ class TestFilterPassthrough: tests methods. """ - def test_filter_passthrough(self): + def test_filter_passthrough(self) -> None: """Test :func:`colour.plotting.common.filter_passthrough` definition.""" assert sorted( @@ -375,7 +376,7 @@ class TestFilterRgbColourspaces: unit tests methods. """ - def test_filter_RGB_colourspaces(self): + def test_filter_RGB_colourspaces(self) -> None: """ Test :func:`colour.plotting.common.filter_RGB_colourspaces` definition. @@ -393,7 +394,7 @@ class TestFilterCmfs: methods. """ - def test_filter_cmfs(self): + def test_filter_cmfs(self) -> None: """Test :func:`colour.plotting.common.filter_cmfs` definition.""" assert sorted( @@ -410,7 +411,7 @@ class TestFilterIlluminants: tests methods. """ - def test_filter_illuminants(self): + def test_filter_illuminants(self) -> None: """Test :func:`colour.plotting.common.filter_illuminants` definition.""" assert sorted(filter_illuminants(["D50"]).keys()) == ["D50"] @@ -422,7 +423,7 @@ class TestFilterColourCheckers: unit tests methods. """ - def test_filter_colour_checkers(self): + def test_filter_colour_checkers(self) -> None: """Test :func:`colour.plotting.common.filter_colour_checkers` definition.""" assert sorted( @@ -441,7 +442,7 @@ class TestUpdateSettingsCollection: definition unit tests methods. """ - def test_update_settings_collection(self): + def test_update_settings_collection(self) -> None: """ Test :func:`colour.plotting.common.update_settings_collection` definition. @@ -464,7 +465,7 @@ class TestPlotSingleColourSwatch: unit tests methods. """ - def test_plot_single_colour_swatch(self): + def test_plot_single_colour_swatch(self) -> None: """ Test :func:`colour.plotting.common.plot_single_colour_swatch` definition. @@ -491,7 +492,7 @@ class TestPlotMultiColourSwatches: definition unit tests methods. """ - def test_plot_multi_colour_swatches(self): + def test_plot_multi_colour_swatches(self) -> None: """ Test :func:`colour.plotting.common.plot_multi_colour_swatches` definition. @@ -527,7 +528,7 @@ class TestPlotSingleFunction: tests methods. """ - def test_plot_single_function(self): + def test_plot_single_function(self) -> None: """Test :func:`colour.plotting.common.plot_single_function` definition.""" figure, axes = plot_single_function(partial(gamma_function, exponent=1 / 2.2)) @@ -542,7 +543,7 @@ class TestPlotMultiFunctions: tests methods. """ - def test_plot_multi_functions(self): + def test_plot_multi_functions(self) -> None: """Test :func:`colour.plotting.common.plot_multi_functions` definition.""" functions = { @@ -581,11 +582,15 @@ class TestPlotImage: methods. """ - def test_plot_image(self): + def test_plot_image(self) -> None: """Test :func:`colour.plotting.common.plot_image` definition.""" path = os.path.join( - colour.__path__[0], "..", "docs", "_static", "Logo_Medium_001.png" + colour.__path__[0], # pyright: ignore + "..", + "docs", + "_static", + "Logo_Medium_001.png", ) # Distribution does not ship the documentation thus we are skipping diff --git a/colour/plotting/tests/test_corresponding.py b/colour/plotting/tests/test_corresponding.py index dba1bddc9..6be6d0a2e 100644 --- a/colour/plotting/tests/test_corresponding.py +++ b/colour/plotting/tests/test_corresponding.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.corresponding` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -23,7 +25,7 @@ class TestPlotCorrespondingChromaticitiesPrediction: plot_corresponding_chromaticities_prediction` definition unit tests methods. """ - def test_plot_corresponding_chromaticities_prediction(self): + def test_plot_corresponding_chromaticities_prediction(self) -> None: """ Test :func:`colour.plotting.corresponding.\ plot_corresponding_chromaticities_prediction` definition. diff --git a/colour/plotting/tests/test_diagrams.py b/colour/plotting/tests/test_diagrams.py index 297296d1e..8dd77b54e 100644 --- a/colour/plotting/tests/test_diagrams.py +++ b/colour/plotting/tests/test_diagrams.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.diagrams` module.""" +from __future__ import annotations + import pytest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -54,7 +56,7 @@ class TestLinesSpectralLocus: unit tests methods. """ - def test_lines_spectral_locus(self): + def test_lines_spectral_locus(self) -> None: """ Test :func:`colour.plotting.diagrams.lines_spectral_locus` definition. @@ -69,7 +71,7 @@ class TestPlotSpectralLocus: unit tests methods. """ - def test_plot_spectral_locus(self): + def test_plot_spectral_locus(self) -> None: """ Test :func:`colour.plotting.diagrams.plot_spectral_locus` definition. """ @@ -117,7 +119,7 @@ class TestPlotChromaticityDiagramColours: definition unit tests methods. """ - def test_plot_chromaticity_diagram_colours(self): + def test_plot_chromaticity_diagram_colours(self) -> None: """ Test :func:`colour.plotting.diagrams.plot_chromaticity_diagram_colours` definition. @@ -145,7 +147,7 @@ class TestPlotChromaticityDiagram: definition unit tests methods. """ - def test_plot_chromaticity_diagram(self): + def test_plot_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.diagrams.plot_chromaticity_diagram` definition. @@ -182,7 +184,7 @@ class TestPlotChromaticityDiagramCIE1931: definition unit tests methods. """ - def test_plot_chromaticity_diagram_CIE1931(self): + def test_plot_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_chromaticity_diagram_CIE1931` definition. @@ -200,7 +202,7 @@ class TestPlotChromaticityDiagramCIE1960UCS: plot_chromaticity_diagram_CIE1960UCS` definition unit tests methods. """ - def test_plot_chromaticity_diagram_CIE1960UCS(self): + def test_plot_chromaticity_diagram_CIE1960UCS(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_chromaticity_diagram_CIE1960UCS` definition. @@ -218,7 +220,7 @@ class TestPlotChromaticityDiagramCIE1976UCS: plot_chromaticity_diagram_CIE1976UCS` definition unit tests methods. """ - def test_plot_chromaticity_diagram_CIE1976UCS(self): + def test_plot_chromaticity_diagram_CIE1976UCS(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_chromaticity_diagram_CIE1976UCS` definition. @@ -236,7 +238,7 @@ class TestPlotSdsInChromaticityDiagram: plot_sds_in_chromaticity_diagram` definition unit tests methods. """ - def test_plot_sds_in_chromaticity_diagram(self): + def test_plot_sds_in_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.diagrams.plot_sds_in_chromaticity_diagram` definition. @@ -276,7 +278,7 @@ class TestPlotSdsInChromaticityDiagramCIE1931: plot_sds_in_chromaticity_diagram_CIE1931` definition unit tests methods. """ - def test_plot_sds_in_chromaticity_diagram_CIE1931(self): + def test_plot_sds_in_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1931` definition. @@ -296,7 +298,7 @@ class TestPlotSdsInChromaticityDiagramCIE1960UCS: plot_sds_in_chromaticity_diagram_CIE1960UCS` definition unit tests methods. """ - def test_plot_sds_in_chromaticity_diagram_CIE1960UCS(self): + def test_plot_sds_in_chromaticity_diagram_CIE1960UCS(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1960UCS` definition. @@ -316,7 +318,7 @@ class TestPlotSdsInChromaticityDiagramCIE1976UCS: plot_sds_in_chromaticity_diagram_CIE1976UCS` definition unit tests methods. """ - def test_plot_sds_in_chromaticity_diagram_CIE1976UCS(self): + def test_plot_sds_in_chromaticity_diagram_CIE1976UCS(self) -> None: """ Test :func:`colour.plotting.diagrams.\ plot_sds_in_chromaticity_diagram_CIE1976UCS` definition. diff --git a/colour/plotting/tests/test_graph.py b/colour/plotting/tests/test_graph.py index 9a60b724f..07cef22a7 100644 --- a/colour/plotting/tests/test_graph.py +++ b/colour/plotting/tests/test_graph.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.graph` module.""" +from __future__ import annotations + import tempfile from colour.plotting import plot_automatic_colour_conversion_graph @@ -23,7 +25,7 @@ class TestPlotAutomaticColourConversionGraph: plot_automatic_colour_conversion_graph` definition unit tests methods. """ - def test_plot_automatic_colour_conversion_graph(self): + def test_plot_automatic_colour_conversion_graph(self) -> None: """ Test :func:`colour.plotting.graph.\ plot_automatic_colour_conversion_graph` definition. diff --git a/colour/plotting/tests/test_models.py b/colour/plotting/tests/test_models.py index 4db8c4d44..3ba72e01c 100644 --- a/colour/plotting/tests/test_models.py +++ b/colour/plotting/tests/test_models.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.models` module.""" +from __future__ import annotations + import numpy as np import pytest from matplotlib.axes import Axes @@ -65,7 +67,7 @@ class TestCommonColourspaceModelAxisReorder: definition unit tests methods. """ - def test_colourspace_model_axis_reorder(self): + def test_colourspace_model_axis_reorder(self) -> None: """ Test :func:`colour.plotting.models.colourspace_model_axis_reorder` definition. @@ -108,7 +110,7 @@ class TestLinesPointerGamut: tests methods. """ - def test_lines_pointer_gamut(self): + def test_lines_pointer_gamut(self) -> None: """ Test :func:`colour.plotting.models.lines_pointer_gamut` definition. """ @@ -122,7 +124,7 @@ class TestPlotPointerGamut: tests methods. """ - def test_plot_pointer_gamut(self): + def test_plot_pointer_gamut(self) -> None: """Test :func:`colour.plotting.models.plot_pointer_gamut` definition.""" figure, axes = plot_pointer_gamut() @@ -149,7 +151,7 @@ class TestPlotRGBColourspacesInChromaticityDiagram: plot_RGB_colourspaces_in_chromaticity_diagram` definition unit tests methods. """ - def test_plot_RGB_colourspaces_in_chromaticity_diagram(self): + def test_plot_RGB_colourspaces_in_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram` definition. @@ -190,7 +192,7 @@ class TestPlotRGBColourspacesInChromaticityDiagramCIE1931: methods. """ - def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931(self): + def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1931` definition. @@ -211,7 +213,7 @@ class TestPlotRGBColourspacesInChromaticityDiagramCIE1960UCS: methods. """ - def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS(self): + def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1960UCS` definition. @@ -235,7 +237,7 @@ class TestPlotRGBColourspacesInChromaticityDiagramCIE1976UCS: methods. """ - def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS(self): + def test_plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_colourspaces_in_chromaticity_diagram_CIE1976UCS` definition. @@ -258,7 +260,7 @@ class TestPlotRGBChromaticitiesInChromaticityDiagram: plot_RGB_chromaticities_in_chromaticity_diagram` definition unit tests methods. """ - def test_plot_RGB_chromaticities_in_chromaticity_diagram(self): + def test_plot_RGB_chromaticities_in_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram` definition. @@ -279,7 +281,7 @@ class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1931: methods. """ - def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(self): + def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1931` definition. @@ -300,7 +302,7 @@ class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1960UCS: tests methods. """ - def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(self): + def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1960UCS` definition. @@ -324,7 +326,7 @@ class TestPlotRGBChromaticitiesInChromaticityDiagramCIE1976UCS: tests methods. """ - def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(self): + def test_plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS(self) -> None: """ Test :func:`colour.plotting.models.\ plot_RGB_chromaticities_in_chromaticity_diagram_CIE1976UCS` definition. @@ -347,7 +349,7 @@ class TestEllipsesMacAdam1942: tests methods. """ - def test_ellipses_MacAdam1942(self): + def test_ellipses_MacAdam1942(self) -> None: """Test :func:`colour.plotting.models.ellipses_MacAdam1942` definition.""" assert len(ellipses_MacAdam1942()) == 25 @@ -362,7 +364,7 @@ class TestPlotEllipsesMacAdam1942InChromaticityDiagram: methods. """ - def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram(self): + def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram` definition. @@ -391,7 +393,7 @@ class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1931: tests methods. """ - def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(self): + def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1931` definition. @@ -415,7 +417,7 @@ class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1960UCS: def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS( self, - ): + ) -> None: """ Test :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1960UCS` definition. @@ -439,7 +441,7 @@ class TestPlotEllipsesMacAdam1942InChromaticityDiagramCIE1976UCS: def test_plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS( self, - ): + ) -> None: """ Test :func:`colour.plotting.models.\ plot_ellipses_MacAdam1942_in_chromaticity_diagram_CIE1976UCS` definition. @@ -460,7 +462,7 @@ class TestPlotSingleCctf: tests methods. """ - def test_plot_single_cctf(self): + def test_plot_single_cctf(self) -> None: """Test :func:`colour.plotting.models.plot_single_cctf` definition.""" figure, axes = plot_single_cctf("ITU-R BT.709") @@ -475,7 +477,7 @@ class TestPlotMultiCctfs: tests methods. """ - def test_plot_multi_cctfs(self): + def test_plot_multi_cctfs(self) -> None: """Test :func:`colour.plotting.models.plot_multi_cctfs` definition.""" figure, axes = plot_multi_cctfs(["ITU-R BT.709", "sRGB"]) @@ -490,7 +492,7 @@ class TestPlotConstantHueLoci: unit tests methods. """ - def test_plot_constant_hue_loci(self): + def test_plot_constant_hue_loci(self) -> None: """Test :func:`colour.plotting.models.plot_constant_hue_loci` definition.""" data = [ diff --git a/colour/plotting/tests/test_notation.py b/colour/plotting/tests/test_notation.py index 61d4f5e78..8563ce124 100644 --- a/colour/plotting/tests/test_notation.py +++ b/colour/plotting/tests/test_notation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.notation` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -27,7 +29,7 @@ class TestPlotSingleMunsellValueFunction: definition unit tests methods. """ - def test_plot_single_munsell_value_function(self): + def test_plot_single_munsell_value_function(self) -> None: """ Test :func:`colour.plotting.notation.\ plot_single_munsell_value_function` definition. @@ -45,7 +47,7 @@ class TestPlotMultiMunsellValueFunctions: definition unit tests methods. """ - def test_plot_multi_munsell_value_functions(self): + def test_plot_multi_munsell_value_functions(self) -> None: """ Test :func:`colour.plotting.notation.\ plot_multi_munsell_value_functions` definition. diff --git a/colour/plotting/tests/test_phenomena.py b/colour/plotting/tests/test_phenomena.py index ccda103ba..d94268850 100644 --- a/colour/plotting/tests/test_phenomena.py +++ b/colour/plotting/tests/test_phenomena.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.phenomena` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -27,7 +29,7 @@ class TestPlotSingleSdRayleighScattering: plot_single_sd_rayleigh_scattering` definition unit tests methods. """ - def test_plot_single_sd_rayleigh_scattering(self): + def test_plot_single_sd_rayleigh_scattering(self) -> None: """ Test :func:`colour.plotting.phenomena.\ plot_single_sd_rayleigh_scattering` definition. @@ -45,7 +47,7 @@ class TestPlotTheBlueSky: tests methods. """ - def test_plot_the_blue_sky(self): + def test_plot_the_blue_sky(self) -> None: """Test :func:`colour.plotting.phenomena.plot_the_blue_sky` definition.""" figure, axes = plot_the_blue_sky() diff --git a/colour/plotting/tests/test_quality.py b/colour/plotting/tests/test_quality.py index 97f5ab47e..8d2b45c47 100644 --- a/colour/plotting/tests/test_quality.py +++ b/colour/plotting/tests/test_quality.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.quality` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -40,7 +42,7 @@ class TestPlotColourQualityBars: unit tests methods. """ - def test_plot_colour_quality_bars(self): + def test_plot_colour_quality_bars(self) -> None: """ Test :func:`colour.plotting.quality.plot_colour_quality_bars` definition. @@ -52,7 +54,7 @@ def test_plot_colour_quality_bars(self): cqs_i = colour_quality_scale(illuminant, additional_data=True) cqs_l = colour_quality_scale(light_source, additional_data=True) - figure, axes = plot_colour_quality_bars([cqs_i, cqs_l]) + figure, axes = plot_colour_quality_bars([cqs_i, cqs_l]) # pyright: ignore assert isinstance(figure, Figure) assert isinstance(axes, Axes) @@ -64,7 +66,7 @@ class TestPlotSingleSdColourRenderingIndexBars: plot_single_sd_colour_rendering_index_bars` definition unit tests methods. """ - def test_plot_single_sd_colour_rendering_index_bars(self): + def test_plot_single_sd_colour_rendering_index_bars(self) -> None: """ Test :func:`colour.plotting.quality.\ plot_single_sd_colour_rendering_index_bars` definition. @@ -84,7 +86,7 @@ class TestPlotMultiSdsColourRenderingIndexesBars: plot_multi_sds_colour_rendering_indexes_bars` definition unit tests methods. """ - def test_plot_multi_sds_colour_rendering_indexes_bars(self): + def test_plot_multi_sds_colour_rendering_indexes_bars(self) -> None: """ Test :func:`colour.plotting.quality.\ plot_multi_sds_colour_rendering_indexes_bars` definition. @@ -104,7 +106,7 @@ class TestPlotSingleSdColourQualityScaleBars: plot_single_sd_colour_quality_scale_bars` definition unit tests methods. """ - def test_plot_single_sd_colour_quality_scale_bars(self): + def test_plot_single_sd_colour_quality_scale_bars(self) -> None: """ Test :func:`colour.plotting.quality.\ plot_single_sd_colour_quality_scale_bars` definition. @@ -122,7 +124,7 @@ class TestPlotMultiSdsColourQualityScalesBars: plot_multi_sds_colour_quality_scales_bars` definition unit tests methods. """ - def test_plot_multi_sds_colour_quality_scales_bars(self): + def test_plot_multi_sds_colour_quality_scales_bars(self) -> None: """ Test :func:`colour.plotting.quality.\ plot_multi_sds_colour_quality_scales_bars` definition. diff --git a/colour/plotting/tests/test_section.py b/colour/plotting/tests/test_section.py index 8fe179919..8653bcae7 100644 --- a/colour/plotting/tests/test_section.py +++ b/colour/plotting/tests/test_section.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.section` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -36,7 +38,7 @@ class TestPlotHullSectionColours: definition unit tests methods. """ - def test_plot_hull_section_colours(self): + def test_plot_hull_section_colours(self) -> None: """ Test :func:`colour.plotting.section.plot_hull_section_colours` definition. @@ -73,7 +75,7 @@ class TestPlotHullSectionContour: definition unit tests methods. """ - def test_plot_hull_section_contour(self): + def test_plot_hull_section_contour(self) -> None: """ Test :func:`colour.plotting.section.plot_hull_section_contour` definition. @@ -100,7 +102,7 @@ class TestPlotVisibleSpectrumSection: definition unit tests methods. """ - def test_plot_visible_spectrum_section(self): + def test_plot_visible_spectrum_section(self) -> None: """ Test :func:`colour.plotting.section.plot_visible_spectrum_section` definition. @@ -121,7 +123,7 @@ class TestPlotRGBColourspaceSection: definition unit tests methods. """ - def test_plot_RGB_colourspace_section(self): + def test_plot_RGB_colourspace_section(self) -> None: """ Test :func:`colour.plotting.section.plot_RGB_colourspace_section` definition. diff --git a/colour/plotting/tests/test_temperature.py b/colour/plotting/tests/test_temperature.py index 7f00cbca2..0957808d1 100644 --- a/colour/plotting/tests/test_temperature.py +++ b/colour/plotting/tests/test_temperature.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.temperature` module.""" +from __future__ import annotations + import pytest from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -40,7 +42,7 @@ class TestLinesDaylightLocus: unit tests methods. """ - def test_lines_daylight_locus(self): + def test_lines_daylight_locus(self) -> None: """ Test :func:`colour.plotting.diagrams.lines_daylight_locus` definition. """ @@ -54,7 +56,7 @@ class TestPlotDaylightLocus: unit tests methods. """ - def test_plot_daylight_locus(self): + def test_plot_daylight_locus(self) -> None: """ Test :func:`colour.plotting.temperature.plot_daylight_locus` definition. @@ -84,7 +86,7 @@ class TestLinesPlanckianLocus: unit tests methods. """ - def test_lines_planckian_locus(self): + def test_lines_planckian_locus(self) -> None: """ Test :func:`colour.plotting.diagrams.lines_planckian_locus` definition. """ @@ -98,7 +100,7 @@ class TestPlotPlanckianLocus: unit tests methods. """ - def test_plot_planckian_locus(self): + def test_plot_planckian_locus(self) -> None: """ Test :func:`colour.plotting.temperature.plot_planckian_locus` definition. @@ -133,7 +135,7 @@ class TestPlotPlanckianLocusInChromaticityDiagram: plot_planckian_locus_in_chromaticity_diagram` definition unit tests methods. """ - def test_plot_planckian_locus_in_chromaticity_diagram(self): + def test_plot_planckian_locus_in_chromaticity_diagram(self) -> None: """ Test :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram` definition. @@ -182,7 +184,7 @@ class TestPlotPlanckianLocusInChromaticityDiagramCIE1931: methods. """ - def test_plot_planckian_locus_in_chromaticity_diagram_CIE1931(self): + def test_plot_planckian_locus_in_chromaticity_diagram_CIE1931(self) -> None: """ Test :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram_CIE1931` definition. @@ -203,7 +205,7 @@ class TestPlotPlanckianLocusInChromaticityDiagramCIE1960UCS: methods. """ - def test_plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(self): + def test_plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS(self) -> None: """ Test :func:`colour.plotting.temperature.\ plot_planckian_locus_in_chromaticity_diagram_CIE1960UCS` definition. diff --git a/colour/plotting/tests/test_volume.py b/colour/plotting/tests/test_volume.py index 87c7f5e21..6b0540456 100644 --- a/colour/plotting/tests/test_volume.py +++ b/colour/plotting/tests/test_volume.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.volume` module.""" +from __future__ import annotations + import numpy as np from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -29,7 +31,7 @@ class TestNadirGrid: methods. """ - def test_nadir_grid(self): + def test_nadir_grid(self) -> None: """Test :func:`colour.plotting.volume.nadir_grid` definition.""" quads, faces_colours, edges_colours = nadir_grid(segments=1) @@ -124,7 +126,7 @@ class TestRGBIdentityCube: tests methods. """ - def test_RGB_identity_cube(self): + def test_RGB_identity_cube(self) -> None: """Test :func:`colour.plotting.volume.RGB_identity_cube` definition.""" vertices, RGB = RGB_identity_cube(1, 1, 1) @@ -196,7 +198,7 @@ class TestPlotRGBColourspacesGamuts: definition unit tests methods. """ - def test_plot_RGB_colourspaces_gamuts(self): + def test_plot_RGB_colourspaces_gamuts(self) -> None: """ Test :func:`colour.plotting.volume.plot_RGB_colourspaces_gamuts` definition. @@ -219,7 +221,7 @@ class TestPlotRGBScatter: tests methods. """ - def test_plot_RGB_scatter(self): + def test_plot_RGB_scatter(self) -> None: """Test :func:`colour.plotting.volume.plot_RGB_scatter` definition.""" figure, axes = plot_RGB_scatter(np.random.random((128, 128, 3)), "ITU-R BT.709") diff --git a/colour/plotting/tm3018/components.py b/colour/plotting/tm3018/components.py index 6aad47a8b..af91aae3a 100644 --- a/colour/plotting/tm3018/components.py +++ b/colour/plotting/tm3018/components.py @@ -429,7 +429,7 @@ def plot_colour_vector_graphic( zorder=CONSTANTS_COLOUR_STYLE.zorder.midground_line, ) - def corner_label_and_text(label: str, text: str, ha: str, va: str): + def corner_label_and_text(label: str, text: str, ha: str, va: str) -> None: """Draw a label and text in given corner.""" x = -1.45 if ha == "left" else 1.45 diff --git a/colour/plotting/tm3018/tests/test_components.py b/colour/plotting/tm3018/tests/test_components.py index c97c8072b..da36225d6 100644 --- a/colour/plotting/tm3018/tests/test_components.py +++ b/colour/plotting/tm3018/tests/test_components.py @@ -50,7 +50,7 @@ class TestPlotSpectraANSIIESTM3018: plot_spectra_ANSIIESTM3018` definition unit tests methods. """ - def test_plot_spectra_ANSIIESTM3018(self): + def test_plot_spectra_ANSIIESTM3018(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_spectra_ANSIIESTM3018` definition. @@ -68,7 +68,7 @@ class TestPlotColourVectorGraphic: plot_colour_vector_graphic` definition unit tests methods. """ - def test_plot_colour_vector_graphic(self): + def test_plot_colour_vector_graphic(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_colour_vector_graphic` definition. @@ -86,7 +86,7 @@ class TestPlot16BinBars: definition unit tests methods. """ - def test_plot_16_bin_bars(self): + def test_plot_16_bin_bars(self) -> None: """ Test :func:`colour.plotting.tm3018.components.plot_16_bin_bars` definition. @@ -104,7 +104,7 @@ class TestPlotLocalChromaShifts: definition unit tests methods. """ - def test_plot_local_chroma_shifts(self): + def test_plot_local_chroma_shifts(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_local_chroma_shifts` definition. @@ -122,7 +122,7 @@ class TestPlotLocalHueShifts: definition unit tests methods. """ - def test_plot_local_hue_shifts(self): + def test_plot_local_hue_shifts(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_local_hue_shifts` definition. @@ -140,7 +140,7 @@ class TestPlotLocalColourFidelities: plot_local_colour_fidelities` definition unit tests methods. """ - def test_plot_local_colour_fidelities(self): + def test_plot_local_colour_fidelities(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_local_colour_fidelities` definition. @@ -158,7 +158,7 @@ class TestPlotColourFidelityIndexes: plot_colour_fidelity_indexes` definition unit tests methods. """ - def test_plot_colour_fidelity_indexes(self): + def test_plot_colour_fidelity_indexes(self) -> None: """ Test :func:`colour.plotting.tm3018.components.\ plot_colour_fidelity_indexes` definition. diff --git a/colour/plotting/tm3018/tests/test_report.py b/colour/plotting/tm3018/tests/test_report.py index 107845a6e..6b8a68d3c 100644 --- a/colour/plotting/tm3018/tests/test_report.py +++ b/colour/plotting/tm3018/tests/test_report.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.plotting.tm3018.report` module.""" +from __future__ import annotations + from matplotlib.axes import Axes from matplotlib.figure import Figure @@ -32,7 +34,7 @@ class TestPlotSingleSdColourRenditionReportFull: plot_single_sd_colour_rendition_report_full` definition unit tests methods. """ - def test_plot_single_sd_colour_rendition_report_full(self): + def test_plot_single_sd_colour_rendition_report_full(self) -> None: """ Test :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_full` definition. @@ -53,7 +55,7 @@ class TestPlotSingleSdColourRenditionReportIntermediate: methods. """ - def test_plot_single_sd_colour_rendition_report_intermediate(self): + def test_plot_single_sd_colour_rendition_report_intermediate(self) -> None: """ Test :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_intermediate` definition. @@ -73,7 +75,7 @@ class TestPlotSingleSdColourRenditionReportSimple: plot_single_sd_colour_rendition_report_simple` definition unit tests methods. """ - def test_plot_color_vector_graphic(self): + def test_plot_color_vector_graphic(self) -> None: """ Test :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report_simple` definition. @@ -93,7 +95,7 @@ class TestPlotSingleSdColourRenditionReport: plot_single_sd_colour_rendition_report` definition unit tests methods. """ - def test_plot_single_sd_colour_rendition_report(self): + def test_plot_single_sd_colour_rendition_report(self) -> None: """ Test :func:`colour.plotting.tm3018.report.\ plot_single_sd_colour_rendition_report` definition. diff --git a/colour/plotting/volume.py b/colour/plotting/volume.py index 253c0ed29..a199d3834 100644 --- a/colour/plotting/volume.py +++ b/colour/plotting/volume.py @@ -319,19 +319,21 @@ def RGB_identity_cube( height_segments: int = 16, depth_segments: int = 16, planes: ( - Literal[ - "-x", - "+x", - "-y", - "+y", - "-z", - "+z", - "xy", - "xz", - "yz", - "yx", - "zx", - "zy", + Sequence[ + Literal[ + "-x", + "+x", + "-y", + "+y", + "-z", + "+z", + "xy", + "xz", + "yz", + "yx", + "zx", + "zy", + ] ] | None ) = None, diff --git a/colour/quality/__init__.py b/colour/quality/__init__.py index 960c01880..ed72189f7 100644 --- a/colour/quality/__init__.py +++ b/colour/quality/__init__.py @@ -64,7 +64,7 @@ def colour_fidelity_index( sd_test: SpectralDistribution, - additional_data=False, + additional_data: bool = False, method: Literal["CIE 2017", "ANSI/IES TM-30-18"] | str = "CIE 2017", ) -> ( float diff --git a/colour/quality/tests/test_cfi2017.py b/colour/quality/tests/test_cfi2017.py index 187638990..08c50cacf 100644 --- a/colour/quality/tests/test_cfi2017.py +++ b/colour/quality/tests/test_cfi2017.py @@ -19,8 +19,10 @@ reshape_sd, sd_blackbody, ) +from colour.hints import cast from colour.quality.cfi2017 import ( CCT_reference_illuminant, + ColourRendering_Specification_CIE2017, colour_fidelity_index_CIE2017, sd_reference_illuminant, ) @@ -552,14 +554,17 @@ class TestColourFidelityIndexCIE2017: definition unit tests methods. """ - def test_colour_fidelity_index_CIE2017(self): + def test_colour_fidelity_index_CIE2017(self) -> None: """ Test :func:`colour.quality.CIE2017.colour_fidelity_index_CIE2017` definition. """ for sd in [SD_SAMPLE_5NM, SD_SAMPLE_1NM]: - specification = colour_fidelity_index_CIE2017(sd, additional_data=True) + specification = cast( + ColourRendering_Specification_CIE2017, + colour_fidelity_index_CIE2017(sd, additional_data=True), + ) np.testing.assert_allclose(specification.R_f, 81.6, atol=0.1) np.testing.assert_allclose( specification.R_s, @@ -667,8 +672,9 @@ def test_colour_fidelity_index_CIE2017(self): atol=0.1, ) - specification = colour_fidelity_index_CIE2017( - SDS_ILLUMINANTS["FL1"], additional_data=True + specification = cast( + ColourRendering_Specification_CIE2017, + colour_fidelity_index_CIE2017(SDS_ILLUMINANTS["FL1"], additional_data=True), ) np.testing.assert_allclose(specification.R_f, 80.6, atol=0.1) np.testing.assert_allclose( @@ -777,8 +783,9 @@ def test_colour_fidelity_index_CIE2017(self): atol=0.1, ) - specification = colour_fidelity_index_CIE2017( - SDS_ILLUMINANTS["FL2"], additional_data=True + specification = cast( + ColourRendering_Specification_CIE2017, + colour_fidelity_index_CIE2017(SDS_ILLUMINANTS["FL2"], additional_data=True), ) np.testing.assert_allclose(specification.R_f, 70.1, atol=0.1) np.testing.assert_allclose( @@ -887,7 +894,7 @@ def test_colour_fidelity_index_CIE2017(self): atol=0.1, ) - def test_raise_exception_colour_fidelity_index_CFI2017(self): + def test_raise_exception_colour_fidelity_index_CFI2017(self) -> None: """ Test :func:`colour.quality.CIE2017.colour_fidelity_index_CFI2017` definition raised exception. @@ -906,7 +913,7 @@ class TestCctReferenceIlluminant: definition unit tests methods. """ - def test_CCT_reference_illuminant(self): + def test_CCT_reference_illuminant(self) -> None: """ Test :func:`colour.quality.CIE2017.CCT_reference_illuminant` definition. @@ -924,7 +931,7 @@ class TestSdReferenceIlluminant: definition unit tests methods. """ - def test_sd_reference_illuminant(self): + def test_sd_reference_illuminant(self) -> None: """ Test :func:`colour.quality.CIE2017.sd_reference_illuminant` definition. diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index 79c3ef84e..fede00973 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -1,9 +1,12 @@ """Define the unit tests for the :mod:`colour.quality.cqs` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import SDS_ILLUMINANTS, SDS_LIGHT_SOURCES from colour.constants import TOLERANCE_ABSOLUTE_TESTS +from colour.hints import cast from colour.quality import ( ColourRendering_Specification_CQS, colour_quality_scale, @@ -28,58 +31,75 @@ class TestColourQualityScale: tests methods. """ - def test_colour_quality_scale(self): + def test_colour_quality_scale(self) -> None: """Test :func:`colour.quality.cqs.colour_quality_scale` definition.""" np.testing.assert_allclose( - colour_quality_scale(SDS_ILLUMINANTS["FL1"]), + cast(float, colour_quality_scale(SDS_ILLUMINANTS["FL1"])), 74.982585798279914, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale(SDS_ILLUMINANTS["FL1"], method="NIST CQS 7.4"), + cast( + float, + colour_quality_scale(SDS_ILLUMINANTS["FL1"], method="NIST CQS 7.4"), + ), 75.377089740493361, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale(SDS_ILLUMINANTS["FL2"]), + cast(float, colour_quality_scale(SDS_ILLUMINANTS["FL2"])), 64.111822015662852, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale(SDS_ILLUMINANTS["FL2"], method="NIST CQS 7.4"), + cast( + float, + colour_quality_scale(SDS_ILLUMINANTS["FL2"], method="NIST CQS 7.4"), + ), 64.774586908581369, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale(SDS_LIGHT_SOURCES["Neodimium Incandescent"]), + cast( + float, colour_quality_scale(SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + ), 89.737456186836681, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale( - SDS_LIGHT_SOURCES["Neodimium Incandescent"], - method="NIST CQS 7.4", + cast( + float, + colour_quality_scale( + SDS_LIGHT_SOURCES["Neodimium Incandescent"], + method="NIST CQS 7.4", + ), ), 87.700300087538821, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale(SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"]), + cast( + float, + colour_quality_scale(SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"]), + ), 84.934928463428903, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_quality_scale( - SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"], - method="NIST CQS 7.4", + cast( + float, + colour_quality_scale( + SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"], + method="NIST CQS 7.4", + ), ), 83.255457439460713, atol=TOLERANCE_ABSOLUTE_TESTS, @@ -200,195 +220,198 @@ def test_colour_quality_scale(self): ), }, colorimetry_data=( - [ + ( DataColorimetry_VS( name="VS1", XYZ=np.array([0.13183826, 0.09887241, 0.22510560]), Lab=np.array([37.63929023, 27.59987425, -26.20530751]), - C=38.058786112947161, + C=np.array([38.058786112947161]), ), DataColorimetry_VS( name="VS2", XYZ=np.array([0.13061818, 0.10336027, 0.30741529]), Lab=np.array([38.43888224, 23.35252921, -37.81858787]), - C=44.447566961689617, + C=np.array([44.447566961689617]), ), DataColorimetry_VS( name="VS3", XYZ=np.array([0.10089287, 0.09200351, 0.32265558]), Lab=np.array([36.36721207, 11.00392324, -43.53144829]), - C=44.900705083686788, + C=np.array([44.900705083686788]), ), DataColorimetry_VS( name="VS4", XYZ=np.array([0.13339390, 0.15696027, 0.38421714]), Lab=np.array([46.57313273, -9.89411460, -33.95550516]), - C=35.367638235231176, + C=np.array([35.367638235231176]), ), DataColorimetry_VS( name="VS5", XYZ=np.array([0.18662999, 0.24708620, 0.40043676]), Lab=np.array([56.79040832, -23.15964295, -18.30798276]), - C=29.522047597875542, + C=np.array([29.522047597875542]), ), DataColorimetry_VS( name="VS6", XYZ=np.array([0.15843362, 0.24157338, 0.26933196]), Lab=np.array([56.24498076, -36.24891195, -1.43946286]), - C=36.277481597875926, + C=np.array([36.277481597875926]), ), DataColorimetry_VS( name="VS7", XYZ=np.array([0.14991085, 0.24929718, 0.13823961]), Lab=np.array([57.00687838, -44.55799945, 24.99093151]), - C=51.087786926248803, + C=np.array([51.087786926248803]), ), DataColorimetry_VS( name="VS8", XYZ=np.array([0.26141761, 0.36817692, 0.11429088]), Lab=np.array([67.14003019, -33.22377274, 48.66064659]), - C=58.920943658800866, + C=np.array([58.920943658800866]), ), DataColorimetry_VS( name="VS9", XYZ=np.array([0.42410903, 0.52851922, 0.11439812]), Lab=np.array([77.78749106, -22.21024952, 66.98873308]), - C=70.5746806093467, + C=np.array([70.5746806093467]), ), DataColorimetry_VS( name="VS10", XYZ=np.array([0.55367933, 0.62018757, 0.09672217]), Lab=np.array([82.92339395, -8.84301088, 80.99721844]), - C=81.478513954529475, + C=np.array([81.478513954529475]), ), DataColorimetry_VS( name="VS11", XYZ=np.array([0.39755898, 0.39521027, 0.05739407]), Lab=np.array([69.12701310, 6.97471851, 71.51095397]), - C=71.850283480415115, + C=np.array([71.850283480415115]), ), DataColorimetry_VS( name="VS12", XYZ=np.array([0.43757530, 0.38969458, 0.08630191]), Lab=np.array([68.72913590, 20.83589132, 59.86354051]), - C=63.385943630694335, + C=np.array([63.385943630694335]), ), DataColorimetry_VS( name="VS13", XYZ=np.array([0.34657727, 0.27547744, 0.08900676]), Lab=np.array([59.47793328, 31.84647528, 43.02166812]), - C=53.526273138196274, + C=np.array([53.526273138196274]), ), DataColorimetry_VS( name="VS14", XYZ=np.array([0.14271714, 0.09107438, 0.04949461]), Lab=np.array([36.19033157, 40.77665898, 18.34813575]), - C=44.714539058373845, + C=np.array([44.714539058373845]), ), DataColorimetry_VS( name="VS15", XYZ=np.array([0.13593948, 0.09214669, 0.11591665]), Lab=np.array([36.39436371, 35.62220213, -4.79596673]), - C=35.94360278722214, + C=np.array([35.94360278722214]), ), - ], - [ + ), + ( DataColorimetry_VS( name="VS1", XYZ=np.array([0.15205130, 0.10842697, 0.21629425]), Lab=np.array([39.31425803, 32.98285941, -21.74818073]), - C=39.507624328927392, + C=np.array([39.507624328927392]), ), DataColorimetry_VS( name="VS2", XYZ=np.array([0.13187179, 0.10619377, 0.29945481]), Lab=np.array([38.93186373, 22.05038057, -35.82206456]), - C=42.064707208617435, + C=np.array([42.064707208617435]), ), DataColorimetry_VS( name="VS3", XYZ=np.array([0.10123263, 0.09853741, 0.32956604]), Lab=np.array([37.57864252, 6.04766746, -42.39139508]), - C=42.82061020516246, + C=np.array([42.82061020516246]), ), DataColorimetry_VS( name="VS4", XYZ=np.array([0.13144454, 0.16803553, 0.39315864]), Lab=np.array([48.01155296, -17.36604069, -32.56734417]), - C=36.908146466038922, + C=np.array([36.908146466038922]), ), DataColorimetry_VS( name="VS5", XYZ=np.array([0.18145723, 0.25845953, 0.41319313]), Lab=np.array([57.89053983, -30.61152779, -17.92233237]), - C=35.472181086008781, + C=np.array([35.472181086008781]), ), DataColorimetry_VS( name="VS6", XYZ=np.array([0.15184114, 0.25076481, 0.28160235]), Lab=np.array([57.14986362, -44.01984887, -1.76443512]), - C=44.055196354398468, + C=np.array([44.055196354398468]), ), DataColorimetry_VS( name="VS7", XYZ=np.array([0.13956282, 0.25328776, 0.14470413]), Lab=np.array([57.39436644, -52.59240053, 24.11037488]), - C=57.8556027598421, + C=np.array([57.8556027598421]), ), DataColorimetry_VS( name="VS8", XYZ=np.array([0.24672357, 0.36210726, 0.11976641]), Lab=np.array([66.68062145, -37.45331629, 46.38001890]), - C=59.614235332660144, + C=np.array([59.614235332660144]), ), DataColorimetry_VS( name="VS9", XYZ=np.array([0.40820163, 0.50861708, 0.11894288]), Lab=np.array([76.59516365, -21.90847578, 63.69499819]), - C=67.357509638238682, + C=np.array([67.357509638238682]), ), DataColorimetry_VS( name="VS10", XYZ=np.array([0.56036726, 0.60569219, 0.10169199]), Lab=np.array([82.14661230, -3.82032735, 78.14954550]), - C=78.24286780890229, + C=np.array([78.24286780890229]), ), DataColorimetry_VS( name="VS11", XYZ=np.array([0.40540651, 0.38003446, 0.05753983]), Lab=np.array([68.02315451, 14.17690044, 69.54409225]), - C=70.974398718322206, + C=np.array([70.974398718322206]), ), DataColorimetry_VS( name="VS12", XYZ=np.array([0.45407809, 0.37920609, 0.08621297]), Lab=np.array([67.96206127, 28.93563884, 58.57062794]), - C=65.328321974859804, + C=np.array([65.328321974859804]), ), DataColorimetry_VS( name="VS13", XYZ=np.array([0.37207030, 0.27413935, 0.08882217]), Lab=np.array([59.35552778, 40.92542311, 42.87088737]), - C=59.268906188196901, + C=np.array([59.268906188196901]), ), DataColorimetry_VS( name="VS14", XYZ=np.array([0.19307398, 0.11049957, 0.04883445]), Lab=np.array([39.66448332, 53.96576475, 24.65796798]), - C=59.332277465127156, + C=np.array([59.332277465127156]), ), DataColorimetry_VS( name="VS15", XYZ=np.array([0.17306027, 0.10700056, 0.11280793]), Lab=np.array([39.07062485, 45.99788526, 0.67641984]), - C=46.002858517472262, + C=np.array([46.002858517472262]), ), - ], + ), ), ) - specification_t = colour_quality_scale( - SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 7.4" + specification_t = cast( + ColourRendering_Specification_CQS, + colour_quality_scale( + SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 7.4" + ), ) np.testing.assert_allclose( @@ -512,195 +535,198 @@ def test_colour_quality_scale(self): ), }, colorimetry_data=( - [ + ( DataColorimetry_VS( name="VS1", XYZ=np.array([0.14271715, 0.09107438, 0.04949462]), Lab=np.array([36.19033159, 40.77666015, 18.34813122]), - C=44.714538268056295, + C=np.array([44.714538268056295]), ), DataColorimetry_VS( name="VS2", XYZ=np.array([0.34657727, 0.27547744, 0.08900676]), Lab=np.array([59.47793328, 31.84647553, 43.02166698]), - C=53.526272364542265, + C=np.array([53.526272364542265]), ), DataColorimetry_VS( name="VS3", XYZ=np.array([0.41050103, 0.38688447, 0.06613576]), Lab=np.array([68.52498199, 13.58373774, 66.83110597]), - C=68.197614738277153, + C=np.array([68.197614738277153]), ), DataColorimetry_VS( name="VS4", XYZ=np.array([0.45427132, 0.50401485, 0.08193287]), Lab=np.array([76.31503360, -7.01311937, 74.42292542]), - C=74.752629859451574, + C=np.array([74.752629859451574]), ), DataColorimetry_VS( name="VS5", XYZ=np.array([0.42410903, 0.52851922, 0.11439811]), Lab=np.array([77.78749106, -22.21024992, 66.98873490]), - C=70.574682470722237, + C=np.array([70.574682470722237]), ), DataColorimetry_VS( name="VS6", XYZ=np.array([0.26141761, 0.36817692, 0.11429088]), Lab=np.array([67.14003019, -33.22377278, 48.66064673]), - C=58.920943801328043, + C=np.array([58.920943801328043]), ), DataColorimetry_VS( name="VS7", XYZ=np.array([0.14991085, 0.24929718, 0.13823960]), Lab=np.array([57.00687837, -44.55800078, 24.99093412]), - C=51.087789364109447, + C=np.array([51.087789364109447]), ), DataColorimetry_VS( name="VS8", XYZ=np.array([0.15843361, 0.24157338, 0.26933192]), Lab=np.array([56.24498073, -36.24891645, -1.43945699]), - C=36.277485856650493, + C=np.array([36.277485856650493]), ), DataColorimetry_VS( name="VS9", XYZ=np.array([0.18662998, 0.24708620, 0.40043672]), Lab=np.array([56.79040828, -23.15964795, -18.30797717]), - C=29.522048055967336, + C=np.array([29.522048055967336]), ), DataColorimetry_VS( name="VS10", XYZ=np.array([0.13339389, 0.15696027, 0.38421709]), Lab=np.array([46.57313267, -9.89412218, -33.95549821]), - C=35.367633681665495, + C=np.array([35.367633681665495]), ), DataColorimetry_VS( name="VS11", XYZ=np.array([0.09900743, 0.09954465, 0.32039098]), Lab=np.array([37.76058147, 3.51413565, -40.81527590]), - C=40.966277550944625, + C=np.array([40.966277550944625]), ), DataColorimetry_VS( name="VS12", XYZ=np.array([0.11576390, 0.09613722, 0.31928926]), Lab=np.array([37.14003664, 18.77460935, -41.73197608]), - C=45.760723157938472, + C=np.array([45.760723157938472]), ), DataColorimetry_VS( name="VS13", XYZ=np.array([0.20975356, 0.16847879, 0.37267453]), Lab=np.array([48.06778877, 25.97523691, -29.94366223]), - C=39.640078711661452, + C=np.array([39.640078711661452]), ), DataColorimetry_VS( name="VS14", XYZ=np.array([0.32298108, 0.24163045, 0.36212750]), Lab=np.array([56.25066973, 37.45976513, -14.49801776]), - C=40.167480906459893, + C=np.array([40.167480906459893]), ), DataColorimetry_VS( name="VS15", XYZ=np.array([0.22039693, 0.15371392, 0.17553541]), Lab=np.array([46.13873255, 39.31630210, -2.10769974]), - C=39.372757193029329, + C=np.array([39.372757193029329]), ), - ], - [ + ), + ( DataColorimetry_VS( name="VS1", XYZ=np.array([0.19307399, 0.11049957, 0.04883449]), Lab=np.array([39.66448335, 53.96576813, 24.65795205]), - C=59.332273930950407, + C=np.array([59.332273930950407]), ), DataColorimetry_VS( name="VS2", XYZ=np.array([0.37207030, 0.27413935, 0.08882218]), Lab=np.array([59.35552779, 40.92542394, 42.87088336]), - C=59.268903858924929, + C=np.array([59.268903858924929]), ), DataColorimetry_VS( name="VS3", XYZ=np.array([0.42080177, 0.37272049, 0.06618662]), Lab=np.array([67.48063529, 21.22017785, 65.01028998]), - C=68.385917784001094, + C=np.array([68.385917784001094]), ), DataColorimetry_VS( name="VS4", XYZ=np.array([0.46201298, 0.49481812, 0.08588402]), Lab=np.array([75.75009449, -2.36998858, 72.10803500]), - C=72.146971918467017, + C=np.array([72.146971918467017]), ), DataColorimetry_VS( name="VS5", XYZ=np.array([0.40820163, 0.50861708, 0.11894286]), Lab=np.array([76.59516364, -21.90847694, 63.69500310]), - C=67.35751466170575, + C=np.array([67.35751466170575]), ), DataColorimetry_VS( name="VS6", XYZ=np.array([0.24672357, 0.36210726, 0.11976641]), Lab=np.array([66.68062144, -37.45331655, 46.38001966]), - C=59.614236088535129, + C=np.array([59.614236088535129]), ), DataColorimetry_VS( name="VS7", XYZ=np.array([0.13956281, 0.25328776, 0.14470409]), Lab=np.array([57.39436642, -52.59240564, 24.11038403]), - C=57.855611215555271, + C=np.array([57.855611215555271]), ), DataColorimetry_VS( name="VS8", XYZ=np.array([0.15184111, 0.25076481, 0.28160222]), Lab=np.array([57.14986354, -44.01986548, -1.76441495]), - C=44.055212144295837, + C=np.array([44.055212144295837]), ), DataColorimetry_VS( name="VS9", XYZ=np.array([0.18145720, 0.25845953, 0.41319296]), Lab=np.array([57.89053974, -30.61154597, -17.92231311]), - C=35.472187042106164, + C=np.array([35.472187042106164]), ), DataColorimetry_VS( name="VS10", XYZ=np.array([0.13144449, 0.16803553, 0.39315843]), Lab=np.array([48.01155280, -17.36606803, -32.56732004]), - C=36.908138035180549, + C=np.array([36.908138035180549]), ), DataColorimetry_VS( name="VS11", XYZ=np.array([0.09725029, 0.10655822, 0.32331756]), Lab=np.array([38.99463289, -3.20501320, -39.09286753]), - C=39.224028364277721, + C=np.array([39.224028364277721]), ), DataColorimetry_VS( name="VS12", XYZ=np.array([0.11497971, 0.09965866, 0.31509326]), Lab=np.array([37.78109906, 15.45054732, -40.03995920]), - C=42.917569190579727, + C=np.array([42.917569190579727]), ), DataColorimetry_VS( name="VS13", XYZ=np.array([0.23125767, 0.17972670, 0.36038776]), Lab=np.array([49.46294201, 29.95248104, -25.97793559]), - C=39.648508903390763, + C=np.array([39.648508903390763]), ), DataColorimetry_VS( name="VS14", XYZ=np.array([0.35887695, 0.25609884, 0.35518732]), Lab=np.array([57.66488716, 43.83765559, -11.16556087]), - C=45.237261162848789, + C=np.array([45.237261162848789]), ), DataColorimetry_VS( name="VS15", XYZ=np.array([0.26552457, 0.17192965, 0.17300682]), Lab=np.array([48.50225789, 48.80528996, 2.49443403]), - C=48.868993532230895, + C=np.array([48.868993532230895]), ), - ], + ), ), ) - specification_t = colour_quality_scale( - SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 9.0" + specification_t = cast( + ColourRendering_Specification_CQS, + colour_quality_scale( + SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 9.0" + ), ) np.testing.assert_allclose( diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index 695962e84..9349ee4ce 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -6,6 +6,7 @@ from colour.colorimetry import SDS_ILLUMINANTS, SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS +from colour.hints import cast from colour.quality import ( ColourRendering_Specification_CRI, colour_rendering_index, @@ -114,29 +115,29 @@ class TestColourRenderingIndex: definition unit tests methods. """ - def test_colour_rendering_index(self): + def test_colour_rendering_index(self) -> None: """Test :func:`colour.quality.cri.colour_rendering_index` definition.""" np.testing.assert_allclose( - colour_rendering_index(SDS_ILLUMINANTS["FL1"]), + cast(float, colour_rendering_index(SDS_ILLUMINANTS["FL1"])), 75.852827992149358, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_rendering_index(SDS_ILLUMINANTS["FL2"]), + cast(float, colour_rendering_index(SDS_ILLUMINANTS["FL2"])), 64.233724121664778, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_rendering_index(SDS_ILLUMINANTS["A"]), + cast(float, colour_rendering_index(SDS_ILLUMINANTS["A"])), 99.996230290506887, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - colour_rendering_index(SpectralDistribution(DATA_SAMPLE)), + cast(float, colour_rendering_index(SpectralDistribution(DATA_SAMPLE))), 70.815265381660197, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -161,7 +162,7 @@ def test_colour_rendering_index(self): 14: DataColourQualityScale_TCS(name="TCS14", Q_a=94.884867470552663), }, colorimetry_data=( - [ + ( DataColorimetry_TCS( name="TCS01", XYZ=np.array([31.19561134, 29.74560797, 23.44190201]), @@ -246,8 +247,8 @@ def test_colour_rendering_index(self): uv=np.array([0.18328188, 0.35214117]), UVW=np.array([-6.11563143, 19.91896684, 40.34566797]), ), - ], - [ + ), + ( DataColorimetry_TCS( name="TCS01", XYZ=np.array([33.04774537, 29.80902109, 24.23929188]), @@ -332,12 +333,13 @@ def test_colour_rendering_index(self): uv=np.array([0.18597686, 0.34955284]), UVW=np.array([-6.34991066, 18.99712303, 39.76962229]), ), - ], + ), ), ) - specification_t = colour_rendering_index( - SDS_ILLUMINANTS["FL1"], additional_data=True + specification_t = cast( + ColourRendering_Specification_CRI, + colour_rendering_index(SDS_ILLUMINANTS["FL1"], additional_data=True), ) np.testing.assert_allclose( diff --git a/colour/quality/tests/test_ssi.py b/colour/quality/tests/test_ssi.py index 415a0ad12..051bbae5e 100644 --- a/colour/quality/tests/test_ssi.py +++ b/colour/quality/tests/test_ssi.py @@ -559,7 +559,7 @@ class TestSpectralSimilarityIndex: definition unit tests methods. """ - def test_spectral_similarity_index(self): + def test_spectral_similarity_index(self) -> None: """Test :func:`colour.quality.ssi.spectral_similarity_index` definition.""" assert ( @@ -573,7 +573,7 @@ def test_spectral_similarity_index(self): == 72.0 ) - def test_spectral_similarity_rounding(self): + def test_spectral_similarity_rounding(self) -> None: """ Test :func:`colour.quality.ssi.spectral_similarity_index` for producing continuous values. diff --git a/colour/quality/tests/test_tm3018.py b/colour/quality/tests/test_tm3018.py index 6d4661135..b06249d97 100644 --- a/colour/quality/tests/test_tm3018.py +++ b/colour/quality/tests/test_tm3018.py @@ -8,10 +8,14 @@ http://media.ies.org/docs/errata/TM-30-18_tools_etc.zip. """ +from __future__ import annotations + import numpy as np from colour.colorimetry import SDS_ILLUMINANTS +from colour.hints import cast from colour.quality.tm3018 import ( + ColourQuality_Specification_ANSIIESTM3018, averages_area, colour_fidelity_index_ANSIIESTM3018, ) @@ -36,14 +40,17 @@ class TestColourFidelityIndexANSIIESTM3018: definition unit tests methods. """ - def test_colour_fidelity_index_ANSIIESTM3018(self): + def test_colour_fidelity_index_ANSIIESTM3018(self) -> None: """ Test :func:`colour.quality.tm3018.colour_fidelity_index_ANSIIESTM3018` definition. """ - specification = colour_fidelity_index_ANSIIESTM3018( - SDS_ILLUMINANTS["FL2"], additional_data=True + specification = cast( + ColourQuality_Specification_ANSIIESTM3018, + colour_fidelity_index_ANSIIESTM3018( + SDS_ILLUMINANTS["FL2"], additional_data=True + ), ) np.testing.assert_allclose(specification.R_f, 70, atol=2e-1) @@ -197,7 +204,7 @@ class TestAveragesArea: methods. """ - def test_averages_area(self): + def test_averages_area(self) -> None: """Test :func:`colour.quality.tm3018.averages_area` definition.""" # Simple 3 * sqrt(2) by sqrt(2) rectangle. diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 01cfbed36..3d8571278 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -790,7 +790,7 @@ def interpolator(self) -> RegularGridInterpolator: return self._interpolator - def _create_interpolator(self): + def _create_interpolator(self) -> None: """ Create a :class:`scipy.interpolate.RegularGridInterpolator` class instance for read or generated coefficients. @@ -810,7 +810,7 @@ def generate( illuminant: SpectralDistribution | None = None, size: int = 64, print_callable: Callable = print, - ): + ) -> None: """ Generate the lookup table data for given *RGB* colourspace, colour matching functions, illuminant and given size. diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index aa6bddd94..9416270b6 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -270,7 +270,7 @@ def RGB_to_msds_camera_sensitivities_Jiang2013( RGB: ArrayLike, illuminant: SpectralDistribution, reflectances: MultiSpectralDistributions, - basis_functions=BASIS_FUNCTIONS_DYER2017, + basis_functions: ArrayLike = BASIS_FUNCTIONS_DYER2017, shape: SpectralShape | None = None, ) -> MultiSpectralDistributions: """ @@ -369,6 +369,7 @@ def RGB_to_msds_camera_sensitivities_Jiang2013( """ R, G, B = tsplit(np.reshape(RGB, [-1, 3])) + basis_functions = as_float_array(basis_functions) shape = optional(shape, illuminant.shape) R_w, G_w, B_w = tsplit(np.moveaxis(basis_functions, 0, 1)) diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index bbe76fc6a..c5f58cc39 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -181,7 +181,7 @@ def shape(self) -> SpectralShape | None: Returns ------- - :py:data:`None` or :class:`colour.SpectralShape` + :class:`colour.SpectralShape` or :py:data:`None` Shape used by the *Otsu et al. (2018)* dataset. """ @@ -195,7 +195,7 @@ def basis_functions(self) -> NDArrayFloat | None: Returns ------- - :py:data:`None` or :class:`numpy.ndarray` + :class:`numpy.ndarray` or :py:data:`None` Basis functions of the *Otsu et al. (2018)* dataset. """ @@ -208,7 +208,7 @@ def means(self) -> NDArrayFloat | None: Returns ------- - :py:data:`None` or :class:`numpy.ndarray` + :class:`numpy.ndarray` or :py:data:`None` Means of the *Otsu et al. (2018)* dataset. """ @@ -222,7 +222,7 @@ def selector_array(self) -> NDArrayFloat | None: Returns ------- - :py:data:`None` or :class:`numpy.ndarray` + :class:`numpy.ndarray` or :py:data:`None` Selector array of the *Otsu et al. (2018)* dataset. """ @@ -691,7 +691,7 @@ def reflectances(self) -> NDArrayFloat | None: return self._reflectances @reflectances.setter - def reflectances(self, value: ArrayLike | None): + def reflectances(self, value: ArrayLike | None) -> None: """Setter for the **self.reflectances** property.""" if value is not None: @@ -1006,7 +1006,7 @@ def __init__( self, parent: Self | None = None, children: list | None = None, - data: Self | None = None, + data: Data_Otsu2018 | None = None, ) -> None: super().__init__(parent=parent, children=children, data=data) @@ -1054,7 +1054,7 @@ def row(self) -> Tuple[float, float, Self, Self]: else: raise ValueError('The "partition axis" is undefined!') - def split(self, children: Sequence[Self], axis: PartitionAxis): + def split(self, children: Sequence[Self], axis: PartitionAxis) -> None: """ Convert the leaf node into an inner node using given children and partition axis. @@ -1372,7 +1372,7 @@ def optimise( iterations: int = 8, minimum_cluster_size: int | None = None, print_callable: Callable = print, - ): + ) -> None: """ Optimise the tree by repeatedly performing optimal partitioning of the nodes, creating a tree that minimises the total reconstruction error. diff --git a/colour/recovery/tests/test__init__.py b/colour/recovery/tests/test__init__.py index f0ac2d95e..e2d27e1cf 100644 --- a/colour/recovery/tests/test__init__.py +++ b/colour/recovery/tests/test__init__.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import ( @@ -32,7 +34,7 @@ class TestXYZ_to_sd: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._cmfs = reshape_msds( @@ -42,7 +44,7 @@ def setup_method(self): self._sd_D65 = reshape_sd(SDS_ILLUMINANTS["D65"], self._cmfs.shape) - def test_domain_range_scale_XYZ_to_sd(self): + def test_domain_range_scale_XYZ_to_sd(self) -> None: """ Test :func:`colour.recovery.XYZ_to_sd` definition domain and range scale support. diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index 6406ee478..105b19585 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.jakob2019` module.""" +from __future__ import annotations + import os import shutil import tempfile @@ -11,6 +13,7 @@ from colour.colorimetry import handle_spectral_arguments, sd_to_XYZ from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.difference import JND_CIE1976, delta_E_CIE1976 +from colour.hints import Type from colour.models import ( RGB_COLOURSPACE_sRGB, RGB_to_XYZ, @@ -47,7 +50,7 @@ class TestErrorFunction: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_JAKOB2019 @@ -57,7 +60,7 @@ def setup_method(self): self._Lab_e = np.array([72, -20, 61]) - def test_intermediates(self): + def test_intermediates(self) -> None: """ Test intermediate results of :func:`colour.recovery.jakob2019.error_function` with @@ -81,7 +84,7 @@ def test_intermediates(self): ] for coefficients in coefficient_list: - error, _derror, R, XYZ, Lab = error_function( + error, _derror, R, XYZ, Lab = error_function( # pyright: ignore coefficients, self._Lab_e, self._cmfs, @@ -104,7 +107,7 @@ def test_intermediates(self): assert abs(error_reference - error) < JND_CIE1976 / 100 assert delta_E_CIE1976(Lab, sd_Lab) < JND_CIE1976 / 100 - def test_derivatives(self): + def test_derivatives(self) -> None: """ Test the gradients computed using closed-form expressions of the derivatives with finite difference approximations. @@ -122,7 +125,7 @@ def test_derivatives(self): coefficients = ones(3) coefficients[coefficient_i] = sample - error, derror = error_function( + error, derror = error_function( # pyright: ignore coefficients, self._Lab_e, self._cmfs, self._sd_D65 ) @@ -145,13 +148,13 @@ class TestXYZ_to_sd_Jakob2019: unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_JAKOB2019 self._cmfs, self._sd_D65 = handle_spectral_arguments(shape_default=self._shape) - def test_XYZ_to_sd_Jakob2019(self): + def test_XYZ_to_sd_Jakob2019(self) -> None: """Test :func:`colour.recovery.jakob2019.XYZ_to_sd_Jakob2019` definition.""" # Tests the round-trip with values of a colour checker. @@ -165,7 +168,7 @@ def test_XYZ_to_sd_Jakob2019(self): if error > JND_CIE1976 / 100: # pragma: no cover pytest.fail(f"Delta E for '{name}' is {error}!") - def test_domain_range_scale_XYZ_to_sd_Jakob2019(self): + def test_domain_range_scale_XYZ_to_sd_Jakob2019(self) -> None: """ Test :func:`colour.recovery.jakob2019.XYZ_to_sd_Jakob2019` definition domain and range scale support. @@ -173,7 +176,7 @@ def test_domain_range_scale_XYZ_to_sd_Jakob2019(self): XYZ_i = np.array([0.20654008, 0.12197225, 0.05136952]) XYZ_o = sd_to_XYZ( - XYZ_to_sd_Jakob2019(XYZ_i, self._cmfs, self._sd_D65), + XYZ_to_sd_Jakob2019(XYZ_i, self._cmfs, self._sd_D65, additional_data=False), # pyright: ignore self._cmfs, self._sd_D65, ) @@ -181,9 +184,14 @@ def test_domain_range_scale_XYZ_to_sd_Jakob2019(self): d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_allclose( + np.testing.assert_allclose( # pyright: ignore sd_to_XYZ( - XYZ_to_sd_Jakob2019(XYZ_i * factor_a, self._cmfs, self._sd_D65), + XYZ_to_sd_Jakob2019( + XYZ_i * factor_a, + self._cmfs, + self._sd_D65, + additional_data=False, + ), # pyright: ignore self._cmfs, self._sd_D65, ), @@ -199,7 +207,7 @@ class TestLUT3D_Jakob2019: """ @classmethod - def generate_LUT(cls): + def generate_LUT(cls: Type[TestLUT3D_Jakob2019]) -> LUT3D_Jakob2019: """ Generate the *LUT* used for the unit tests. @@ -223,7 +231,7 @@ def generate_LUT(cls): return cls._LUT - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -236,7 +244,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(LUT3D_Jakob2019) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -251,12 +259,12 @@ def test_required_methods(self): for method in required_methods: assert method in dir(LUT3D_Jakob2019) - def test_size(self): + def test_size(self) -> None: """Test :attr:`colour.recovery.jakob2019.LUT3D_Jakob2019.size` property.""" assert TestLUT3D_Jakob2019.generate_LUT().size == 5 - def test_lightness_scale(self): + def test_lightness_scale(self) -> None: """ Test :attr:`colour.recovery.jakob2019.LUT3D_Jakob2019.lightness_scale` property. @@ -268,7 +276,7 @@ def test_lightness_scale(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_coefficients(self): + def test_coefficients(self) -> None: """ Test :attr:`colour.recovery.jakob2019.LUT3D_Jakob2019.coefficients` property. @@ -276,7 +284,7 @@ def test_coefficients(self): assert TestLUT3D_Jakob2019.generate_LUT().coefficients.shape == (3, 5, 5, 5, 3) - def test_LUT3D_Jakob2019(self): + def test_LUT3D_Jakob2019(self) -> None: """ Test the entirety of the :class:`colour.recovery.jakob2019.LUT3D_Jakob2019`class. @@ -327,7 +335,7 @@ def test_LUT3D_Jakob2019(self): f"{self._RGB_colourspace.name} is {error}!" ) - def test_raise_exception_RGB_to_coefficients(self): + def test_raise_exception_RGB_to_coefficients(self) -> None: """ Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.\ RGB_to_coefficients` method raised exception. @@ -337,7 +345,7 @@ def test_raise_exception_RGB_to_coefficients(self): pytest.raises(RuntimeError, LUT.RGB_to_coefficients, np.array([1, 2, 3, 4])) - def test_raise_exception_read(self): + def test_raise_exception_read(self) -> None: """ Test :func:`colour.recovery.jakob2019.LUT3D_Jakob2019.read` method raised exception. diff --git a/colour/recovery/tests/test_jiang2013.py b/colour/recovery/tests/test_jiang2013.py index c52a9606d..d08759c5a 100644 --- a/colour/recovery/tests/test_jiang2013.py +++ b/colour/recovery/tests/test_jiang2013.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.jiang2013` module.""" +from __future__ import annotations + import platform import numpy as np @@ -50,7 +52,7 @@ class TestPCA_Jiang2013: tests methods. """ - def test_PCA_Jiang2013(self): + def test_PCA_Jiang2013(self) -> None: """Test :func:`colour.recovery.jiang2013.PCA_Jiang2013` definition.""" if platform.system() in ("Windows", "Microsoft", "Linux"): @@ -61,7 +63,11 @@ def test_PCA_Jiang2013(self): camera: msds.copy().align(shape) for camera, msds in MSDS_CAMERA_SENSITIVITIES.items() } - w, v = PCA_Jiang2013(camera_sensitivities, 3, True) + w, v = PCA_Jiang2013( # pyright: ignore + camera_sensitivities, + 3, + additional_data=True, + ) np.testing.assert_allclose( np.abs(np.array(w)), @@ -218,12 +224,12 @@ class TestRGB_to_sd_camera_sensitivity_Jiang2013(FixtureJiang2013): definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" FixtureJiang2013.__init__(self) - def test_RGB_to_sd_camera_sensitivity_Jiang2013(self): + def test_RGB_to_sd_camera_sensitivity_Jiang2013(self) -> None: """ Test :func:`colour.recovery.jiang2013.\ RGB_to_sd_camera_sensitivity_Jiang2013` definition. @@ -284,12 +290,12 @@ class TestRGB_to_msds_camera_sensitivities_Jiang2013(FixtureJiang2013): RGB_to_msds_camera_sensitivities_Jiang2013` definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" FixtureJiang2013.__init__(self) - def test_RGB_to_msds_camera_sensitivities_Jiang2013(self): + def test_RGB_to_msds_camera_sensitivities_Jiang2013(self) -> None: """ Test :func:`colour.recovery.jiang2013.\ RGB_to_msds_camera_sensitivities_Jiang2013` definition. diff --git a/colour/recovery/tests/test_mallett2019.py b/colour/recovery/tests/test_mallett2019.py index 2603fd6ae..de8df56f8 100644 --- a/colour/recovery/tests/test_mallett2019.py +++ b/colour/recovery/tests/test_mallett2019.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.mallett2019` module.""" +from __future__ import annotations + import numpy as np import pytest @@ -43,10 +45,9 @@ class FixtureMallett2019: """A fixture for testing the :mod:`colour.recovery.mallett2019` module.""" - @pytest.fixture(autouse=True) - def setup_fixture_mallett_2019(self) -> None: - """Configure the class instance.""" - + def __init__(self) -> None: + self._basis = MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019 + self._RGB_colourspace = RGB_COLOURSPACE_sRGB self._cmfs = reshape_msds( MSDS_CMFS["CIE 1931 2 Degree Standard Observer"], SpectralShape(360, 780, 10), @@ -54,7 +55,13 @@ def setup_fixture_mallett_2019(self) -> None: self._sd_D65 = reshape_sd(SDS_ILLUMINANTS["D65"], self._cmfs.shape) self._xy_D65 = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["D65"] - def check_basis_functions(self): + @pytest.fixture(autouse=True) + def setup_fixture_mallett_2019(self) -> None: + """Configure the class instance.""" + + self.__init__() + + def check_basis_functions(self) -> None: """ Test :func:`colour.recovery.RGB_to_sd_Mallett2019` definition or the more specialised :func:`colour.recovery.RGB_to_sd_Mallett2019` @@ -97,14 +104,14 @@ class TestSpectralPrimaryDecompositionMallett2019(FixtureMallett2019): spectral_primary_decomposition_Mallett2019` definition unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" FixtureMallett2019.__init__(self) self._RGB_colourspace = RGB_COLOURSPACE_PAL_SECAM - def test_spectral_primary_decomposition_Mallett2019(self): + def test_spectral_primary_decomposition_Mallett2019(self) -> None: """ Test :func:`colour.recovery.mallett2019.\ test_spectral_primary_decomposition_Mallett2019` definition. @@ -123,7 +130,7 @@ class TestRGB_to_sd_Mallett2019(FixtureMallett2019): unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" FixtureMallett2019.__init__(self) @@ -131,7 +138,7 @@ def setup_method(self): self._RGB_colourspace = RGB_COLOURSPACE_sRGB self._basis = MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019 - def test_RGB_to_sd_Mallett2019(self): + def test_RGB_to_sd_Mallett2019(self) -> None: """ Test :func:`colour.recovery.mallett2019.RGB_to_sd_Mallett2019` definition. diff --git a/colour/recovery/tests/test_meng2015.py b/colour/recovery/tests/test_meng2015.py index 7c9f625a2..b347f8047 100644 --- a/colour/recovery/tests/test_meng2015.py +++ b/colour/recovery/tests/test_meng2015.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.meng2015` module.""" +from __future__ import annotations + import numpy as np import pytest @@ -33,7 +35,7 @@ class TestXYZ_to_sd_Meng2015: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._cmfs = reshape_msds( @@ -43,7 +45,7 @@ def setup_method(self): self._sd_D65 = reshape_sd(SDS_ILLUMINANTS["D65"], self._cmfs.shape) self._sd_E = reshape_sd(SDS_ILLUMINANTS["E"], self._cmfs.shape) - def test_XYZ_to_sd_Meng2015(self): + def test_XYZ_to_sd_Meng2015(self) -> None: """Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition.""" XYZ = np.array([0.20654008, 0.12197225, 0.05136952]) @@ -100,7 +102,7 @@ def test_XYZ_to_sd_Meng2015(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_XYZ_to_sd_Meng2015(self): + def test_raise_exception_XYZ_to_sd_Meng2015(self) -> None: """ Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition raised exception. @@ -115,7 +117,7 @@ def test_raise_exception_XYZ_to_sd_Meng2015(self): }, ) - def test_domain_range_scale_XYZ_to_sd_Meng2015(self): + def test_domain_range_scale_XYZ_to_sd_Meng2015(self) -> None: """ Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition domain and range scale support. diff --git a/colour/recovery/tests/test_otsu2018.py b/colour/recovery/tests/test_otsu2018.py index 127794f49..77a7e1ba2 100644 --- a/colour/recovery/tests/test_otsu2018.py +++ b/colour/recovery/tests/test_otsu2018.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.jakob2019` module.""" +from __future__ import annotations + import os import platform import shutil @@ -55,7 +57,7 @@ class TestDataset_Otsu2018: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._dataset = DATASET_REFERENCE_OTSU2018 @@ -66,12 +68,12 @@ def setup_method(self): self._path = os.path.join(self._temporary_directory, "Test_Otsu2018.npz") self._dataset.write(self._path) - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -84,7 +86,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Dataset_Otsu2018) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -99,48 +101,51 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Dataset_Otsu2018) - def test_shape(self): + def test_shape(self) -> None: """Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.shape` property.""" assert self._dataset.shape == SPECTRAL_SHAPE_OTSU2018 - def test_basis_functions(self): + def test_basis_functions(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.basis_functions` property. """ + assert self._dataset.basis_functions is not None assert self._dataset.basis_functions.shape == (8, 3, 36) - def test_means(self): + def test_means(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.means` property. """ + assert self._dataset.means is not None assert self._dataset.means.shape == (8, 36) - def test_selector_array(self): + def test_selector_array(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Dataset_Otsu2018.selector_array` property. """ + assert self._dataset.selector_array is not None assert self._dataset.selector_array.shape == (7, 4) - def test__str__(self): + def test__str__(self) -> None: """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.__str__` method.""" assert str(self._dataset) == "Dataset_Otsu2018(8 basis functions)" assert str(Dataset_Otsu2018()) == "Dataset_Otsu2018()" - def test_select(self): + def test_select(self) -> None: """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.select` method.""" assert self._dataset.select(self._xy) == 6 - def test_raise_exception_select(self): + def test_raise_exception_select(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.select` method raised exception. @@ -148,14 +153,14 @@ def test_raise_exception_select(self): pytest.raises(ValueError, Dataset_Otsu2018().select, np.array([0, 0])) - def test_cluster(self): + def test_cluster(self) -> None: """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.cluster` method.""" basis_functions, means = self._dataset.cluster(self._xy) assert basis_functions.shape == (3, 36) assert means.shape == (36,) - def test_raise_exception_cluster(self): + def test_raise_exception_cluster(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.cluster` method raised exception. @@ -163,18 +168,21 @@ def test_raise_exception_cluster(self): pytest.raises(ValueError, Dataset_Otsu2018().cluster, np.array([0, 0])) - def test_read(self): + def test_read(self) -> None: """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.read` method.""" dataset = Dataset_Otsu2018() dataset.read(self._path) assert dataset.shape == SPECTRAL_SHAPE_OTSU2018 + assert dataset.basis_functions is not None assert dataset.basis_functions.shape == (8, 3, 36) + assert dataset.means is not None assert dataset.means.shape == (8, 36) + assert dataset.selector_array is not None assert dataset.selector_array.shape == (7, 4) - def test_write(self): + def test_write(self) -> None: """Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.write` method.""" self._dataset.write(self._path) @@ -183,11 +191,14 @@ def test_write(self): dataset.read(self._path) assert dataset.shape == SPECTRAL_SHAPE_OTSU2018 + assert dataset.basis_functions is not None assert dataset.basis_functions.shape == (8, 3, 36) + assert dataset.means is not None assert dataset.means.shape == (8, 36) + assert dataset.selector_array is not None assert dataset.selector_array.shape == (7, 4) - def test_raise_exception_write(self): + def test_raise_exception_write(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Dataset_Otsu2018.write` method raised exception. @@ -202,7 +213,7 @@ class TestXYZ_to_sd_Otsu2018: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -210,7 +221,7 @@ def setup_method(self): self._XYZ_D65 = sd_to_XYZ(self._sd_D65) self._xy_D65 = XYZ_to_xy(self._XYZ_D65) - def test_XYZ_to_sd_Otsu2018(self): + def test_XYZ_to_sd_Otsu2018(self) -> None: """Test :func:`colour.recovery.otsu2018.XYZ_to_sd_Otsu2018` definition.""" # Tests the round-trip with values of a colour checker. @@ -231,7 +242,7 @@ def test_XYZ_to_sd_Otsu2018(self): delta_E = delta_E_CIE1976(Lab, recovered_Lab) assert delta_E < 1e-12 - def test_raise_exception_XYZ_to_sd_Otsu2018(self): + def test_raise_exception_XYZ_to_sd_Otsu2018(self) -> None: """ Test :func:`colour.recovery.otsu2018.XYZ_to_sd_Otsu2018` definition raised_exception. @@ -246,7 +257,7 @@ def test_raise_exception_XYZ_to_sd_Otsu2018(self): Dataset_Otsu2018(), ) - def test_domain_range_scale_XYZ_to_sd_Otsu2018(self): + def test_domain_range_scale_XYZ_to_sd_Otsu2018(self) -> None: """ Test :func:`colour.recovery.otsu2018.XYZ_to_sd_Otsu2018` definition domain and range scale support. @@ -279,7 +290,7 @@ class TestData_Otsu2018: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -296,7 +307,7 @@ def setup_method(self): self._data = Data_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -310,7 +321,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Data_Otsu2018) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -327,7 +338,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Data_Otsu2018) - def test_reflectances(self): + def test_reflectances(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.reflectances` property. @@ -335,12 +346,12 @@ def test_reflectances(self): assert self._data.reflectances is self._reflectances - def test_cmfs(self): + def test_cmfs(self) -> None: """Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.cmfs` property.""" assert self._data.cmfs is self._cmfs - def test_illuminant(self): + def test_illuminant(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.illuminant` property. @@ -348,7 +359,7 @@ def test_illuminant(self): assert self._data.illuminant is self._sd_D65 - def test_basis_functions(self): + def test_basis_functions(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.basis_functions` property. @@ -360,9 +371,10 @@ def test_basis_functions(self): data.PCA() + assert data.basis_functions is not None assert data.basis_functions.shape == (3, 36) - def test_mean(self): + def test_mean(self) -> None: """Test :attr:`colour.recovery.otsu2018.Data_Otsu2018.mean` property.""" data = Data_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) @@ -371,19 +383,20 @@ def test_mean(self): data.PCA() + assert data.mean is not None assert data.mean.shape == (36,) - def test__str__(self): + def test__str__(self) -> None: """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.__str__` method.""" assert str(self._data) == "Data_Otsu2018(24 Reflectances)" - def test__len__(self): + def test__len__(self) -> None: """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.__len__` method.""" assert len(self._data) == 24 - def test_origin(self): + def test_origin(self) -> None: """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.origin` method.""" np.testing.assert_allclose( @@ -392,7 +405,7 @@ def test_origin(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_origin(self): + def test_raise_exception_origin(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.origin` method raised exception. @@ -405,14 +418,14 @@ def test_raise_exception_origin(self): 1, ) - def test_partition(self): + def test_partition(self) -> None: """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.partition` method.""" partition = self._data.partition(PartitionAxis(4, 1)) assert len(partition) == 2 - def test_raise_exception_partition(self): + def test_raise_exception_partition(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.partition` method raised exception. @@ -424,7 +437,7 @@ def test_raise_exception_partition(self): PartitionAxis(4, 1), ) - def test_PCA(self): + def test_PCA(self) -> None: """Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.PCA` method.""" if platform.system() in ("Windows", "Microsoft", "Linux"): @@ -434,6 +447,8 @@ def test_PCA(self): data.PCA() + assert data.basis_functions is not None + np.testing.assert_allclose( np.abs(data.basis_functions), np.array( @@ -557,6 +572,8 @@ def test_PCA(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) + assert data.mean is not None + np.testing.assert_allclose( data.mean, np.array( @@ -602,7 +619,7 @@ def test_PCA(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_reconstruct(self): + def test_reconstruct(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.reconstruct` method. @@ -665,7 +682,7 @@ def test_reconstruct(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_reconstruct(self): + def test_raise_exception_reconstruct(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.reconstruct` method raised exception. @@ -677,7 +694,7 @@ def test_raise_exception_reconstruct(self): np.array([0, 0, 0]), ) - def test_reconstruction_error(self): + def test_reconstruction_error(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.\ reconstruction_error` method. @@ -691,7 +708,7 @@ def test_reconstruction_error(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_raise_exception_reconstruction_error(self): + def test_raise_exception_reconstruction_error(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Data_Otsu2018.\ reconstruction_error` method raised exception. @@ -709,7 +726,7 @@ class TestNode_Otsu2018: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -736,7 +753,7 @@ def setup_method(self): self._partition_axis = self._node_a.partition_axis - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("partition_axis", "row") @@ -744,7 +761,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Node_Otsu2018) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -758,7 +775,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Node_Otsu2018) - def test_partition_axis(self): + def test_partition_axis(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Node_Otsu2018.partition_axis` property. @@ -766,7 +783,7 @@ def test_partition_axis(self): assert self._node_a.partition_axis is self._partition_axis - def test_row(self): + def test_row(self) -> None: """Test :attr:`colour.recovery.otsu2018.Node_Otsu2018.row` property.""" assert self._node_a.row == ( @@ -776,7 +793,7 @@ def test_row(self): self._node_c, ) - def test_raise_exception_row(self): + def test_raise_exception_row(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Node_Otsu2018.row` property raised exception. @@ -784,7 +801,7 @@ def test_raise_exception_row(self): pytest.raises(ValueError, lambda: Node_Otsu2018().row) - def test_split(self): + def test_split(self) -> None: """Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.split` method.""" node_a = Node_Otsu2018(self._tree, None) @@ -794,7 +811,7 @@ def test_split(self): assert len(node_a.children) == 2 - def test_minimise(self): + def test_minimise(self) -> None: """Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.minimise` method.""" node = Node_Otsu2018(data=self._data_a) @@ -809,7 +826,7 @@ def test_minimise(self): partition_error, 2.0402980027, atol=TOLERANCE_ABSOLUTE_TESTS ) - def test_leaf_reconstruction_error(self): + def test_leaf_reconstruction_error(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.\ leaf_reconstruction_error` method. @@ -821,7 +838,7 @@ def test_leaf_reconstruction_error(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_branch_reconstruction_error(self): + def test_branch_reconstruction_error(self) -> None: """ Test :meth:`colour.recovery.otsu2018.Node_Otsu2018.\ branch_reconstruction_error` method. @@ -840,7 +857,7 @@ class TestTree_Otsu2018: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._shape = SPECTRAL_SHAPE_OTSU2018 @@ -860,12 +877,12 @@ def setup_method(self): self._path = os.path.join(self._temporary_directory, "Test_Otsu2018.npz") - def teardown_method(self): + def teardown_method(self) -> None: """After tests actions.""" shutil.rmtree(self._temporary_directory) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("reflectances", "cmfs", "illuminant") @@ -873,7 +890,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Tree_Otsu2018) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__str__", "optimise", "to_dataset") @@ -881,7 +898,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Tree_Otsu2018) - def test_reflectances(self): + def test_reflectances(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Tree_Otsu2018.reflectances` property. @@ -897,12 +914,12 @@ def test_reflectances(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_cmfs(self): + def test_cmfs(self) -> None: """Test :attr:`colour.recovery.otsu2018.Tree_Otsu2018.cmfs` property.""" assert self._tree.cmfs is self._cmfs - def test_illuminant(self): + def test_illuminant(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Tree_Otsu2018.illuminant` property. @@ -910,7 +927,7 @@ def test_illuminant(self): assert self._tree.illuminant is self._sd_D65 - def test_optimise(self): + def test_optimise(self) -> None: """Test :class:`colour.recovery.otsu2018.Tree_Otsu2018.optimise` method.""" node_tree = Tree_Otsu2018(self._reflectances, self._cmfs, self._sd_D65) @@ -941,7 +958,7 @@ def test_optimise(self): delta_E = delta_E_CIE1976(Lab, recovered_Lab) assert delta_E < 1e-12 - def test_to_dataset(self): + def test_to_dataset(self) -> None: """ Test :attr:`colour.recovery.otsu2018.Tree_Otsu2018.to_dataset` method. diff --git a/colour/recovery/tests/test_smits1999.py b/colour/recovery/tests/test_smits1999.py index 44394a2f4..48dc62ca5 100644 --- a/colour/recovery/tests/test_smits1999.py +++ b/colour/recovery/tests/test_smits1999.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.recovery.smits1999` module.""" +from __future__ import annotations + import numpy as np from colour.colorimetry import sd_to_XYZ_integration @@ -26,7 +28,7 @@ class TestRGB_to_sd_Smits1999: definition unit tests methods. """ - def test_RGB_to_sd_Smits1999(self): + def test_RGB_to_sd_Smits1999(self) -> None: """ Test :func:`colour.recovery.smits1999.RGB_to_sd_Smits1999` definition. @@ -152,7 +154,7 @@ def test_RGB_to_sd_Smits1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_domain_range_scale_RGB_to_sd_Smits1999(self): + def test_domain_range_scale_RGB_to_sd_Smits1999(self) -> None: """ Test :func:`colour.recovery.smits1999.RGB_to_sd_Smits1999` definition domain and range scale support. diff --git a/colour/temperature/ohno2013.py b/colour/temperature/ohno2013.py index a204cea2b..f0a4039bf 100644 --- a/colour/temperature/ohno2013.py +++ b/colour/temperature/ohno2013.py @@ -340,7 +340,7 @@ def XYZ_to_CCT_Ohno2013( start: float | None = None, end: float | None = None, spacing: float | None = None, -): +) -> NDArrayFloat: """ Return the correlated colour temperature :math:`T_{cp}` and :math:`\\Delta_{uv}` from given *CIE XYZ* tristimulus values, colour @@ -391,7 +391,7 @@ def XYZ_to_CCT_Ohno2013( def CCT_to_XYZ_Ohno2013( CCT_D_uv: ArrayLike, cmfs: MultiSpectralDistributions | None = None -): +) -> NDArrayFloat: """ Return the *CIE XYZ* tristimulus values from given correlated colour temperature :math:`T_{cp}`, :math:`\\Delta_{uv}` and colour matching diff --git a/colour/temperature/tests/test_cie_d.py b/colour/temperature/tests/test_cie_d.py index f20ff4606..6e8e47376 100644 --- a/colour/temperature/tests/test_cie_d.py +++ b/colour/temperature/tests/test_cie_d.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.cie_d` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXy_to_CCT_CIE_D: tests methods. """ - def test_xy_to_CCT_CIE_D(self): + def test_xy_to_CCT_CIE_D(self) -> None: """Test :func:`colour.temperature.cie_d.xy_to_CCT_CIE_D` definition.""" np.testing.assert_allclose( @@ -57,7 +59,7 @@ def test_xy_to_CCT_CIE_D(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_CCT_CIE_D(self): + def test_n_dimensional_xy_to_CCT_CIE_D(self) -> None: """ Test :func:`colour.temperature.cie_d.xy_to_CCT_CIE_D` definition n-dimensional arrays support. @@ -79,7 +81,7 @@ def test_n_dimensional_xy_to_CCT_CIE_D(self): ) @ignore_numpy_errors - def test_nan_xy_to_CCT_CIE_D(self): + def test_nan_xy_to_CCT_CIE_D(self) -> None: """ Test :func:`colour.temperature.cie_d.xy_to_CCT_CIE_D` definition nan support. @@ -96,7 +98,7 @@ class TestCCT_to_xy_CIE_D: unit tests methods. """ - def test_CCT_to_xy_CIE_D(self): + def test_CCT_to_xy_CIE_D(self) -> None: """Test :func:`colour.temperature.cie_d.CCT_to_xy_CIE_D` definition.""" np.testing.assert_allclose( @@ -117,7 +119,7 @@ def test_CCT_to_xy_CIE_D(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_xy_CIE_D(self): + def test_n_dimensional_CCT_to_xy_CIE_D(self) -> None: """ Test :func:`colour.temperature.cie_d.CCT_to_xy_CIE_D` definition n-dimensional arrays support. @@ -139,7 +141,7 @@ def test_n_dimensional_CCT_to_xy_CIE_D(self): ) @ignore_numpy_errors - def test_nan_CCT_to_xy_CIE_D(self): + def test_nan_CCT_to_xy_CIE_D(self) -> None: """ Test :func:`colour.temperature.cie_d.CCT_to_xy_CIE_D` definition nan support. diff --git a/colour/temperature/tests/test_hernandez1999.py b/colour/temperature/tests/test_hernandez1999.py index 3423a8de2..920f8c77f 100644 --- a/colour/temperature/tests/test_hernandez1999.py +++ b/colour/temperature/tests/test_hernandez1999.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.hernandez1999` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class Testxy_to_CCT_Hernandez1999: definition unit tests methods. """ - def test_xy_to_CCT_Hernandez1999(self): + def test_xy_to_CCT_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.xy_to_CCT_McCamy1992` definition. @@ -51,7 +53,7 @@ def test_xy_to_CCT_Hernandez1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_CCT_Hernandez1999(self): + def test_n_dimensional_xy_to_CCT_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.xy_to_CCT_Hernandez1999` definition n-dimensional arrays support. @@ -73,7 +75,7 @@ def test_n_dimensional_xy_to_CCT_Hernandez1999(self): ) @ignore_numpy_errors - def test_nan_xy_to_CCT_Hernandez1999(self): + def test_nan_xy_to_CCT_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.xy_to_CCT_Hernandez1999` definition nan support. @@ -90,7 +92,7 @@ class TestCCT_to_xy_Hernandez1999: definition unit tests methods. """ - def test_CCT_to_xy_Hernandez1999(self): + def test_CCT_to_xy_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.CCT_to_xy_Hernandez1999` definition. @@ -114,7 +116,7 @@ def test_CCT_to_xy_Hernandez1999(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_xy_Hernandez1999(self): + def test_n_dimensional_CCT_to_xy_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.CCT_to_xy_Hernandez1999` definition n-dimensional arrays support. @@ -136,7 +138,7 @@ def test_n_dimensional_CCT_to_xy_Hernandez1999(self): ) @ignore_numpy_errors - def test_nan_CCT_to_xy_Hernandez1999(self): + def test_nan_CCT_to_xy_Hernandez1999(self) -> None: """ Test :func:`colour.temperature.hernandez1999.CCT_to_xy_Hernandez1999` definition nan support. diff --git a/colour/temperature/tests/test_kang2002.py b/colour/temperature/tests/test_kang2002.py index 8a733a39f..fbc6fede8 100644 --- a/colour/temperature/tests/test_kang2002.py +++ b/colour/temperature/tests/test_kang2002.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.kang2002` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestXy_to_CCT_Kang2002: definition unit tests methods. """ - def test_xy_to_CCT_Kang2002(self): + def test_xy_to_CCT_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.xy_to_CCT_Kang2002` definition. @@ -60,7 +62,7 @@ def test_xy_to_CCT_Kang2002(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_CCT_Kang2002(self): + def test_n_dimensional_xy_to_CCT_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.xy_to_CCT_Kang2002` definition n-dimensional arrays support. @@ -82,7 +84,7 @@ def test_n_dimensional_xy_to_CCT_Kang2002(self): ) @ignore_numpy_errors - def test_nan_xy_to_CCT_Kang2002(self): + def test_nan_xy_to_CCT_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.xy_to_CCT_Kang2002` definition nan support. @@ -99,7 +101,7 @@ class TestCCT_to_xy_Kang2002: unit tests methods. """ - def test_CCT_to_xy_Kang2002(self): + def test_CCT_to_xy_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.CCT_to_xy_Kang2002` definition. @@ -123,7 +125,7 @@ def test_CCT_to_xy_Kang2002(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_xy_Kang2002(self): + def test_n_dimensional_CCT_to_xy_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.CCT_to_xy_Kang2002` definition n-dimensional arrays support. @@ -145,7 +147,7 @@ def test_n_dimensional_CCT_to_xy_Kang2002(self): ) @ignore_numpy_errors - def test_nan_CCT_to_xy_Kang2002(self): + def test_nan_CCT_to_xy_Kang2002(self) -> None: """ Test :func:`colour.temperature.kang2002.CCT_to_xy_Kang2002` definition nan support. diff --git a/colour/temperature/tests/test_krystek1985.py b/colour/temperature/tests/test_krystek1985.py index 671bd26a3..f50d58587 100644 --- a/colour/temperature/tests/test_krystek1985.py +++ b/colour/temperature/tests/test_krystek1985.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.krystek1985` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -26,7 +28,7 @@ class TestUv_to_CCT_Krystek1985: definition unit tests methods. """ - def test_uv_to_CCT_Krystek1985(self): + def test_uv_to_CCT_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.uv_to_CCT_Krystek1985` definition. @@ -59,7 +61,7 @@ def test_uv_to_CCT_Krystek1985(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_uv_to_CCT_Krystek1985(self): + def test_n_dimensional_uv_to_CCT_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.uv_to_CCT_Krystek1985` definition n-dimensional arrays support. @@ -81,7 +83,7 @@ def test_n_dimensional_uv_to_CCT_Krystek1985(self): ) @ignore_numpy_errors - def test_nan_uv_to_CCT_Krystek1985(self): + def test_nan_uv_to_CCT_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.uv_to_CCT_Krystek1985` definition nan support. @@ -98,7 +100,7 @@ class TestCCT_to_uv_Krystek1985: definition unit tests methods. """ - def test_CCT_to_uv_Krystek1985(self): + def test_CCT_to_uv_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.CCT_to_uv_Krystek1985` definition. @@ -122,7 +124,7 @@ def test_CCT_to_uv_Krystek1985(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_uv_Krystek1985(self): + def test_n_dimensional_CCT_to_uv_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.CCT_to_uv_Krystek1985` definition n-dimensional arrays support. @@ -144,7 +146,7 @@ def test_n_dimensional_CCT_to_uv_Krystek1985(self): ) @ignore_numpy_errors - def test_nan_CCT_to_uv_Krystek1985(self): + def test_nan_CCT_to_uv_Krystek1985(self) -> None: """ Test :func:`colour.temperature.krystek1985.CCT_to_uv_Krystek1985` definition nan support. diff --git a/colour/temperature/tests/test_mccamy1992.py b/colour/temperature/tests/test_mccamy1992.py index 421a32aef..1ba25fa1b 100644 --- a/colour/temperature/tests/test_mccamy1992.py +++ b/colour/temperature/tests/test_mccamy1992.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.mccamy1992` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class Testxy_to_CCT_McCamy1992: definition unit tests methods. """ - def test_xy_to_CCT_McCamy1992(self): + def test_xy_to_CCT_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.xy_to_CCT_McCamy1992` definition. @@ -51,7 +53,7 @@ def test_xy_to_CCT_McCamy1992(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_xy_to_CCT_McCamy1992(self): + def test_n_dimensional_xy_to_CCT_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.xy_to_CCT_McCamy1992` definition n-dimensional arrays support. @@ -73,7 +75,7 @@ def test_n_dimensional_xy_to_CCT_McCamy1992(self): ) @ignore_numpy_errors - def test_nan_xy_to_CCT_McCamy1992(self): + def test_nan_xy_to_CCT_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.xy_to_CCT_McCamy1992` definition nan support. @@ -90,7 +92,7 @@ class TestCCT_to_xy_McCamy1992: definition unit tests methods. """ - def test_CCT_to_xy_McCamy1992(self): + def test_CCT_to_xy_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.CCT_to_xy_McCamy1992` definition. @@ -114,7 +116,7 @@ def test_CCT_to_xy_McCamy1992(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_xy_McCamy1992(self): + def test_n_dimensional_CCT_to_xy_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.CCT_to_xy_McCamy1992` definition n-dimensional arrays support. @@ -136,7 +138,7 @@ def test_n_dimensional_CCT_to_xy_McCamy1992(self): ) @ignore_numpy_errors - def test_nan_CCT_to_xy_McCamy1992(self): + def test_nan_CCT_to_xy_McCamy1992(self) -> None: """ Test :func:`colour.temperature.mccamy1992.CCT_to_xy_McCamy1992` definition nan support. diff --git a/colour/temperature/tests/test_ohno2013.py b/colour/temperature/tests/test_ohno2013.py index 06bfcd2b2..3315f7091 100644 --- a/colour/temperature/tests/test_ohno2013.py +++ b/colour/temperature/tests/test_ohno2013.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.ohno2013` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -39,7 +41,7 @@ class TestPlanckianTable: unit tests methods. """ - def test_planckian_table(self): + def test_planckian_table(self) -> None: """Test :func:`colour.temperature.ohno2013.planckian_table` definition.""" np.testing.assert_allclose( @@ -86,7 +88,7 @@ class TestUv_to_CCT_Ohno2013: unit tests methods. """ - def test_uv_to_CCT_Ohno2013(self): + def test_uv_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.uv_to_CCT_Ohno2013` definition. @@ -119,7 +121,7 @@ def test_uv_to_CCT_Ohno2013(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_uv_to_CCT_Ohno2013(self): + def test_n_dimensional_uv_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.uv_to_CCT_Ohno2013` definition n-dimensional arrays support. @@ -141,7 +143,7 @@ def test_n_dimensional_uv_to_CCT_Ohno2013(self): ) @ignore_numpy_errors - def test_nan_uv_to_CCT_Ohno2013(self): + def test_nan_uv_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.uv_to_CCT_Ohno2013` definition nan support. @@ -158,7 +160,7 @@ class TestCCT_to_uv_Ohno2013: unit tests methods. """ - def test_CCT_to_uv_Ohno2013(self): + def test_CCT_to_uv_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_uv_Ohno2013` definition. @@ -182,7 +184,7 @@ def test_CCT_to_uv_Ohno2013(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_uv_Ohno2013(self): + def test_n_dimensional_CCT_to_uv_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_uv_Ohno2013` definition n-dimensional arrays support. @@ -204,7 +206,7 @@ def test_n_dimensional_CCT_to_uv_Ohno2013(self): ) @ignore_numpy_errors - def test_nan_CCT_to_uv_Ohno2013(self): + def test_nan_CCT_to_uv_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_uv_Ohno2013` definition nan support. @@ -221,7 +223,7 @@ class Test_XYZ_to_CCT_Ohno2013: unit tests methods. """ - def test_XYZ_to_CCT_Ohno2013(self): + def test_XYZ_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.XYZ_to_CCT_Ohno2013` definition. """ @@ -232,7 +234,7 @@ def test_XYZ_to_CCT_Ohno2013(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_XYZ_to_CCT_Ohno2013(self): + def test_n_dimensional_XYZ_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.XYZ_to_CCT_Ohno2013` definition n-dimensional arrays support. @@ -254,7 +256,7 @@ def test_n_dimensional_XYZ_to_CCT_Ohno2013(self): ) @ignore_numpy_errors - def test_nan_XYZ_to_CCT_Ohno2013(self): + def test_nan_XYZ_to_CCT_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.XYZ_to_CCT_Ohno2013` definition nan support. @@ -271,7 +273,7 @@ class Test_CCT_to_XYZ_Ohno2013: unit tests methods. """ - def test_CCT_to_XYZ_Ohno2013(self): + def test_CCT_to_XYZ_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_XYZ_Ohno2013` definition. """ @@ -282,7 +284,7 @@ def test_CCT_to_XYZ_Ohno2013(self): atol=1e-6, ) - def test_n_dimensional_CCT_to_XYZ_Ohno2013(self): + def test_n_dimensional_CCT_to_XYZ_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_XYZ_Ohno2013` definition n-dimensional arrays support. @@ -304,7 +306,7 @@ def test_n_dimensional_CCT_to_XYZ_Ohno2013(self): ) @ignore_numpy_errors - def test_nan_CCT_to_uv_Ohno2013(self): + def test_nan_CCT_to_uv_Ohno2013(self) -> None: """ Test :func:`colour.temperature.ohno2013.CCT_to_uv_Ohno2013` definition nan support. diff --git a/colour/temperature/tests/test_planck1900.py b/colour/temperature/tests/test_planck1900.py index 6d567336b..cb22a9c51 100644 --- a/colour/temperature/tests/test_planck1900.py +++ b/colour/temperature/tests/test_planck1900.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.temperature.planck1900` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -27,7 +29,7 @@ class TestUv_to_CCT_Planck1900: definition unit tests methods. """ - def test_uv_to_CCT_Planck1900(self): + def test_uv_to_CCT_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.uv_to_CCT_Planck1900` definition. @@ -60,7 +62,7 @@ def test_uv_to_CCT_Planck1900(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_uv_to_CCT_Planck1900(self): + def test_n_dimensional_uv_to_CCT_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.uv_to_CCT_Planck1900` definition n-dimensional arrays support. @@ -82,7 +84,7 @@ def test_n_dimensional_uv_to_CCT_Planck1900(self): ) @ignore_numpy_errors - def test_nan_uv_to_CCT_Planck1900(self): + def test_nan_uv_to_CCT_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.uv_to_CCT_Planck1900` definition nan support. @@ -99,7 +101,7 @@ class TestCCT_to_uv_Planck1900: unit tests methods. """ - def test_CCT_to_uv_Planck1900(self): + def test_CCT_to_uv_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.CCT_to_uv_Planck1900` definition. @@ -123,7 +125,7 @@ def test_CCT_to_uv_Planck1900(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_uv_Planck1900(self): + def test_n_dimensional_CCT_to_uv_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.CCT_to_uv_Planck1900` definition n-dimensional arrays support. @@ -145,7 +147,7 @@ def test_n_dimensional_CCT_to_uv_Planck1900(self): ) @ignore_numpy_errors - def test_nan_CCT_to_uv_Planck1900(self): + def test_nan_CCT_to_uv_Planck1900(self) -> None: """ Test :func:`colour.temperature.planck1900.CCT_to_uv_Planck1900` definition nan support. diff --git a/colour/temperature/tests/test_robertson1968.py b/colour/temperature/tests/test_robertson1968.py index 88b4c38df..ea6aad7b0 100644 --- a/colour/temperature/tests/test_robertson1968.py +++ b/colour/temperature/tests/test_robertson1968.py @@ -139,7 +139,7 @@ class TestMired_to_CCT: definition unit tests methods. """ - def test_mired_to_CCT(self): + def test_mired_to_CCT(self) -> None: """ Test :func:`colour.temperature.robertson1968.mired_to_CCT` definition. @@ -159,7 +159,7 @@ def test_mired_to_CCT(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_mired_to_CCT(self): + def test_n_dimensional_mired_to_CCT(self) -> None: """ Test :func:`colour.temperature.robertson1968.mired_to_CCT` definition n-dimensional arrays support. @@ -181,7 +181,7 @@ def test_n_dimensional_mired_to_CCT(self): ) @ignore_numpy_errors - def test_nan_mired_to_CCT(self): + def test_nan_mired_to_CCT(self) -> None: """ Test :func:`colour.temperature.robertson1968.mired_to_CCT` definition nan support. @@ -198,7 +198,7 @@ class TestCCT_to_mired: definition unit tests methods. """ - def test_CCT_to_mired(self): + def test_CCT_to_mired(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_mired` definition. @@ -218,7 +218,7 @@ def test_CCT_to_mired(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_mired(self): + def test_n_dimensional_CCT_to_mired(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_mired` definition n-dimensional arrays support. @@ -240,7 +240,7 @@ def test_n_dimensional_CCT_to_mired(self): ) @ignore_numpy_errors - def test_nan_CCT_to_mired(self): + def test_nan_CCT_to_mired(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_mired` definition nan support. @@ -257,7 +257,7 @@ class TestUv_to_CCT_Robertson1968: definition unit tests methods. """ - def test_uv_to_CCT_Robertson1968(self): + def test_uv_to_CCT_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.uv_to_CCT_Robertson1968` definition. @@ -266,7 +266,7 @@ def test_uv_to_CCT_Robertson1968(self): for key, value in TEMPERATURE_DUV_TO_UV.items(): np.testing.assert_allclose(uv_to_CCT_Robertson1968(value), key, atol=0.25) - def test_n_dimensional_uv_to_CCT_Robertson1968(self): + def test_n_dimensional_uv_to_CCT_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.uv_to_CCT_Robertson1968` definition n-dimensional arrays support. @@ -292,7 +292,7 @@ def test_n_dimensional_uv_to_CCT_Robertson1968(self): ) @ignore_numpy_errors - def test_nan_uv_to_CCT_Robertson1968(self): + def test_nan_uv_to_CCT_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.uv_to_CCT_Robertson1968` definition nan support. @@ -309,7 +309,7 @@ class TestCCT_to_uv_Robertson1968: definition unit tests methods. """ - def test_CCT_to_uv_Robertson1968(self): + def test_CCT_to_uv_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_uv_Robertson1968` definition. @@ -322,7 +322,7 @@ def test_CCT_to_uv_Robertson1968(self): atol=TOLERANCE_ABSOLUTE_TESTS, ) - def test_n_dimensional_CCT_to_uv_Robertson1968(self): + def test_n_dimensional_CCT_to_uv_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_uv_Robertson1968` definition n-dimensional arrays support. @@ -348,7 +348,7 @@ def test_n_dimensional_CCT_to_uv_Robertson1968(self): ) @ignore_numpy_errors - def test_nan_CCT_to_uv_Robertson1968(self): + def test_nan_CCT_to_uv_Robertson1968(self) -> None: """ Test :func:`colour.temperature.robertson1968.CCT_to_uv_Robertson1968` definition nan support. diff --git a/colour/utilities/__init__.py b/colour/utilities/__init__.py index 129815065..19b10f5a0 100644 --- a/colour/utilities/__init__.py +++ b/colour/utilities/__init__.py @@ -299,7 +299,7 @@ class utilities(ModuleAPI): """Define a class acting like the *utilities* module.""" - def __getattr__(self, attribute) -> Any: + def __getattr__(self, attribute: str) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 786b02a57..29cc38168 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -44,7 +44,7 @@ NDArrayFloat, NDArrayInt, Real, - Tuple, + Sequence, Type, cast, ) @@ -239,7 +239,9 @@ class MixinDataclassArray(MixinDataclassIterable): - :class:`colour.utilities.MixinDataclassFields` """ - def __array__(self, dtype: Type[DTypeReal] | None = None, copy=None) -> NDArray: + def __array__( + self, dtype: Type[DTypeReal] | None = None, copy: bool = True + ) -> NDArray: """ Implement support for :class:`dataclass`-like class conversion to :class:`numpy.ndarray` class. @@ -541,7 +543,7 @@ def arithmetical_operation( def as_array( - a: ArrayLike, + a: ArrayLike | KeysView | ValuesView, dtype: Type[DType] | None = None, ) -> NDArray: """ @@ -771,6 +773,7 @@ def as_int_scalar(a: ArrayLike, dtype: Type[DTypeInt] | None = None) -> int: attest(a.ndim == 0, f'"{a}" cannot be converted to "int" scalar!') + # TODO: Revisit when Numpy types are well established. return cast(int, as_int(a, dtype)) @@ -808,6 +811,7 @@ def as_float_scalar(a: ArrayLike, dtype: Type[DTypeFloat] | None = None) -> floa attest(a.ndim == 0, f'"{a}" cannot be converted to "float" scalar!') + # TODO: Revisit when Numpy types are well established. return cast(float, as_float(a, dtype)) @@ -952,7 +956,7 @@ def set_domain_range_scale( scale: ( Literal["ignore", "reference", "Ignore", "Reference", "1", "100"] | str ) = "reference", -): +) -> None: """ Set the current *Colour* domain-range scale. The following scales are available: @@ -1056,7 +1060,7 @@ def __enter__(self) -> domain_range_scale: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """Set the previous domain-range scale upon exiting the context manager.""" set_domain_range_scale(self._previous_scale) @@ -1783,7 +1787,7 @@ def is_ndarray_copy_enabled() -> bool: return _NDARRAY_COPY_ENABLED -def set_ndarray_copy_enable(enable: bool): +def set_ndarray_copy_enable(enable: bool) -> None: """ Set *Colour* :class:`numpy.ndarray` copy enabled state. @@ -1832,7 +1836,7 @@ def __enter__(self) -> ndarray_copy_enable: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """ Set the *Colour* :class:`numpy.ndarray` copy enabled state upon exiting the context manager. @@ -2512,7 +2516,7 @@ def ndarray_write(a: ArrayLike) -> Generator: def zeros( - shape: int | Tuple[int, ...], + shape: int | Sequence[int], dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", ) -> NDArray: @@ -2550,7 +2554,7 @@ def zeros( def ones( - shape: int | Tuple[int, ...], + shape: int | Sequence[int], dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", ) -> NDArray: @@ -2588,7 +2592,7 @@ def ones( def full( - shape: int | Tuple[int, ...], + shape: int | Sequence[int], fill_value: Real, dtype: Type[DTypeReal] | None = None, order: Literal["C", "F"] = "C", diff --git a/colour/utilities/common.py b/colour/utilities/common.py index a4cc7c132..064261ebb 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -110,7 +110,7 @@ def is_caching_enabled() -> bool: return _CACHING_ENABLED -def set_caching_enable(enable: bool): +def set_caching_enable(enable: bool) -> None: """ Set *Colour* caching enabled state. @@ -159,7 +159,7 @@ def __enter__(self) -> caching_enable: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """ Set the *Colour* caching enabled state upon exiting the context manager. @@ -278,7 +278,7 @@ def register_cache(self, name: str) -> dict: return self._registry[name] - def unregister_cache(self, name: str): + def unregister_cache(self, name: str) -> None: """ Unregister cache with given name in the registry. @@ -312,7 +312,7 @@ def unregister_cache(self, name: str): del self._registry[name] - def clear_cache(self, name: str): + def clear_cache(self, name: str) -> None: """ Clear the cache with given name. @@ -335,7 +335,7 @@ def clear_cache(self, name: str): self._registry[name].clear() - def clear_all_caches(self): + def clear_all_caches(self) -> None: """ Clear all the caches in the registry. @@ -447,7 +447,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: return wrapper -def attest(condition: bool | DTypeBoolean, message: str = ""): +def attest(condition: bool | DTypeBoolean, message: str = "") -> None: """ Provide the `assert` statement functionality without being disabled by optimised Python execution. @@ -512,7 +512,7 @@ def __enter__(self) -> disable_multiprocessing: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """ Enable *Colour* multiprocessing state upon exiting the context manager. @@ -535,7 +535,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: return wrapper -def _initializer(kwargs: Any): +def _initializer(kwargs: Any) -> None: """ Initialize a multiprocessing pool. @@ -613,12 +613,17 @@ class _DummyPool: def __init__(self, *args: Any, **kwargs: Any) -> None: pass - def map(self, func, iterable, chunksize=None): # noqa: ARG002 + def map( + self, + func: Callable, + iterable: Sequence, + chunksize: int | None = None, # noqa: ARG002 + ) -> list[Any]: """Apply given function to each element of given iterable.""" return [func(a) for a in iterable] - def terminate(self): + def terminate(self) -> None: """Terminate the process.""" kwargs["initializer"] = _initializer diff --git a/colour/utilities/network.py b/colour/utilities/network.py index bdfe2523b..593ca5d18 100644 --- a/colour/utilities/network.py +++ b/colour/utilities/network.py @@ -38,6 +38,7 @@ Generator, List, Self, + Sequence, Tuple, Type, ) @@ -194,7 +195,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -223,7 +224,7 @@ def parent(self) -> Self | None: return self._parent @parent.setter - def parent(self, value: Self | None): + def parent(self, value: Self | None) -> None: """Setter for the **self.parent** property.""" from colour.utilities import attest @@ -258,7 +259,7 @@ def children(self) -> List[Self]: return self._children @children.setter - def children(self, value: List[Self]): + def children(self, value: List[Self]) -> None: """Setter for the **self.children** property.""" from colour.utilities import attest @@ -342,7 +343,7 @@ def data(self) -> Any: return self._data @data.setter - def data(self, value: Any): + def data(self, value: Any) -> None: """Setter for the **self.data** property.""" self._data = value @@ -486,7 +487,7 @@ def walk_hierarchy(self, ascendants: bool = False) -> Generator: yield from node.walk_hierarchy(ascendants=ascendants) - def render(self, tab_level: int = 0): + def render(self, tab_level: int = 0) -> str: """ Render the current node and its children as a string. @@ -615,7 +616,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, value: str): + def name(self, value: str) -> None: """Setter for the **self.name** property.""" attest( @@ -651,7 +652,7 @@ def value(self) -> Any: return self._value @value.setter - def value(self, value: Any): + def value(self, value: Any) -> None: """Setter for the **self.value** property.""" self._value = value @@ -704,7 +705,7 @@ def description(self) -> str | None: return self._description @description.setter - def description(self, value: str | None): + def description(self, value: str | None) -> None: """Setter for the **self.description** property.""" attest( @@ -729,7 +730,7 @@ def node(self) -> PortNode | None: return self._node @node.setter - def node(self, value: PortNode | None): + def node(self, value: PortNode | None) -> None: """Setter for the **self.node** property.""" attest( @@ -955,7 +956,7 @@ class PortNode(TreeNode, MixinLogging): Examples -------- >>> class NodeAdd(PortNode): - ... def __init__(self, *args, **kwargs): + ... def __init__(self, *args: Any, **kwargs: Any): ... super().__init__(*args, **kwargs) ... ... self.description = "Perform the addition of the two input port values." @@ -982,7 +983,7 @@ class PortNode(TreeNode, MixinLogging): 2 """ - def __init__(self, name: str | None = None, description: str | None = None): + def __init__(self, name: str | None = None, description: str | None = None) -> None: super().__init__(name) self._description = description self.description = optional(description, self._description) @@ -1036,7 +1037,7 @@ def dirty(self) -> bool: return self._dirty @dirty.setter - def dirty(self, value: bool): + def dirty(self, value: bool) -> None: """Setter for the **self.dirty** property.""" attest( @@ -1094,7 +1095,7 @@ def description(self) -> str | None: return self._description @description.setter - def description(self, value: str | None): + def description(self, value: str | None) -> None: """Setter for the **self.description** property.""" attest( @@ -1185,7 +1186,7 @@ def add_output_port( value: Any = None, description: str | None = None, port_type: Type[Port] = Port, - ) -> None: + ) -> Port: """ Add an output port with given name and value to the node. @@ -1484,7 +1485,7 @@ def process(self) -> None: Examples -------- >>> class NodeAdd(PortNode): - ... def __init__(self, *args, **kwargs): + ... def __init__(self, *args: Any, **kwargs: Any): ... super().__init__(*args, **kwargs) ... ... self.description = ( @@ -1572,7 +1573,7 @@ class PortGraph(PortNode): Examples -------- >>> class NodeAdd(PortNode): - ... def __init__(self, *args, **kwargs): + ... def __init__(self, *args: Any, **kwargs: Any): ... super().__init__(*args, **kwargs) ... ... self.description = "Perform the addition of the two input port values." @@ -1608,7 +1609,7 @@ class PortGraph(PortNode): 3 """ - def __init__(self, name: str | None = None, description: str | None = None): + def __init__(self, name: str | None = None, description: str | None = None) -> None: super().__init__(name, description) self._name: str = self.__class__.__name__ @@ -1834,7 +1835,7 @@ def walk_ports(self) -> Generator: yield node except nx.NetworkXUnfeasible as error: filename = "AGraph.png" - self.log( + self.log( # pyright: ignore f'A "NetworkX" error occurred, debug graph image has been ' f'saved to "{os.path.join(os.getcwd(), filename)}"!' ) @@ -1856,7 +1857,7 @@ def process(self, **kwargs: Dict) -> None: Examples -------- >>> class NodeAdd(PortNode): - ... def __init__(self, *args, **kwargs): + ... def __init__(self, *args: Any, **kwargs: Any): ... super().__init__(*args, **kwargs) ... ... self.description = ( @@ -2011,7 +2012,7 @@ def value(self) -> Any: """ @value.setter - def value(self, value: Any): + def value(self, value: Any) -> None: """Setter for the **self.value** property.""" @@ -2020,7 +2021,7 @@ class ExecutionNode(PortNode): Define a special node with execution input and output ports. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port( @@ -2034,7 +2035,7 @@ def __init__(self, *args, **kwargs): class ControlFlowNode(ExecutionNode): """Define a class inherited by control flow nodes.""" - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) @@ -2061,7 +2062,7 @@ class For(ControlFlowNode): :class:`colour.utilities.PortGraph` class instance. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port("array", [], "Array to loop onto") @@ -2111,7 +2112,7 @@ def process(self) -> None: _THREADING_LOCK = threading.Lock() -def _task_thread(args): +def _task_thread(args: Sequence) -> tuple[int, Any]: """ Define the default task for the :class:`colour.utilities.ParallelForThread` loop node @@ -2165,7 +2166,7 @@ class ParallelForThread(ControlFlowNode): instead. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port("array", [], "Array to loop onto") @@ -2225,7 +2226,7 @@ def process(self) -> None: self.dirty = False -def _task_multiprocess(args): +def _task_multiprocess(args: Sequence) -> tuple[int, Any]: """ Define the default task for the :class:`colour.utilities.ParallelForMultiprocess` loop node @@ -2272,7 +2273,7 @@ class ParallelForMultiprocess(ControlFlowNode): :class:`colour.utilities.PortGraph` class instance. """ - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port("array", [], "Array to loop onto") diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index 5c11ddd27..3194d167c 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -93,7 +93,7 @@ class Structure(dict): def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - def __setattr__(self, name: str, value: Any): + def __setattr__(self, name: str, value: Any) -> None: """ Assign given value to the attribute with given name. @@ -107,7 +107,7 @@ def __setattr__(self, name: str, value: Any): self[name] = value - def __delattr__(self, name: str): + def __delattr__(self, name: str) -> None: """ Delete the attribute with given name. @@ -155,7 +155,7 @@ def __getattr__(self, name: str) -> Any: except KeyError as error: raise AttributeError(name) from error - def __setstate__(self, state): + def __setstate__(self, state: Any) -> None: """Set the object state when unpickling.""" # See https://github.com/scikit-learn/scikit-learn/issues/6196 for more # information. @@ -340,7 +340,7 @@ def __repr__(self) -> str: else: return f"{self.__class__.__name__}({dict(self.items())})" - def __setitem__(self, item: str | Any, value: Any): + def __setitem__(self, item: str | Any, value: Any) -> None: """ Set given item with given value in the delimiter and case-insensitive :class:`dict`-like object. @@ -396,7 +396,7 @@ def __getitem__(self, item: str | Any) -> Any: return self[dict(zip(self.canonical_keys(), self.keys()))[item]] - def __delitem__(self, item: str | Any): + def __delitem__(self, item: str | Any) -> None: """ Delete given item from the delimiter and case-insensitive :class:`dict`-like object. @@ -545,7 +545,7 @@ def __ne__(self, other: Any) -> bool: return not (self == other) @staticmethod - def _collision_warning(keys: list): + def _collision_warning(keys: list) -> None: """ Issue a runtime warning when given keys are colliding. diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index d6b29e402..e5fdcad14 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -14,7 +14,7 @@ DTYPE_INT_DEFAULT, TOLERANCE_ABSOLUTE_TESTS, ) -from colour.hints import NDArray, Type +from colour.hints import ArrayLike, DType, NDArray, NDArrayFloat, Type from colour.utilities import ( MixinDataclassArithmetic, MixinDataclassArray, @@ -131,7 +131,7 @@ class TestMixinDataclassFields(unittest.TestCase): tests methods. """ - def setUp(self): + def setUp(self) -> None: """Initialise the common tests attributes.""" @dataclass @@ -142,7 +142,7 @@ class Data(MixinDataclassFields): self._data: Data = Data(a="Foo", b="Bar", c="Baz") - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("fields",) @@ -150,7 +150,7 @@ def test_required_attributes(self): for method in required_attributes: assert method in dir(MixinDataclassFields) - def test_fields(self): + def test_fields(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassIterable._fields` method. @@ -165,7 +165,7 @@ class TestMixinDataclassIterable(unittest.TestCase): tests methods. """ - def setUp(self): + def setUp(self) -> None: """Initialise the common tests attributes.""" @dataclass @@ -176,7 +176,7 @@ class Data(MixinDataclassIterable): self._data: Data = Data(a="Foo", b="Bar", c="Baz") - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -188,7 +188,7 @@ def test_required_attributes(self): for method in required_attributes: assert method in dir(MixinDataclassIterable) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__iter__",) @@ -196,7 +196,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MixinDataclassIterable) - def test__iter__(self): + def test__iter__(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassIterable.__iter__` method. @@ -206,7 +206,7 @@ def test__iter__(self): {"a": "Foo", "b": "Bar", "c": "Baz"} ) - def test_keys(self): + def test_keys(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassIterable.keys` method. @@ -214,7 +214,7 @@ def test_keys(self): assert tuple(self._data.keys) == ("a", "b", "c") - def test_values(self): + def test_values(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassIterable.values` method. @@ -222,7 +222,7 @@ def test_values(self): assert tuple(self._data.values) == ("Foo", "Bar", "Baz") - def test_items(self): + def test_items(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassIterable.items` method. @@ -237,7 +237,7 @@ class TestMixinDataclassArray(unittest.TestCase): tests methods. """ - def setUp(self): + def setUp(self) -> None: """Initialise the common tests attributes.""" @dataclass @@ -265,7 +265,7 @@ class Data(MixinDataclassArray): ] ) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__array__",) @@ -273,7 +273,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MixinDataclassArray) - def test__array__(self): + def test__array__(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassArray.__array__` method. @@ -290,7 +290,7 @@ class TestMixinDataclassArithmetic(unittest.TestCase): tests methods. """ - def setUp(self): + def setUp(self) -> None: """Initialise the common tests attributes.""" @dataclass @@ -319,7 +319,7 @@ class Data(MixinDataclassArithmetic): ] ) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -339,7 +339,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MixinDataclassArithmetic) - def test_arithmetical_operation(self): + def test_arithmetical_operation(self) -> None: """ Test :meth:`colour.utilities.array.MixinDataclassArithmetic.\ arithmetical_operation` method. @@ -475,7 +475,7 @@ class TestAsArray(unittest.TestCase): methods. """ - def test_as_array(self): + def test_as_array(self) -> None: """Test :func:`colour.utilities.array.as_array` definition.""" np.testing.assert_equal(as_array([1, 2, 3]), np.array([1, 2, 3])) @@ -495,7 +495,7 @@ class TestAsInt(unittest.TestCase): methods. """ - def test_as_int(self): + def test_as_int(self) -> None: """Test :func:`colour.utilities.array.as_int` definition.""" assert as_int(1) == 1 @@ -519,7 +519,7 @@ class TestAsFloat(unittest.TestCase): methods. """ - def test_as_float(self): + def test_as_float(self) -> None: """Test :func:`colour.utilities.array.as_float` definition.""" assert as_float(1) == 1.0 @@ -545,7 +545,7 @@ class TestAsIntArray(unittest.TestCase): methods. """ - def test_as_int_array(self): + def test_as_int_array(self) -> None: """Test :func:`colour.utilities.array.as_int_array` definition.""" np.testing.assert_equal(as_int_array([1.0, 2.0, 3.0]), np.array([1, 2, 3])) @@ -559,7 +559,7 @@ class TestAsFloatArray(unittest.TestCase): methods. """ - def test_as_float_array(self): + def test_as_float_array(self) -> None: """Test :func:`colour.utilities.array.as_float_array` definition.""" np.testing.assert_equal(as_float_array([1, 2, 3]), np.array([1, 2, 3])) @@ -573,12 +573,12 @@ class TestAsIntScalar(unittest.TestCase): methods. """ - def test_as_int_scalar(self): + def test_as_int_scalar(self) -> None: """Test :func:`colour.utilities.array.as_int_scalar` definition.""" assert as_int_scalar(1.0) == 1 - assert as_int_scalar(1.0).dtype == DTYPE_INT_DEFAULT + assert as_int_scalar(1.0).dtype == DTYPE_INT_DEFAULT # pyright: ignore class TestAsFloatScalar(unittest.TestCase): @@ -587,12 +587,12 @@ class TestAsFloatScalar(unittest.TestCase): tests methods. """ - def test_as_float_scalar(self): + def test_as_float_scalar(self) -> None: """Test :func:`colour.utilities.array.as_float_scalar` definition.""" assert as_float_scalar(1) == 1.0 - assert as_float_scalar(1).dtype == DTYPE_FLOAT_DEFAULT + assert as_float_scalar(1).dtype == DTYPE_FLOAT_DEFAULT # pyright: ignore class TestSetDefaultIntegerDtype(unittest.TestCase): @@ -601,7 +601,7 @@ class TestSetDefaultIntegerDtype(unittest.TestCase): tests methods. """ - def test_set_default_int_dtype(self): + def test_set_default_int_dtype(self) -> None: """ Test :func:`colour.utilities.array.set_default_int_dtype` definition. """ @@ -616,7 +616,7 @@ def test_set_default_int_dtype(self): assert as_int_array(np.ones(3)).dtype == np.int64 - def tearDown(self): + def tearDown(self) -> None: """After tests actions.""" set_default_int_dtype(np.int64) @@ -628,7 +628,7 @@ class TestSetDefaultFloatDtype(unittest.TestCase): tests methods. """ - def test_set_default_float_dtype(self): + def test_set_default_float_dtype(self) -> None: """ Test :func:`colour.utilities.array.set_default_float_dtype` definition. @@ -647,7 +647,7 @@ def test_set_default_float_dtype(self): finally: set_default_float_dtype(np.float64) - def test_set_default_float_dtype_enforcement(self): + def test_set_default_float_dtype_enforcement(self) -> None: """ Test whether :func:`colour.utilities.array.set_default_float_dtype` effect is applied through most of *Colour* public API. @@ -728,7 +728,7 @@ def test_set_default_float_dtype_enforcement(self): ): a = np.array([(0.25, 0.5), (0.25, 0.5)]) - def dtype_getter(x): + def dtype_getter(x: NDArray) -> DType: """Dtype getter callable.""" for specification in ( @@ -744,9 +744,9 @@ def dtype_getter(x): "ZCAM", ): if target.endswith(specification): # noqa: B023 - return getattr(x, fields(x)[0].name).dtype + return getattr(x, fields(x)[0].name).dtype # pyright: ignore - return x.dtype + return x.dtype # pyright: ignore assert dtype_getter(convert(a, source, target)) == dtype finally: @@ -759,7 +759,7 @@ class TestGetDomainRangeScale(unittest.TestCase): unit tests methods. """ - def test_get_domain_range_scale(self): + def test_get_domain_range_scale(self) -> None: """ Test :func:`colour.utilities.common.get_domain_range_scale` definition. @@ -781,7 +781,7 @@ class TestSetDomainRangeScale(unittest.TestCase): unit tests methods. """ - def test_set_domain_range_scale(self): + def test_set_domain_range_scale(self) -> None: """ Test :func:`colour.utilities.common.set_domain_range_scale` definition. @@ -809,7 +809,7 @@ class TestDomainRangeScale(unittest.TestCase): unit tests methods. """ - def test_domain_range_scale(self): + def test_domain_range_scale(self) -> None: """ Test :func:`colour.utilities.common.domain_range_scale` definition. @@ -832,7 +832,7 @@ def test_domain_range_scale(self): assert get_domain_range_scale() == "reference" - def fn_a(a): + def fn_a(a: ArrayLike) -> NDArrayFloat: """Change the domain-range scale for unit testing.""" b = to_domain_10(a) @@ -860,7 +860,7 @@ def fn_a(a): assert get_domain_range_scale() == "reference" @domain_range_scale("1") - def fn_b(a): + def fn_b(a: ArrayLike) -> NDArrayFloat: """Change the domain-range scale for unit testing.""" b = to_domain_10(a) @@ -878,7 +878,7 @@ class TestToDomain1(unittest.TestCase): tests methods. """ - def test_to_domain_1(self): + def test_to_domain_1(self) -> None: """Test :func:`colour.utilities.common.to_domain_1` definition.""" with domain_range_scale("Reference"): @@ -903,7 +903,7 @@ class TestToDomain10(unittest.TestCase): tests methods. """ - def test_to_domain_10(self): + def test_to_domain_10(self) -> None: """Test :func:`colour.utilities.common.to_domain_10` definition.""" with domain_range_scale("Reference"): @@ -928,7 +928,7 @@ class TestToDomain100(unittest.TestCase): tests methods. """ - def test_to_domain_100(self): + def test_to_domain_100(self) -> None: """Test :func:`colour.utilities.common.to_domain_100` definition.""" with domain_range_scale("Reference"): @@ -953,7 +953,7 @@ class TestToDomainDegrees(unittest.TestCase): tests methods. """ - def test_to_domain_degrees(self): + def test_to_domain_degrees(self) -> None: """Test :func:`colour.utilities.common.to_domain_degrees` definition.""" with domain_range_scale("Reference"): @@ -978,7 +978,7 @@ class TestToDomainInt(unittest.TestCase): tests methods. """ - def test_to_domain_int(self): + def test_to_domain_int(self) -> None: """Test :func:`colour.utilities.common.to_domain_int` definition.""" with domain_range_scale("Reference"): @@ -1003,7 +1003,7 @@ class TestFromRange1(unittest.TestCase): tests methods. """ - def test_from_range_1(self): + def test_from_range_1(self) -> None: """Test :func:`colour.utilities.common.from_range_1` definition.""" with domain_range_scale("Reference"): @@ -1025,7 +1025,7 @@ class TestFromRange10(unittest.TestCase): tests methods. """ - def test_from_range_10(self): + def test_from_range_10(self) -> None: """Test :func:`colour.utilities.common.from_range_10` definition.""" with domain_range_scale("Reference"): @@ -1047,7 +1047,7 @@ class TestFromRange100(unittest.TestCase): tests methods. """ - def test_from_range_100(self): + def test_from_range_100(self) -> None: """Test :func:`colour.utilities.common.from_range_100` definition.""" with domain_range_scale("Reference"): @@ -1069,7 +1069,7 @@ class TestFromRangeDegrees(unittest.TestCase): tests methods. """ - def test_from_range_degrees(self): + def test_from_range_degrees(self) -> None: """Test :func:`colour.utilities.common.from_range_degrees` definition.""" with domain_range_scale("Reference"): @@ -1091,7 +1091,7 @@ class TestFromRangeInt(unittest.TestCase): tests methods. """ - def test_from_range_int(self): + def test_from_range_int(self) -> None: """Test :func:`colour.utilities.common.from_range_int` definition.""" with domain_range_scale("Reference"): @@ -1116,7 +1116,7 @@ class TestIsNdarrayCopyEnabled(unittest.TestCase): unit tests methods. """ - def test_is_ndarray_copy_enabled(self): + def test_is_ndarray_copy_enabled(self) -> None: """ Test :func:`colour.utilities.array.is_ndarray_copy_enabled` definition. """ @@ -1134,7 +1134,7 @@ class TestSetNdarrayCopyEnabled(unittest.TestCase): unit tests methods. """ - def test_set_ndarray_copy_enable(self): + def test_set_ndarray_copy_enable(self) -> None: """ Test :func:`colour.utilities.array.set_ndarray_copy_enable` definition. """ @@ -1154,7 +1154,7 @@ class TestNdarrayCopyEnable(unittest.TestCase): tests methods. """ - def test_ndarray_copy_enable(self): + def test_ndarray_copy_enable(self) -> None: """ Test :func:`colour.utilities.array.ndarray_copy_enable` definition. """ @@ -1166,7 +1166,7 @@ def test_ndarray_copy_enable(self): assert not is_ndarray_copy_enabled() @ndarray_copy_enable(True) - def fn_a(): + def fn_a() -> None: """:func:`ndarray_copy_enable` unit tests :func:`fn_a` definition.""" assert is_ndarray_copy_enabled() @@ -1174,7 +1174,7 @@ def fn_a(): fn_a() @ndarray_copy_enable(False) - def fn_b(): + def fn_b() -> None: """:func:`ndarray_copy_enable` unit tests :func:`fn_b` definition.""" assert not is_ndarray_copy_enabled() @@ -1188,7 +1188,7 @@ class TestNdarrayCopy(unittest.TestCase): tests methods. """ - def test_ndarray_copy(self): + def test_ndarray_copy(self) -> None: """Test :func:`colour.utilities.array.ndarray_copy` definition.""" a = np.linspace(0, 1, 10) @@ -1205,7 +1205,7 @@ class TestClosestIndexes(unittest.TestCase): tests methods. """ - def test_closest_indexes(self): + def test_closest_indexes(self) -> None: """Test :func:`colour.utilities.array.closest_indexes` definition.""" a = np.array( @@ -1237,7 +1237,7 @@ class TestClosest(unittest.TestCase): methods. """ - def test_closest(self): + def test_closest(self) -> None: """Test :func:`colour.utilities.array.closest` definition.""" a = np.array( @@ -1270,7 +1270,7 @@ class TestInterval(unittest.TestCase): methods. """ - def test_interval(self): + def test_interval(self) -> None: """Test :func:`colour.utilities.array.interval` definition.""" np.testing.assert_array_equal(interval(range(0, 10, 2)), np.array([2])) @@ -1298,7 +1298,7 @@ class TestIsUniform(unittest.TestCase): methods. """ - def test_is_uniform(self): + def test_is_uniform(self) -> None: """Test :func:`colour.utilities.array.is_uniform` definition.""" assert is_uniform(range(0, 10, 2)) @@ -1312,7 +1312,7 @@ class TestInArray(unittest.TestCase): methods. """ - def test_in_array(self): + def test_in_array(self) -> None: """Test :func:`colour.utilities.array.in_array` definition.""" assert np.array_equal( @@ -1330,7 +1330,7 @@ def test_in_array(self): np.array([[True], [True]]), ) - def test_n_dimensional_in_array(self): + def test_n_dimensional_in_array(self) -> None: """ Test :func:`colour.utilities.array.in_array` definition n-dimensional support. @@ -1358,7 +1358,7 @@ class TestTstack(unittest.TestCase): methods. """ - def test_tstack(self): + def test_tstack(self) -> None: """Test :func:`colour.utilities.array.tstack` definition.""" a = 0 @@ -1443,7 +1443,7 @@ class TestTsplit(unittest.TestCase): methods. """ - def test_tsplit(self): + def test_tsplit(self) -> None: """Test :func:`colour.utilities.array.tsplit` definition.""" a = np.array([0, 0, 0]) @@ -1565,7 +1565,7 @@ class TestRowAsDiagonal(unittest.TestCase): tests methods. """ - def test_row_as_diagonal(self): + def test_row_as_diagonal(self) -> None: """Test :func:`colour.utilities.array.row_as_diagonal` definition.""" np.testing.assert_allclose( @@ -1619,7 +1619,7 @@ class TestOrient(unittest.TestCase): methods. """ - def test_orient(self): + def test_orient(self) -> None: """Test :func:`colour.utilities.array.orient` definition.""" a = np.tile(np.arange(5), (5, 1)) @@ -1698,7 +1698,7 @@ class TestCentroid(unittest.TestCase): methods. """ - def test_centroid(self): + def test_centroid(self) -> None: """Test :func:`colour.utilities.array.centroid` definition.""" a = np.arange(5) @@ -1720,7 +1720,7 @@ class TestFillNan(unittest.TestCase): methods. """ - def test_fill_nan(self): + def test_fill_nan(self) -> None: """Test :func:`colour.utilities.array.fill_nan` definition.""" a = np.array([0.1, 0.2, np.nan, 0.4, 0.5]) @@ -1743,14 +1743,14 @@ class TestHasNanOnly(unittest.TestCase): methods. """ - def test_has_only_nan(self): + def test_has_only_nan(self) -> None: """Test :func:`colour.utilities.array.has_only_nan` definition.""" - assert has_only_nan(None) + assert has_only_nan(None) # pyright: ignore - assert has_only_nan([None, None]) + assert has_only_nan([None, None]) # pyright: ignore - assert not has_only_nan([True, None]) + assert not has_only_nan([True, None]) # pyright: ignore assert not has_only_nan([0.1, np.nan, 0.3]) @@ -1761,7 +1761,7 @@ class TestNdarrayWrite(unittest.TestCase): methods. """ - def test_ndarray_write(self): + def test_ndarray_write(self) -> None: """Test :func:`colour.utilities.array.ndarray_write` definition.""" a = np.linspace(0, 1, 10) @@ -1780,7 +1780,7 @@ class TestZeros(unittest.TestCase): methods. """ - def test_zeros(self): + def test_zeros(self) -> None: """Test :func:`colour.utilities.array.zeros` definition.""" np.testing.assert_equal(zeros(3), np.zeros(3)) @@ -1792,7 +1792,7 @@ class TestOnes(unittest.TestCase): methods. """ - def test_ones(self): + def test_ones(self) -> None: """Test :func:`colour.utilities.array.ones` definition.""" np.testing.assert_equal(ones(3), np.ones(3)) @@ -1804,7 +1804,7 @@ class TestFull(unittest.TestCase): methods. """ - def test_full(self): + def test_full(self) -> None: """Test :func:`colour.utilities.array.full` definition.""" np.testing.assert_equal(full(3, 0.5), np.full(3, 0.5)) @@ -1816,7 +1816,7 @@ class TestIndexAlongLastAxis(unittest.TestCase): unit tests methods. """ - def test_index_along_last_axis(self): + def test_index_along_last_axis(self) -> None: """Test :func:`colour.utilities.array.index_along_last_axis` definition.""" a = np.array( [ @@ -1866,7 +1866,7 @@ def test_index_along_last_axis(self): ), ) - def test_compare_with_argmin_argmax(self): + def test_compare_with_argmin_argmax(self) -> None: """ Test :func:`colour.utilities.array.index_along_last_axis` definition by comparison with :func:`argmin` and :func:`argmax`. @@ -1882,7 +1882,7 @@ def test_compare_with_argmin_argmax(self): index_along_last_axis(a, np.argmax(a, axis=-1)), np.max(a, axis=-1) ) - def test_exceptions(self): + def test_exceptions(self) -> None: """ Test :func:`colour.utilities.array.index_along_last_axis` definition handling of invalid inputs. @@ -1912,7 +1912,7 @@ class TestFormatArrayAsRow(unittest.TestCase): tests methods. """ - def test_format_array_as_row(self): + def test_format_array_as_row(self) -> None: """Test :func:`colour.utilities.array.format_array_as_row` definition.""" assert format_array_as_row([1.25, 2.5, 3.75]) == "1.2500000 2.5000000 3.7500000" diff --git a/colour/utilities/tests/test_callback.py b/colour/utilities/tests/test_callback.py index 9fde9a0ad..dba6a2f15 100644 --- a/colour/utilities/tests/test_callback.py +++ b/colour/utilities/tests/test_callback.py @@ -22,20 +22,22 @@ class TestMixinCallback: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" class WithCallback(MixinCallback): """Test :class:`MixinCallback` class.""" - def __init__(self): + def __init__(self) -> None: super().__init__() self.attribute_a = "a" self._with_callback = WithCallback() - def _on_attribute_a_changed(self, name: str, value: str) -> str: + def _on_attribute_a_changed( + self: TestMixinCallback, name: str, value: str + ) -> str: """Transform *self._attribute_a* to uppercase.""" value = value.upper() @@ -49,7 +51,7 @@ def _on_attribute_a_changed(self, name: str, value: str) -> str: self._on_attribute_a_changed = _on_attribute_a_changed - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("callbacks",) @@ -57,7 +59,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(MixinCallback) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -69,7 +71,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(MixinCallback) - def test_register_callback(self): + def test_register_callback(self) -> None: """ Test :class:`colour.utilities.callback.MixinCallback.register_callback` method. @@ -85,7 +87,7 @@ def test_register_callback(self): assert self._with_callback.attribute_a == "A" assert len(self._with_callback.callbacks) == 1 - def test_unregister_callback(self): + def test_unregister_callback(self) -> None: """ Test :class:`colour.utilities.callback.MixinCallback.unregister_callback` method. diff --git a/colour/utilities/tests/test_common.py b/colour/utilities/tests/test_common.py index 04038ffb6..eec5be2ee 100644 --- a/colour/utilities/tests/test_common.py +++ b/colour/utilities/tests/test_common.py @@ -65,7 +65,7 @@ class TestIsCachingEnabled: tests methods. """ - def test_is_caching_enabled(self): + def test_is_caching_enabled(self) -> None: """Test :func:`colour.utilities.common.is_caching_enabled` definition.""" with caching_enable(True): @@ -81,7 +81,7 @@ class TestSetCachingEnabled: tests methods. """ - def test_set_caching_enable(self): + def test_set_caching_enable(self) -> None: """Test :func:`colour.utilities.common.set_caching_enable` definition.""" with caching_enable(is_caching_enabled()): @@ -99,7 +99,7 @@ class TestCachingEnable: tests methods. """ - def test_caching_enable(self): + def test_caching_enable(self) -> None: """Test :func:`colour.utilities.common.caching_enable` definition.""" with caching_enable(True): @@ -109,7 +109,7 @@ def test_caching_enable(self): assert not is_caching_enabled() @caching_enable(True) - def fn_a(): + def fn_a() -> None: """:func:`caching_enable` unit tests :func:`fn_a` definition.""" assert is_caching_enabled() @@ -117,7 +117,7 @@ def fn_a(): fn_a() @caching_enable(False) - def fn_b(): + def fn_b() -> None: """:func:`caching_enable` unit tests :func:`fn_b` definition.""" assert not is_caching_enabled() @@ -132,7 +132,7 @@ class TestCacheRegistry: """ @staticmethod - def _default_test_cache_registry(): + def _default_test_cache_registry() -> CacheRegistry: """Create a default test cache registry.""" cache_registry = CacheRegistry() @@ -144,7 +144,7 @@ def _default_test_cache_registry(): return cache_registry - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("registry",) @@ -152,7 +152,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(CacheRegistry) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -167,13 +167,13 @@ def test_required_methods(self): for method in required_methods: assert method in dir(CacheRegistry) - def test__str__(self): + def test__str__(self) -> None: """Test :class:`colour.utilities.common.CacheRegistry.__str__` method.""" cache_registry = self._default_test_cache_registry() assert str(cache_registry) == "{'Cache A': '1 item(s)', 'Cache B': '2 item(s)'}" - def test_register_cache(self): + def test_register_cache(self) -> None: """ Test :class:`colour.utilities.common.CacheRegistry.register_cache` method. @@ -185,7 +185,7 @@ def test_register_cache(self): cache_b = cache_registry.register_cache("Cache B") assert cache_registry.registry == {"Cache A": cache_a, "Cache B": cache_b} - def test_unregister_cache(self): + def test_unregister_cache(self) -> None: """ Test :class:`colour.utilities.common.CacheRegistry.unregister_cache` method. @@ -196,7 +196,7 @@ def test_unregister_cache(self): assert "Cache A" not in cache_registry.registry assert "Cache B" in cache_registry.registry - def test_clear_cache(self): + def test_clear_cache(self) -> None: """ Test :class:`colour.utilities.common.CacheRegistry.clear_cache` method. @@ -209,7 +209,7 @@ def test_clear_cache(self): "Cache B": {"John": "Doe", "Luke": "Skywalker"}, } - def test_clear_all_caches(self): + def test_clear_all_caches(self) -> None: """ Test :class:`colour.utilities.common.CacheRegistry.clear_all_caches` method. @@ -226,7 +226,7 @@ class TestAttest: tests methods. """ - def test_attest(self): + def test_attest(self) -> None: """Test :func:`colour.utilities.common.attest` definition.""" assert attest(True, "") is None @@ -240,7 +240,7 @@ class TestBatch: methods. """ - def test_batch(self): + def test_batch(self) -> None: """Test :func:`colour.utilities.common.batch` definition.""" assert list(batch(tuple(range(10)), 3)) == [ @@ -266,7 +266,7 @@ def test_batch(self): ] -def _add(a: Real, b: Real): +def _add(a: Real, b: Real) -> Real: """ Add two numbers. @@ -297,7 +297,7 @@ class TestMultiprocessingPool: unit tests methods. """ - def test_multiprocessing_pool(self): + def test_multiprocessing_pool(self) -> None: """Test :func:`colour.utilities.common.multiprocessing_pool` definition.""" with multiprocessing_pool() as pool: @@ -321,7 +321,7 @@ class TestIsIterable: methods. """ - def test_is_iterable(self): + def test_is_iterable(self) -> None: """Test :func:`colour.utilities.common.is_iterable` definition.""" assert is_iterable("") @@ -351,7 +351,7 @@ class TestIsNumeric: methods. """ - def test_is_numeric(self): + def test_is_numeric(self) -> None: """Test :func:`colour.utilities.common.is_numeric` definition.""" assert is_numeric(1) @@ -371,7 +371,7 @@ class TestIsInteger: tests methods. """ - def test_is_integer(self): + def test_is_integer(self) -> None: """Test :func:`colour.utilities.common.is_integer` definition.""" assert is_integer(1) @@ -387,7 +387,7 @@ class TestIsSibling: methods. """ - def test_is_sibling(self): + def test_is_sibling(self) -> None: """Test :func:`colour.utilities.common.is_sibling` definition.""" class Element: @@ -419,7 +419,7 @@ class TestFilterKwargs: tests methods. """ - def test_filter_kwargs(self): + def test_filter_kwargs(self) -> None: """Test :func:`colour.utilities.common.filter_kwargs` definition.""" def fn_a(a: Any) -> Any: @@ -452,7 +452,7 @@ class TestFilterMapping: tests methods. """ - def test_filter_mapping(self): + def test_filter_mapping(self) -> None: """Test :func:`colour.utilities.common.filter_mapping` definition.""" class Element: @@ -494,7 +494,7 @@ class TestFirstItem: tests methods. """ - def test_first_item(self): + def test_first_item(self) -> None: """Test :func:`colour.utilities.common.first_item` definition.""" assert first_item(range(10)) == 0 @@ -511,7 +511,7 @@ class TestValidateMethod: tests methods. """ - def test_validate_method(self): + def test_validate_method(self) -> None: """Test :func:`colour.utilities.common.validate_method` definition.""" assert validate_method("Valid", ("Valid", "Yes", "Ok")) == "valid" @@ -520,7 +520,7 @@ def test_validate_method(self): == "Valid" ) - def test_raise_exception_validate_method(self): + def test_raise_exception_validate_method(self) -> None: """ Test :func:`colour.utilities.common.validate_method` definition raised exception. @@ -535,7 +535,7 @@ class TestOptional: tests methods. """ - def test_optional(self): + def test_optional(self) -> None: """Test :func:`colour.utilities.common.optional` definition.""" assert optional("Foo", "Bar") == "Foo" @@ -549,7 +549,7 @@ class TestSlugify: methods. """ - def test_slugify(self): + def test_slugify(self) -> None: """Test :func:`colour.utilities.common.slugify` definition.""" assert ( @@ -584,7 +584,7 @@ class TestIntDigest: methods. """ - def test_int_digest(self): + def test_int_digest(self) -> None: """Test :func:`colour.utilities.common.int_digest` definition.""" assert int_digest("Foo") == 7467386374397815550 diff --git a/colour/utilities/tests/test_deprecated.py b/colour/utilities/tests/test_deprecated.py index 88c1b4819..6101abd6d 100644 --- a/colour/utilities/tests/test_deprecated.py +++ b/colour/utilities/tests/test_deprecated.py @@ -1,5 +1,7 @@ """Define the unit tests helper module for the deprecation management.""" +from __future__ import annotations + import contextlib import sys @@ -14,7 +16,7 @@ class deprecated(ModuleAPI): """Define a class acting like the *deprecated* module.""" - def __getattr__(self, attribute) -> Any: + def __getattr__(self, attribute: str) -> Any: """Return the value from the attribute with given name.""" return super().__getattr__(attribute) diff --git a/colour/utilities/tests/test_deprecation.py b/colour/utilities/tests/test_deprecation.py index 4e88eca40..5871becb1 100644 --- a/colour/utilities/tests/test_deprecation.py +++ b/colour/utilities/tests/test_deprecation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.utilities.deprecation` module.""" +from __future__ import annotations + import sys import pytest @@ -53,7 +55,7 @@ class TestObjectRenamed: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -61,7 +63,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectRenamed) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ObjectRenamed.__str__` method. @@ -77,7 +79,7 @@ class TestObjectRemoved: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -85,7 +87,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectRemoved) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ObjectRemoved.__str__` method. @@ -100,7 +102,7 @@ class TestObjectFutureRename: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -108,7 +110,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectFutureRename) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ObjectFutureRename.__str__` method. @@ -124,7 +126,7 @@ class TestObjectFutureRemove: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -132,7 +134,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectFutureRemove) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ObjectFutureRemove.__str__` method. @@ -151,7 +153,7 @@ class TestObjectFutureAccessChange: class unit tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -159,7 +161,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectFutureAccessChange) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.\ ObjectFutureAccessChange.__str__` method. @@ -175,7 +177,7 @@ class TestObjectFutureAccessRemove: class unit tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -183,7 +185,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ObjectFutureAccessRemove) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.\ ObjectFutureAccessRemove.__str__` method. @@ -202,7 +204,7 @@ class TestArgumentRenamed: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -210,7 +212,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ArgumentRenamed) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ArgumentRenamed.__str__` method. @@ -226,7 +228,7 @@ class TestArgumentRemoved: tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -234,7 +236,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ArgumentRemoved) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ArgumentRemoved.__str__` method. @@ -249,7 +251,7 @@ class TestArgumentFutureRename: unit tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -257,7 +259,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ArgumentFutureRename) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.\ ArgumentFutureRename.__str__` method. @@ -273,7 +275,7 @@ class TestArgumentFutureRemove: unit tests methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__str__",) @@ -281,7 +283,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ArgumentFutureRemove) - def test__str__(self): + def test__str__(self) -> None: """ Test :meth:`colour.utilities.deprecation.\ ArgumentFutureRemove.__str__` method. @@ -300,7 +302,7 @@ class TestModuleAPI: methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__init__", "__getattr__", "__dir__") @@ -308,7 +310,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(ModuleAPI) - def test__getattr__(self): + def test__getattr__(self) -> None: """ Test :meth:`colour.utilities.deprecation.ModuleAPI.__getattr__` method. @@ -318,16 +320,16 @@ def test__getattr__(self): assert colour.utilities.tests.test_deprecated.NAME is None - def assert_warns(): + def assert_warns() -> None: """Help to test the runtime warning.""" - colour.utilities.tests.test_deprecated.OLD_NAME # noqa: B018 + colour.utilities.tests.test_deprecated.OLD_NAME # noqa: B018 # pyright: ignore pytest.warns(ColourUsageWarning, assert_warns) del sys.modules["colour.utilities.tests.test_deprecated"] - def test_raise_exception__getattr__(self): + def test_raise_exception__getattr__(self) -> None: """ Test :func:`colour.utilities.deprecation.ModuleAPI.__getattr__` method raised exception. @@ -351,7 +353,7 @@ class TestGetAttribute: tests methods. """ - def test_get_attribute(self): + def test_get_attribute(self) -> None: """Test :func:`colour.utilities.deprecation.get_attribute` definition.""" from colour import adaptation @@ -383,7 +385,7 @@ class TestBuildAPIChanges: unit tests methods. """ - def test_build_API_changes(self): + def test_build_API_changes(self) -> None: """ Test :func:`colour.utilities.deprecation.build_API_changes` definition. @@ -449,7 +451,7 @@ class TestHandleArgumentsDeprecation: definition unit tests methods. """ - def test_handle_arguments_deprecation(self): + def test_handle_arguments_deprecation(self) -> None: """ Test :func:`colour.utilities.deprecation.handle_arguments_deprecation` definition. diff --git a/colour/utilities/tests/test_documentation.py b/colour/utilities/tests/test_documentation.py index ca0e08c2a..5256d62fe 100644 --- a/colour/utilities/tests/test_documentation.py +++ b/colour/utilities/tests/test_documentation.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.utilities.documentation` module.""" +from __future__ import annotations + import os from colour.utilities.documentation import is_documentation_building @@ -22,7 +24,7 @@ class TestIsDocumentationBuilding: definition unit tests methods. """ - def test_is_documentation_building(self): + def test_is_documentation_building(self) -> None: """ Test :func:`colour.utilities.documentation.is_documentation_building` definition. diff --git a/colour/utilities/tests/test_metrics.py b/colour/utilities/tests/test_metrics.py index e2b575967..48ac77ee6 100644 --- a/colour/utilities/tests/test_metrics.py +++ b/colour/utilities/tests/test_metrics.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.utilities.metrics` module.""" +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -24,7 +26,7 @@ class TestMetricMse: methods. """ - def test_metric_mse(self): + def test_metric_mse(self) -> None: """Test :func:`colour.utilities.metrics.metric_mse` definition.""" a = np.array([0.48222001, 0.31654775, 0.22070353]) @@ -51,7 +53,7 @@ class TestMetricPsnr: methods. """ - def test_metric_psnr(self): + def test_metric_psnr(self) -> None: """Test :func:`colour.utilities.metrics.metric_psnr` definition.""" a = np.array([0.48222001, 0.31654775, 0.22070353]) diff --git a/colour/utilities/tests/test_network.py b/colour/utilities/tests/test_network.py index 72b911de9..2586dfc05 100644 --- a/colour/utilities/tests/test_network.py +++ b/colour/utilities/tests/test_network.py @@ -1,9 +1,12 @@ """Define the unit tests for the :mod:`colour.utilities.network` module.""" +from __future__ import annotations + import re import numpy as np +from colour.hints import Any from colour.utilities import ( ExecutionNode, For, @@ -40,7 +43,7 @@ class TestTreeNode: methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._data = {"John": "Doe"} @@ -56,7 +59,7 @@ def setup_method(self): self._tree = self._node_a - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -73,7 +76,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(TreeNode) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -91,29 +94,29 @@ def test_required_methods(self): for method in required_methods: assert method in dir(TreeNode) - def test_name(self): + def test_name(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.name` property.""" assert self._tree.name == "Node A" assert "Node#" in TreeNode().name - def test_parent(self): + def test_parent(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.parent` property.""" assert self._node_b.parent is self._node_a assert self._node_h.parent is self._node_g - def test_children(self): + def test_children(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.children` property.""" assert self._node_a.children == [self._node_b, self._node_c] - def test_id(self): + def test_id(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.id` property.""" assert isinstance(self._node_a.id, int) - def test_root(self): + def test_root(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.root` property.""" assert self._node_a.root is self._node_a @@ -121,37 +124,37 @@ def test_root(self): assert self._node_g.root is self._node_a assert self._node_h.root is self._node_a - def test_leaves(self): + def test_leaves(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.leaves` property.""" assert list(self._node_h.leaves) == [self._node_h] assert list(self._node_a.leaves) == [self._node_h, self._node_e, self._node_c] - def test_siblings(self): + def test_siblings(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.siblings` property.""" assert list(self._node_a.siblings) == [] assert list(self._node_b.siblings) == [self._node_c] - def test_data(self): + def test_data(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.data` property.""" assert self._node_a.data is self._data - def test__str__(self): + def test__str__(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.__str__` method.""" assert "TreeNode#" in str(self._node_a) assert "{'John': 'Doe'})" in str(self._node_a) - def test__len__(self): + def test__len__(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.__len__` method.""" assert len(self._node_a) == 7 - def test_is_root(self): + def test_is_root(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.is_root` method.""" assert self._node_a.is_root() @@ -159,7 +162,7 @@ def test_is_root(self): assert not self._node_c.is_root() assert not self._node_h.is_root() - def test_is_inner(self): + def test_is_inner(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.is_inner` method.""" assert not self._node_a.is_inner() @@ -167,7 +170,7 @@ def test_is_inner(self): assert not self._node_c.is_inner() assert not self._node_h.is_inner() - def test_is_leaf(self): + def test_is_leaf(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.is_leaf` method.""" assert not self._node_a.is_leaf() @@ -175,7 +178,7 @@ def test_is_leaf(self): assert self._node_c.is_leaf() assert self._node_h.is_leaf() - def test_walk_hierarchy(self): + def test_walk_hierarchy(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.walk_hierarchy` method.""" assert list(self._node_a.walk_hierarchy()) == [ @@ -196,7 +199,7 @@ def test_walk_hierarchy(self): self._node_a, ] - def test_render(self): + def test_render(self) -> None: """Test :attr:`colour.utilities.network.TreeNode.render` method.""" assert isinstance(self._node_a.render(), str) @@ -207,9 +210,7 @@ class TestPort: Define :class:`colour.utilities.network.Port` class unit tests methods. """ - def setup_method(self): - """Initialise the common tests attributes.""" - + def __init__(self) -> None: class Node(PortNode): ... self._node_a = Node("Node A") @@ -235,7 +236,12 @@ class Node(PortNode): ... self._port_output_node_b, ] - def test_required_attributes(self): + def setup_method(self) -> None: + """Initialise the common tests attributes.""" + + self.__init__() + + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -249,7 +255,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(Port) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -265,7 +271,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Port) - def test_name(self): + def test_name(self) -> None: """Test :attr:`colour.utilities.network.Port.name` property.""" assert self._port_a_node_a.name == "a" @@ -275,7 +281,7 @@ def test_name(self): assert self._port_b_node_b.name == "b" assert self._port_output_node_b.name == "output" - def test_value(self): + def test_value(self) -> None: """Test :attr:`colour.utilities.network.Port.value` property.""" assert self._port_a_node_a.value == 1 @@ -289,13 +295,17 @@ def test_value(self): self._port_output_node_a.connect(self._port_b_node_b) self._port_output_node_a.value = 2 + assert self._port_output_node_a.node is not None assert self._port_output_node_a.node.dirty is True + assert self._port_a_node_b.node is not None assert self._port_a_node_b.node.dirty is True assert self._port_a_node_b.value == 2 assert self._port_b_node_b.value == 2 self._port_a_node_b.value = 3 + assert self._port_a_node_b.node is not None assert self._port_a_node_b.node.dirty is True + assert self._port_output_node_a.node is not None assert self._port_output_node_a.node.dirty is True assert self._port_output_node_a.value == 3 assert self._port_b_node_b.value == 3 @@ -304,6 +314,7 @@ def test_value(self): self._port_output_node_a.value = 2 self._port_output_node_a.node.process() + assert self._port_output_node_a.node is not None assert self._port_output_node_a.node.dirty is False assert self._port_a_node_b.node.dirty is True assert self._port_a_node_b.value == 3 @@ -311,7 +322,7 @@ def test_value(self): self._port_output_node_a.disconnect(self._port_b_node_b) - def test_description(self): + def test_description(self) -> None: """Test :attr:`colour.utilities.network.Port.description` property.""" assert self._port_a_node_a.description == "Port A" @@ -321,7 +332,7 @@ def test_description(self): assert self._port_b_node_b.description is None assert self._port_output_node_b.description == "Output" - def test_node(self): + def test_node(self) -> None: """Test :attr:`colour.utilities.network.Port.node` property.""" assert self._port_a_node_a.node is self._node_a @@ -331,7 +342,7 @@ def test_node(self): assert port.node is None - def test_connections(self): + def test_connections(self) -> None: """Test :attr:`colour.utilities.network.Port.connections` property.""" for port in self._ports: @@ -350,7 +361,7 @@ def test_connections(self): for port in self._ports: assert len(port.connections) == 0 - def test___str__(self): + def test___str__(self) -> None: """Test :meth:`colour.utilities.network.Port.__str__` method.""" assert str(self._port_a_node_a) == "Node A.a (<- [])" @@ -378,7 +389,7 @@ def test___str__(self): self._port_output_node_a.disconnect(self._port_a_node_b) self._port_output_node_a.disconnect(self._port_b_node_b) - def test_is_input_port(self): + def test_is_input_port(self) -> None: """Test :meth:`colour.utilities.network.Port.is_input_port` method.""" assert self._port_a_node_a.is_input_port() is True @@ -389,7 +400,7 @@ def test_is_input_port(self): assert self._port_b_node_b.is_input_port() is True assert self._port_output_node_b.is_input_port() is False - def test_is_output_port(self): + def test_is_output_port(self) -> None: """Test :meth:`colour.utilities.network.Port.is_output_port` method.""" assert self._port_a_node_a.is_output_port() is False @@ -400,17 +411,17 @@ def test_is_output_port(self): assert self._port_b_node_b.is_output_port() is False assert self._port_output_node_b.is_output_port() is True - def test_connect(self): + def test_connect(self) -> None: """Test :meth:`colour.utilities.network.Port.connect` method.""" self.test_connections() - def test_disconnect(self): + def test_disconnect(self) -> None: """Test :meth:`colour.utilities.network.Port.disconnect` method.""" self.test_connections() - def test_to_graphviz(self): + def test_to_graphviz(self) -> None: """Test :meth:`colour.utilities.network.Port.test_to_graphviz` method.""" assert self._port_a_node_a.to_graphviz() == " a" @@ -423,7 +434,7 @@ def test_to_graphviz(self): class _NodeAdd(ExecutionNode): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.description = "Perform the addition of the two input port values." @@ -432,7 +443,7 @@ def __init__(self, *args, **kwargs): self.add_input_port("b") self.add_output_port("output") - def process(self): + def process(self) -> None: a = self.get_input("a") b = self.get_input("b") @@ -445,7 +456,7 @@ def process(self): class _NodeMultiply(ExecutionNode): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.description = "Perform the multiplication of the two input port values." @@ -454,7 +465,7 @@ def __init__(self, *args, **kwargs): self.add_input_port("b") self.add_output_port("output") - def process(self): + def process(self) -> None: a = self.get_input("a") b = self.get_input("b") @@ -471,7 +482,7 @@ class TestPortNode: Define :class:`colour.utilities.network.PortNode` class unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._add_node_1 = _NodeAdd("Node Add 1") @@ -480,7 +491,7 @@ def setup_method(self): self._nodes = [self._add_node_1, self._multiply_node_1, self._add_node_2] - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ( @@ -494,7 +505,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(PortNode) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -516,7 +527,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(PortNode) - def test_input_ports(self): + def test_input_ports(self) -> None: """Test :attr:`colour.utilities.network.PortNode.input_ports` property.""" for name in ("a", "b"): @@ -524,7 +535,7 @@ def test_input_ports(self): assert name in self._multiply_node_1.input_ports assert name in self._add_node_2.input_ports - def test_output_ports(self): + def test_output_ports(self) -> None: """Test :attr:`colour.utilities.network.PortNode.output_ports` property.""" for name in ("output",): @@ -532,7 +543,7 @@ def test_output_ports(self): assert name in self._multiply_node_1.output_ports assert name in self._add_node_2.output_ports - def test_dirty(self): + def test_dirty(self) -> None: """Test :attr:`colour.utilities.network.PortNode.dirty` property.""" assert self._add_node_1.dirty is True @@ -573,7 +584,7 @@ def test_dirty(self): assert self._multiply_node_1.dirty is True assert self._add_node_2.dirty is True - def test_edges(self): + def test_edges(self) -> None: """Test :attr:`colour.utilities.network.PortNode.edges` property.""" assert self._add_node_1.edges == ({}, {}) @@ -623,7 +634,7 @@ def test_edges(self): assert self._multiply_node_1.edges == ({}, {}) assert self._add_node_2.edges == ({}, {}) - def test_description(self): + def test_description(self) -> None: """Test :attr:`colour.utilities.network.PortNode.description` property.""" assert ( @@ -639,7 +650,7 @@ def test_description(self): == "Perform the addition of the two input port values." ) - def test_add_input_port(self): + def test_add_input_port(self) -> None: """Test :meth:`colour.utilities.network.PortNode.add_input_port` method.""" node = PortNode() @@ -648,7 +659,7 @@ def test_add_input_port(self): assert node.input_ports["a"].value == 1 assert node.input_ports["a"].description == 'Input Port "a"' - def test_remove_input_port(self): + def test_remove_input_port(self) -> None: """Test :meth:`colour.utilities.network.PortNode.remove_input_port` method.""" node = PortNode() @@ -657,7 +668,7 @@ def test_remove_input_port(self): assert len(node.input_ports) == 0 - def test_add_output_port(self): + def test_add_output_port(self) -> None: """Test :meth:`colour.utilities.network.PortNode.add_output_port` method.""" node = PortNode() @@ -666,7 +677,7 @@ def test_add_output_port(self): assert node.output_ports["output"].value == 1 assert node.output_ports["output"].description == 'Output Port "output"' - def test_remove_output_port(self): + def test_remove_output_port(self) -> None: """Test :meth:`colour.utilities.network.PortNode.remove_output_port` method.""" node = PortNode() @@ -675,7 +686,7 @@ def test_remove_output_port(self): assert len(node.input_ports) == 0 - def test_get_input(self): + def test_get_input(self) -> None: """Test :meth:`colour.utilities.network.PortNode.get_input` method.""" node = PortNode() @@ -683,7 +694,7 @@ def test_get_input(self): assert node.get_input("a") == 1 - def test_set_input(self): + def test_set_input(self) -> None: """Test :meth:`colour.utilities.network.PortNode.set_input` method.""" node = PortNode() @@ -695,7 +706,7 @@ def test_set_input(self): assert node.input_ports["a"].value == 2 - def test_get_output(self): + def test_get_output(self) -> None: """Test :meth:`colour.utilities.network.PortNode.get_output` method.""" node = PortNode() @@ -703,7 +714,7 @@ def test_get_output(self): assert node.get_output("output") == 1 - def test_set_output(self): + def test_set_output(self) -> None: """Test :meth:`colour.utilities.network.PortNode.set_output` method.""" node = PortNode() @@ -715,17 +726,17 @@ def test_set_output(self): assert node.output_ports["output"].value == 2 - def test_connect(self): + def test_connect(self) -> None: """Test :meth:`colour.utilities.network.PortNode.connect` method.""" self.test_edges() - def test_disconnect(self): + def test_disconnect(self) -> None: """Test :meth:`colour.utilities.network.PortNode.disconnect` method.""" self.test_edges() - def test_process(self): + def test_process(self) -> None: """Test :meth:`colour.utilities.network.PortNode.process` method.""" self._add_node_1.connect("output", self._multiply_node_1, "a") @@ -747,7 +758,7 @@ def test_process(self): self._add_node_1.disconnect("output", self._multiply_node_1, "a") self._multiply_node_1.disconnect("output", self._add_node_2, "a") - def test_to_graphviz(self): + def test_to_graphviz(self) -> None: """Test :meth:`colour.utilities.network.PortNode.to_graphviz` method.""" assert ( @@ -772,7 +783,7 @@ class TestPortGraph: Define :class:`colour.utilities.network.PortGraph` class unit tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._add_node_1 = _NodeAdd("Node Add 1") @@ -798,7 +809,7 @@ def setup_method(self): for node in self._nodes.values(): self._graph.add_node(node) - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("nodes",) @@ -806,7 +817,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(PortGraph) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -822,17 +833,17 @@ def test_required_methods(self): for method in required_methods: assert method in dir(PortGraph) - def test_nodes(self): + def test_nodes(self) -> None: """Test :attr:`colour.utilities.network.PortGraph.nodes` property.""" assert self._graph.nodes == self._nodes - def test___str__(self): + def test___str__(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.__str__` method.""" assert str(self._graph) == "PortGraph(3)" - def test_add_node(self): + def test_add_node(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.add_node` method.""" for node in self._nodes.values(): @@ -845,24 +856,24 @@ def test_add_node(self): assert len(self._graph.nodes) == 3 - def test_remove_node(self): + def test_remove_node(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.remove_node` method.""" self.test_add_node() - def test_walk_ports(self): + def test_walk_ports(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.walk_ports` method.""" assert list(self._graph.walk_ports()) == list(self._nodes.values()) - def test_process(self): + def test_process(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.process` method.""" self._graph.process() assert self._add_node_2.get_output("output") == 5 - def test_to_graphviz(self): + def test_to_graphviz(self) -> None: """Test :meth:`colour.utilities.network.PortGraph.to_graphviz` method.""" if not is_pydot_installed(): @@ -874,7 +885,7 @@ def test_to_graphviz(self): class _AddItem(ExecutionNode): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.description = "Add the item with input key and value to the input mapping." @@ -883,7 +894,7 @@ def __init__(self, *args, **kwargs): self.add_input_port("value") self.add_input_port("mapping", {}) - def process(self): + def process(self) -> None: """ Process the node. """ @@ -900,7 +911,7 @@ def process(self): class _NodeSumMappingValues(ExecutionNode): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.description = "Sum the input mapping values." @@ -908,7 +919,7 @@ def __init__(self, *args, **kwargs): self.add_input_port("mapping", {}) self.add_output_port("summation") - def process(self): + def process(self) -> None: mapping = self.get_input("mapping") if len(mapping) == 0: return @@ -919,7 +930,7 @@ def process(self): class _SubGraph1(ExecutionNode, PortGraph): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port("input") @@ -970,7 +981,7 @@ def __init__(self, *args, **kwargs): self.connect("input", self.nodes["Add Item"], "key") self.nodes["Add Item"].connect("mapping", self, "output") - def process(self, **kwargs) -> None: + def process(self, **kwargs: Any) -> None: self.nodes["Add 1"].set_input("a", 1) self.nodes["Multiply 1"].set_input("b", 2) self.nodes["Add 2"].set_input("b", 3) @@ -983,7 +994,7 @@ class TestFor: Define :class:`colour.utilities.network.For` class unit tests methods. """ - def test_For(self): + def test_For(self) -> None: """Test :class:`colour.utilities.network.For` class.""" sum_mapping_values = _NodeSumMappingValues() @@ -1002,7 +1013,7 @@ def test_For(self): class _NodeSumArray(ExecutionNode): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.description = "Sum the input array." @@ -1010,7 +1021,7 @@ def __init__(self, *args, **kwargs): self.add_input_port("array", []) self.add_output_port("summation") - def process(self): + def process(self) -> None: array = self.get_input("array") if len(array) == 0: return @@ -1021,7 +1032,7 @@ def process(self): class _SubGraph2(ExecutionNode, PortGraph): - def __init__(self, *args, **kwargs): + def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) self.add_input_port("input") @@ -1062,7 +1073,7 @@ def __init__(self, *args, **kwargs): self.connect("input", self.nodes["Add 1"], "b") self.nodes["Add 2"].connect("output", self, "output") - def process(self, **kwargs) -> None: + def process(self, **kwargs: Any) -> None: self.nodes["Add 1"].set_input("a", 1) self.nodes["Multiply 1"].set_input("b", 2) self.nodes["Add 2"].set_input("b", 3) @@ -1076,7 +1087,7 @@ class TestParallelForThread: methods. """ - def test_ParallelForThread(self): + def test_ParallelForThread(self) -> None: """Test :class:`colour.utilities.network.ParallelForThread` class.""" sum_array = _NodeSumArray() @@ -1100,7 +1111,7 @@ class TestParallelForMultiProcess: tests methods. """ - def test_ParallelForMultiProcess(self): + def test_ParallelForMultiProcess(self) -> None: """Test :class:`colour.utilities.network.ParallelForMultiProcess` class.""" sum_array = _NodeSumArray() diff --git a/colour/utilities/tests/test_structures.py b/colour/utilities/tests/test_structures.py index 114054520..fb0ea1d17 100644 --- a/colour/utilities/tests/test_structures.py +++ b/colour/utilities/tests/test_structures.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.utilities.structures` module.""" +from __future__ import annotations + import operator import pickle @@ -35,7 +37,7 @@ class TestStructure: tests methods. """ - def test_Structure(self): + def test_Structure(self) -> None: """Test :class:`colour.utilities.structures.Structure` class.""" structure = Structure(John="Doe", Jane="Doe") @@ -68,7 +70,7 @@ def test_Structure(self): assert structure.John == "Doe" assert structure["John"] == "Doe" - def test_pickling(self): + def test_pickling(self) -> None: """ Test whether :class:`colour.utilities.structures.Structure` class can be pickled. @@ -93,7 +95,7 @@ class TestLookup: methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("keys_from_value", "first_key_from_value") @@ -101,7 +103,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(Lookup) - def test_keys_from_value(self): + def test_keys_from_value(self) -> None: """ Test :meth:`colour.utilities.structures.Lookup.keys_from_value` method. @@ -115,7 +117,7 @@ def test_keys_from_value(self): ) assert sorted(lookup.keys_from_value(np.array([0, 1, 2]))) == ["A", "B"] - def test_first_key_from_value(self): + def test_first_key_from_value(self) -> None: """ Test :meth:`colour.utilities.structures.\ Lookup.first_key_from_value` method. @@ -129,7 +131,7 @@ def test_first_key_from_value(self): ) assert lookup.first_key_from_value(np.array([0, 1, 2])) == "A" - def test_raise_exception_first_key_from_value(self): + def test_raise_exception_first_key_from_value(self) -> None: """ Test :meth:`colour.utilities.structures.\ Lookup.first_key_from_value` method raised exception. @@ -144,7 +146,7 @@ class TestCanonicalMapping: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = ("data",) @@ -152,7 +154,7 @@ def test_required_attributes(self): for attribute in required_attributes: assert attribute in dir(CanonicalMapping) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ( @@ -178,7 +180,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(CanonicalMapping) - def test_data(self): + def test_data(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.data` property. @@ -189,7 +191,7 @@ def test_data(self): "Jane": "Doe", } - def test__repr__(self): + def test__repr__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__repr__` method. @@ -200,7 +202,7 @@ def test__repr__(self): mapping["John"] = "Doe" assert repr(mapping) == "CanonicalMapping({'John': 'Doe'})" - def test__setitem__(self): + def test__setitem__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ __setitem__` method. @@ -212,7 +214,7 @@ def test__setitem__(self): assert mapping["John"] == "Doe" assert mapping["john"] == "Doe" - def test__getitem__(self): + def test__getitem__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ __getitem__` method. @@ -238,7 +240,7 @@ def test__getitem__(self): assert mapping["mccamy1992"] == 1 assert mapping["hernandez1999"] == 2 - def test__delitem__(self): + def test__delitem__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ __delitem__` method. @@ -281,7 +283,7 @@ def test__delitem__(self): assert len(mapping) == 0 - def test__contains__(self): + def test__contains__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ __contains__` method. @@ -303,7 +305,7 @@ def test__contains__(self): assert "mccamy1992" in mapping assert "hernandez1999" in mapping - def test__iter__(self): + def test__iter__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__iter__` method. @@ -312,7 +314,7 @@ def test__iter__(self): mapping = CanonicalMapping(John="Doe", Jane="Doe") assert sorted(item for item in mapping) == ["Jane", "John"] - def test__len__(self): + def test__len__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__len__` method. @@ -322,7 +324,7 @@ def test__len__(self): assert len(CanonicalMapping(John="Doe", Jane="Doe")) == 2 - def test__eq__(self): + def test__eq__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__eq__` method. @@ -336,7 +338,7 @@ def test__eq__(self): assert mapping2 != mapping3 - def test_raise_exception__eq__(self): + def test_raise_exception__eq__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__eq__` method raised exception. @@ -349,7 +351,7 @@ def test_raise_exception__eq__(self): ["John", "Doe", "Jane", "Doe"], ) - def test__ne__(self): + def test__ne__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__ne__` method. @@ -360,7 +362,7 @@ def test__ne__(self): assert mapping1 != mapping2 - def test_raise_exception__ne__(self): + def test_raise_exception__ne__(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.__ne__` method raised exception. @@ -373,7 +375,7 @@ def test_raise_exception__ne__(self): ["John", "Doe", "Jane", "Doe"], ) - def test_copy(self): + def test_copy(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.copy` method. @@ -386,7 +388,7 @@ def test_copy(self): assert id(mapping1) != id(mapping2) - def test_lower_keys(self): + def test_lower_keys(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ lower_keys` method. @@ -400,7 +402,7 @@ def test_lower_keys(self): pytest.warns(ColourUsageWarning, lambda: list(mapping.lower_keys())) - def test_lower_items(self): + def test_lower_items(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ lower_items` method. @@ -413,7 +415,7 @@ def test_lower_items(self): ("john", "Doe"), ] - def test_slugified_keys(self): + def test_slugified_keys(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ slugified_keys` method. @@ -430,7 +432,7 @@ def test_slugified_keys(self): pytest.warns(ColourUsageWarning, lambda: list(mapping.slugified_keys())) - def test_slugified_items(self): + def test_slugified_items(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ slugified_items` method. @@ -442,7 +444,7 @@ def test_slugified_items(self): ("mccamy-1992", 1), ] - def test_canonical_keys(self): + def test_canonical_keys(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ canonical_keys` method. @@ -459,7 +461,7 @@ def test_canonical_keys(self): pytest.warns(ColourUsageWarning, lambda: list(mapping.canonical_keys())) - def test_canonical_items(self): + def test_canonical_items(self) -> None: """ Test :meth:`colour.utilities.structures.CanonicalMapping.\ canonical_items` method. @@ -478,7 +480,7 @@ class TestLazyCanonicalMapping: unit tests methods. """ - def test_required_attributes(self): + def test_required_attributes(self) -> None: """Test the presence of required attributes.""" required_attributes = () @@ -486,7 +488,7 @@ def test_required_attributes(self): for attribute in required_attributes: # pragma: no cover assert attribute in dir(LazyCanonicalMapping) - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("__getitem__",) @@ -494,7 +496,7 @@ def test_required_methods(self): for method in required_methods: assert method in dir(LazyCanonicalMapping) - def test__getitem__(self): + def test__getitem__(self) -> None: """ Test :meth:`colour.utilities.structures.LazyCanonicalMapping.\ __getitem__` method. diff --git a/colour/utilities/tests/test_verbose.py b/colour/utilities/tests/test_verbose.py index 23125f279..76e5cfbdc 100644 --- a/colour/utilities/tests/test_verbose.py +++ b/colour/utilities/tests/test_verbose.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.utilities.verbose` module.""" +from __future__ import annotations + import os import sys import textwrap @@ -41,7 +43,7 @@ class TestMixinLogging: methods. """ - def test_required_methods(self): + def test_required_methods(self) -> None: """Test the presence of required methods.""" required_methods = ("log",) @@ -56,18 +58,18 @@ class TestShowWarning: methods. """ - def test_show_warning(self): + def test_show_warning(self) -> None: """Test :func:`colour.utilities.verbose.show_warning` definition.""" - show_warning("This is a unit test warning!", Warning, None, None) + show_warning("This is a unit test warning!", Warning, __file__, 0) with open(os.devnull) as dev_null: - show_warning("This is a unit test warning!", Warning, None, None, dev_null) + show_warning("This is a unit test warning!", Warning, __file__, 0, dev_null) stderr = sys.stderr try: sys.stderr = None - show_warning("This is a unit test warning!", Warning, None, None) + show_warning("This is a unit test warning!", Warning, __file__, 0) finally: sys.stderr = stderr @@ -78,7 +80,7 @@ class TestAsBool: methods. """ - def test_as_bool(self): + def test_as_bool(self) -> None: """Test :func:`colour.utilities.common.as_bool` definition.""" assert as_bool("1") @@ -102,7 +104,7 @@ class TestSuppressWarnings: tests methods. """ - def test_suppress_warnings(self): + def test_suppress_warnings(self) -> None: """Test :func:`colour.utilities.verbose.suppress_warnings` definition.""" with suppress_warnings(): @@ -115,7 +117,7 @@ class TestSuppressStdout: tests methods. """ - def test_suppress_stdout(self): + def test_suppress_stdout(self) -> None: """Test :func:`colour.utilities.verbose.suppress_stdout` definition.""" with suppress_stdout(): @@ -128,7 +130,7 @@ class TestDescribeEnvironment: unit tests methods. """ - def test_describe_environment(self): + def test_describe_environment(self) -> None: """Test :func:`colour.utilities.verbose.describe_environment` definition.""" environment = describe_environment() @@ -165,7 +167,7 @@ class TestMultilineStr: tests methods. """ - def test_multiline_str(self): + def test_multiline_str(self) -> None: """Test :func:`colour.utilities.verbose.multiline_str` definition.""" class Data: @@ -233,7 +235,7 @@ class TestMultilineRepr: tests methods. """ - def test_multiline_repr(self): + def test_multiline_repr(self) -> None: """Test :func:`colour.utilities.verbose.multiline_repr` definition.""" class Data: diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index 082cf5b2e..fc70b2184 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -150,7 +150,7 @@ def message_box( width: int = 79, padding: int = 3, print_callable: Callable = print, -): +) -> None: """ Print a message inside a box. @@ -200,7 +200,7 @@ def message_box( ideal_width = width - padding * 2 - 2 - def inner(text): + def inner(text: str) -> str: """Format and pads inner text for the message box.""" return ( @@ -301,7 +301,7 @@ def show_warning( warnings.showwarning = show_warning # pragma: no cover -def warning(*args: Any, **kwargs: Any): +def warning(*args: Any, **kwargs: Any) -> None: """ Issue a warning. @@ -322,7 +322,7 @@ def warning(*args: Any, **kwargs: Any): warn(*args, **kwargs) # noqa: B028 -def runtime_warning(*args: Any, **kwargs: Any): +def runtime_warning(*args: Any, **kwargs: Any) -> None: """ Issue a runtime warning. @@ -343,7 +343,7 @@ def runtime_warning(*args: Any, **kwargs: Any): warning(*args, **kwargs) -def usage_warning(*args: Any, **kwargs: Any): +def usage_warning(*args: Any, **kwargs: Any) -> None: """ Issue a usage warning. @@ -369,7 +369,7 @@ def filter_warnings( colour_usage_warnings: bool | LiteralWarning | None = None, colour_warnings: bool | LiteralWarning | None = None, python_warnings: bool | LiteralWarning | None = None, -): +) -> None: """ Filter *Colour* and also optionally overall Python warnings. @@ -595,7 +595,7 @@ def __enter__(self) -> suppress_stdout: return self - def __exit__(self, *args: Any): + def __exit__(self, *args: Any) -> None: """Restore the standard output upon exiting the context manager.""" sys.stdout.close() @@ -1167,4 +1167,4 @@ def _format(attribute: dict) -> str: representation.append(f"{'':{justify}}{_format(attribute)}") - return "{})".format(",\n".join(representation)) # noqa: flynt + return "{})".format(",\n".join(representation)) diff --git a/colour/volume/tests/test_macadam_limits.py b/colour/volume/tests/test_macadam_limits.py index eb4fbefcf..924190469 100644 --- a/colour/volume/tests/test_macadam_limits.py +++ b/colour/volume/tests/test_macadam_limits.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.volume.macadam_limits` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -25,7 +27,7 @@ class TestIsWithinMacadamLimits: definition unit tests methods. """ - def test_is_within_macadam_limits(self): + def test_is_within_macadam_limits(self) -> None: """ Test :func:`colour.volume.macadam_limits.is_within_macadam_limits` definition. @@ -39,7 +41,7 @@ def test_is_within_macadam_limits(self): assert not is_within_macadam_limits(np.array([0.0025, 0.0088, 0.0340]), "C") - def test_n_dimensional_is_within_macadam_limits(self): + def test_n_dimensional_is_within_macadam_limits(self) -> None: """ Test :func:`colour.volume.macadam_limits.is_within_macadam_limits` definition n-dimensional arrays support. @@ -57,7 +59,7 @@ def test_n_dimensional_is_within_macadam_limits(self): np.testing.assert_allclose(is_within_macadam_limits(a, "A"), b) @ignore_numpy_errors - def test_nan_is_within_macadam_limits(self): + def test_nan_is_within_macadam_limits(self) -> None: """ Test :func:`colour.volume.macadam_limits.is_within_macadam_limits` definition nan support. diff --git a/colour/volume/tests/test_mesh.py b/colour/volume/tests/test_mesh.py index c28c90055..14e7ad873 100644 --- a/colour/volume/tests/test_mesh.py +++ b/colour/volume/tests/test_mesh.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.volume.mesh` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -26,7 +28,7 @@ class TestIsWithinMeshVolume: tests methods. """ - def setup_method(self): + def setup_method(self) -> None: """Initialise the common tests attributes.""" self._mesh = np.array( @@ -39,7 +41,7 @@ def setup_method(self): ] ) - def test_is_within_mesh_volume(self): + def test_is_within_mesh_volume(self) -> None: """Test :func:`colour.volume.mesh.is_within_mesh_volume` definition.""" assert is_within_mesh_volume(np.array([0.0005, 0.0031, 0.0010]), self._mesh) @@ -50,7 +52,7 @@ def test_is_within_mesh_volume(self): assert not is_within_mesh_volume(np.array([0.4325, 0.3788, 0.1034]), self._mesh) - def test_n_dimensional_is_within_mesh_volume(self): + def test_n_dimensional_is_within_mesh_volume(self) -> None: """ Test :func:`colour.volume.mesh.is_within_mesh_volume` definition n-dimensional arrays support. @@ -76,7 +78,7 @@ def test_n_dimensional_is_within_mesh_volume(self): ) @ignore_numpy_errors - def test_nan_is_within_mesh_volume(self): + def test_nan_is_within_mesh_volume(self) -> None: """ Test :func:`colour.volume.mesh.is_within_mesh_volume` definition nan support. diff --git a/colour/volume/tests/test_pointer_gamut.py b/colour/volume/tests/test_pointer_gamut.py index f9e4be108..d4b495455 100644 --- a/colour/volume/tests/test_pointer_gamut.py +++ b/colour/volume/tests/test_pointer_gamut.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.volume.pointer_gamut` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -25,7 +27,7 @@ class TestIsWithinPointerGamut: definition unit tests methods. """ - def test_is_within_pointer_gamut(self): + def test_is_within_pointer_gamut(self) -> None: """ Test :func:`colour.volume.pointer_gamut.is_within_pointer_gamut` definition. @@ -39,7 +41,7 @@ def test_is_within_pointer_gamut(self): assert not is_within_pointer_gamut(np.array([0.0025, 0.0088, 0.0340])) - def test_n_dimensional_is_within_pointer_gamut(self): + def test_n_dimensional_is_within_pointer_gamut(self) -> None: """ Test :func:`colour.volume.pointer_gamut.is_within_pointer_gamut` definition n-dimensional arrays support. @@ -57,7 +59,7 @@ def test_n_dimensional_is_within_pointer_gamut(self): np.testing.assert_allclose(is_within_pointer_gamut(a), b) @ignore_numpy_errors - def test_nan_is_within_pointer_gamut(self): + def test_nan_is_within_pointer_gamut(self) -> None: """ Test :func:`colour.volume.pointer_gamut.is_within_pointer_gamut` definition nan support. diff --git a/colour/volume/tests/test_rgb.py b/colour/volume/tests/test_rgb.py index 23726aa9f..99ea152af 100644 --- a/colour/volume/tests/test_rgb.py +++ b/colour/volume/tests/test_rgb.py @@ -18,6 +18,8 @@ reproducibility-of-python-pseudo-random-numbers-across-systems-and-versions """ +from __future__ import annotations + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -58,7 +60,7 @@ class TestRGB_colourspaceLimits: tests methods. """ - def test_RGB_colourspace_limits(self): + def test_RGB_colourspace_limits(self) -> None: """Test :func:`colour.volume.rgb.RGB_colourspace_limits` definition.""" np.testing.assert_allclose( @@ -109,7 +111,7 @@ class TestRGB_colourspaceVolumeMonteCarlo: """ @disable_multiprocessing() - def test_RGB_colourspace_volume_MonteCarlo(self): + def test_RGB_colourspace_volume_MonteCarlo(self) -> None: """ Test :func:`colour.volume.rgb.RGB_colourspace_volume_MonteCarlo` definition. @@ -118,7 +120,7 @@ def test_RGB_colourspace_volume_MonteCarlo(self): np.testing.assert_allclose( RGB_colourspace_volume_MonteCarlo( RGB_COLOURSPACE_BT709, - 10e3, + int(10e3), random_state=np.random.RandomState(2), ) * 1e-6, @@ -137,7 +139,7 @@ class TestRGB_colourspace_volume_coverage_MonteCarlo: :cite:`Laurent2012a` """ - def test_RGB_colourspace_volume_coverage_MonteCarlo(self): + def test_RGB_colourspace_volume_coverage_MonteCarlo(self) -> None: """ Test :func:`colour.volume.rgb.\ RGB_colourspace_volume_coverage_MonteCarlo` definition. @@ -147,7 +149,7 @@ def test_RGB_colourspace_volume_coverage_MonteCarlo(self): RGB_colourspace_volume_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, is_within_pointer_gamut, - 10e3, + int(10e3), random_state=np.random.RandomState(2), ), 81.044349070100140, @@ -166,7 +168,7 @@ class TestRGB_colourspacePointerGamutCoverageMonteCarlo: :cite:`Laurent2012a` """ - def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self): + def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self) -> None: """ Test :func:`colour.volume.rgb.\ RGB_colourspace_pointer_gamut_coverage_MonteCarlo` definition. @@ -175,7 +177,7 @@ def test_RGB_colourspace_pointer_gamut_coverage_MonteCarlo(self): np.testing.assert_allclose( RGB_colourspace_pointer_gamut_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, - 10e3, + int(10e3), random_state=np.random.RandomState(2), ), 81.044349070100140, @@ -194,7 +196,7 @@ class TestRGB_colourspaceVisibleSpectrumCoverageMonteCarlo: :cite:`Laurent2012a` """ - def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self): + def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self) -> None: """ Test :func:`colour.volume.rgb.\ RGB_colourspace_visible_spectrum_coverage_MonteCarlo` definition. @@ -203,7 +205,7 @@ def test_RGB_colourspace_visible_spectrum_coverage_MonteCarlo(self): np.testing.assert_allclose( RGB_colourspace_visible_spectrum_coverage_MonteCarlo( RGB_COLOURSPACE_BT709, - 10e3, + int(10e3), random_state=np.random.RandomState(2), ), 46.931407942238266, diff --git a/colour/volume/tests/test_spectrum.py b/colour/volume/tests/test_spectrum.py index ad967148a..8b2aff87e 100644 --- a/colour/volume/tests/test_spectrum.py +++ b/colour/volume/tests/test_spectrum.py @@ -1,5 +1,7 @@ """Define the unit tests for the :mod:`colour.volume.spectrum` module.""" +from __future__ import annotations + from itertools import product import numpy as np @@ -38,7 +40,7 @@ class TestGeneratePulseWaves: definition unit tests methods. """ - def test_generate_pulse_waves(self): + def test_generate_pulse_waves(self) -> None: """ Test :func:`colour.volume.spectrum.generate_pulse_waves` definition. @@ -136,7 +138,7 @@ class TestXYZOuterSurface: definition unit tests methods. """ - def test_XYZ_outer_surface(self): + def test_XYZ_outer_surface(self) -> None: """ Test :func:`colour.volume.spectrum.XYZ_outer_surface` definition. @@ -195,7 +197,7 @@ class TestIsWithinVisibleSpectrum: definition unit tests methods. """ - def test_is_within_visible_spectrum(self): + def test_is_within_visible_spectrum(self) -> None: """ Test :func:`colour.volume.spectrum.is_within_visible_spectrum` definition. @@ -209,7 +211,7 @@ def test_is_within_visible_spectrum(self): assert not is_within_visible_spectrum(np.array([0.0025, 0.0088, 0.0340])) - def test_n_dimensional_is_within_visible_spectrum(self): + def test_n_dimensional_is_within_visible_spectrum(self) -> None: """ Test :func:`colour.volume.spectrum.is_within_visible_spectrum` definition n-dimensional arrays support. @@ -227,7 +229,7 @@ def test_n_dimensional_is_within_visible_spectrum(self): np.testing.assert_allclose(is_within_visible_spectrum(a), b) @ignore_numpy_errors - def test_nan_is_within_visible_spectrum(self): + def test_nan_is_within_visible_spectrum(self) -> None: """ Test :func:`colour.volume.spectrum.is_within_visible_spectrum` definition nan support. diff --git a/docs/colour.hints.rst b/docs/colour.hints.rst index 5771b9b9a..2a3dc3d80 100644 --- a/docs/colour.hints.rst +++ b/docs/colour.hints.rst @@ -21,6 +21,7 @@ Annotation Type Hints List Literal Mapping + NoReturn NewType Protocol Sequence diff --git a/pyproject.toml b/pyproject.toml index a13d52a47..ffcdab3dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -151,7 +151,7 @@ line-length = 88 select = [ "A", # flake8-builtins "ARG", # flake8-unused-arguments - # "ANN", # flake8-annotations + "ANN", # flake8-annotations "B", # flake8-bugbear # "BLE", # flake8-blind-except "C4", # flake8-comprehensions @@ -192,6 +192,7 @@ select = [ "YTT", # flake8-2020 ] ignore = [ + "ANN401", "B008", "B905", "D104", diff --git a/tasks.py b/tasks.py index 868a83db7..ab41cbbf1 100644 --- a/tasks.py +++ b/tasks.py @@ -68,7 +68,7 @@ @task -def literalise(ctx: Context): +def literalise(ctx: Context) -> None: """ Write various literals in the `colour.hints` module. @@ -91,7 +91,7 @@ def clean( docs: bool = True, bytecode: bool = False, pytest: bool = True, -): +) -> None: """ Clean the project. @@ -131,7 +131,7 @@ def formatting( ctx: Context, asciify: bool = True, bibtex: bool = True, -): +) -> None: """ Convert unicode characters to ASCII and cleanup the *BibTeX* file. @@ -174,7 +174,7 @@ def quality( ctx: Context, pyright: bool = True, rstlint: bool = True, -): +) -> None: """ Check the codebase with *Pyright* and lints various *restructuredText* files with *rst-lint*. @@ -199,7 +199,7 @@ def quality( @task -def precommit(ctx: Context): +def precommit(ctx: Context) -> None: """ Run the "pre-commit" hooks on the codebase. @@ -214,7 +214,7 @@ def precommit(ctx: Context): @task -def tests(ctx: Context): +def tests(ctx: Context) -> None: """ Run the unit tests with *Pytest*. @@ -235,7 +235,7 @@ def tests(ctx: Context): @task -def examples(ctx: Context, plots: bool = False): +def examples(ctx: Context, plots: bool = False) -> None: """ Run the examples. @@ -266,7 +266,7 @@ def examples(ctx: Context, plots: bool = False): @task(formatting, quality, precommit, tests, examples) -def preflight(ctx: Context): # noqa: ARG001 +def preflight(ctx: Context) -> None: # noqa: ARG001 """ Perform the preflight tasks, i.e., *formatting*, *tests*, *quality*, and *examples*. @@ -286,7 +286,7 @@ def docs( plots: bool = True, html: bool = True, pdf: bool = True, -): +) -> None: """ Build the documentation. @@ -318,7 +318,7 @@ def docs( @task -def todo(ctx: Context): +def todo(ctx: Context) -> None: """ Export the TODO items. @@ -335,7 +335,7 @@ def todo(ctx: Context): @task -def requirements(ctx: Context): +def requirements(ctx: Context) -> None: """ Export the *requirements.txt* file. @@ -356,7 +356,7 @@ def requirements(ctx: Context): @task(literalise, clean, preflight, docs, todo, requirements) -def build(ctx: Context): +def build(ctx: Context) -> None: """ Build the project and runs dependency tasks, i.e., *docs*, *todo*, and *preflight*. @@ -399,7 +399,7 @@ def build(ctx: Context): @task -def virtualise(ctx: Context, tests: bool = True): +def virtualise(ctx: Context, tests: bool = True) -> None: """ Create a virtual environment for the project build. @@ -432,7 +432,7 @@ def virtualise(ctx: Context, tests: bool = True): @task -def tag(ctx: Context): +def tag(ctx: Context) -> None: """ Tag the repository according to defined version using *git-flow*. @@ -485,7 +485,7 @@ def tag(ctx: Context): @task(build) -def release(ctx: Context): +def release(ctx: Context) -> None: """ Release the project to *Pypi* with *Twine*. @@ -502,7 +502,7 @@ def release(ctx: Context): @task -def sha256(ctx: Context): +def sha256(ctx: Context) -> None: """ Compute the project *Pypi* package *sha256* with *OpenSSL*. diff --git a/utilities/export_todo.py b/utilities/export_todo.py index 8d18eb915..0f587b659 100755 --- a/utilities/export_todo.py +++ b/utilities/export_todo.py @@ -93,7 +93,7 @@ def extract_todo_items(root_directory: str) -> dict: return todo_items -def export_todo_items(todo_items: dict, file_path: str): +def export_todo_items(todo_items: dict, file_path: str) -> None: """ Export TODO items to given file. diff --git a/utilities/generate_plots.py b/utilities/generate_plots.py index 20467ecc7..feda11eba 100755 --- a/utilities/generate_plots.py +++ b/utilities/generate_plots.py @@ -141,7 +141,7 @@ ] -def generate_documentation_plots(output_directory: str): +def generate_documentation_plots(output_directory: str) -> None: """ Generate documentation plots. diff --git a/utilities/literalise.py b/utilities/literalise.py index c2b44f977..d6ebc9080 100755 --- a/utilities/literalise.py +++ b/utilities/literalise.py @@ -33,7 +33,7 @@ ) -def literalise(path_module_hints: str = PATH_MODULE_HINTS): +def literalise(path_module_hints: str = PATH_MODULE_HINTS) -> None: """ Write various literals in the `colour.hints` module. diff --git a/utilities/mock_for_colour.py b/utilities/mock_for_colour.py index cd744a631..82868a29d 100644 --- a/utilities/mock_for_colour.py +++ b/utilities/mock_for_colour.py @@ -22,7 +22,7 @@ ] -def mock_scipy_for_colour(): +def mock_scipy_for_colour() -> None: """Mock *Scipy* for *Colour*.""" import sys diff --git a/utilities/unicode_to_ascii.py b/utilities/unicode_to_ascii.py index 7bfbf7c76..7dc0be459 100755 --- a/utilities/unicode_to_ascii.py +++ b/utilities/unicode_to_ascii.py @@ -31,7 +31,7 @@ } -def unicode_to_ascii(root_directory: str): +def unicode_to_ascii(root_directory: str) -> None: """ Recursively convert from unicode to ASCII *.py*, *.bib* and *.rst* files in given directory. From a6f95eb3628e20fa1a766c80a0b7e680d2b40399 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 20:48:57 +1300 Subject: [PATCH 07/42] Enable `B008` check. --- colour/adaptation/zhai2018.py | 2 +- colour/algebra/prng.py | 2 +- colour/characterisation/aces_it.py | 5 ++--- colour/contrast/barten1999.py | 17 +++++++++++++++-- colour/corresponding/prediction.py | 2 +- colour/geometry/vertices.py | 8 ++++---- colour/io/fichet2021.py | 13 ++++++++++--- colour/models/cie_luv.py | 2 +- colour/models/cie_ucs.py | 2 +- colour/models/cie_xyy.py | 2 +- colour/plotting/colorimetry.py | 5 ++++- colour/recovery/jakob2019.py | 2 +- colour/volume/rgb.py | 4 ++-- pyproject.toml | 3 +-- 14 files changed, 45 insertions(+), 24 deletions(-) diff --git a/colour/adaptation/zhai2018.py b/colour/adaptation/zhai2018.py index 947d81840..05d767465 100644 --- a/colour/adaptation/zhai2018.py +++ b/colour/adaptation/zhai2018.py @@ -45,7 +45,7 @@ def chromatic_adaptation_Zhai2018( XYZ_wd: ArrayLike, D_b: ArrayLike = 1, D_d: ArrayLike = 1, - XYZ_wo: ArrayLike = np.array([1, 1, 1]), + XYZ_wo: ArrayLike = (1, 1, 1), transform: Literal["CAT02", "CAT16"] | str = "CAT02", ) -> NDArrayFloat: """ diff --git a/colour/algebra/prng.py b/colour/algebra/prng.py index 0033ceeaa..bbbc23eac 100644 --- a/colour/algebra/prng.py +++ b/colour/algebra/prng.py @@ -39,7 +39,7 @@ def random_triplet_generator( size: int, - limits: ArrayLike = np.array([[0, 1], [0, 1], [0, 1]]), + limits: ArrayLike = ([0, 1], [0, 1], [0, 1]), random_state: np.random.RandomState = RANDOM_STATE, ) -> NDArrayFloat: """ diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index e72abfe78..0e11e93b7 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -114,7 +114,6 @@ as_float_array, as_float_scalar, from_range_1, - ones, optional, runtime_warning, tsplit, @@ -703,7 +702,7 @@ def training_data_sds_to_XYZ( def whitepoint_preserving_matrix( - M: ArrayLike, RGB_w: ArrayLike = ones(3) + M: ArrayLike, RGB_w: ArrayLike = (1, 1, 1) ) -> NDArrayFloat: """ Normalise given matrix :math:`M` to preserve given white point @@ -1111,7 +1110,7 @@ def camera_RGB_to_ACES2065_1( RGB: ArrayLike, B: ArrayLike, b: ArrayLike, - k: ArrayLike = np.ones(3), + k: ArrayLike = (1, 1, 1), clip: bool = False, ) -> NDArrayFloat: """ diff --git a/colour/contrast/barten1999.py b/colour/contrast/barten1999.py index 70b928405..a096bfd35 100644 --- a/colour/contrast/barten1999.py +++ b/colour/contrast/barten1999.py @@ -46,6 +46,8 @@ "sigma_Barten1999", "retinal_illuminance_Barten1999", "maximum_angular_size_Barten1999", + "SIGMA_DEFAULT", + "E_DEFAULT", "contrast_sensitivity_function_Barten1999", ] @@ -292,9 +294,20 @@ def maximum_angular_size_Barten1999( return as_float((1 / X_0**2 + 1 / X_max**2 + u**2 / N_max**2) ** -0.5) +SIGMA_DEFAULT: NDArrayFloat = sigma_Barten1999(0.5 / 60, 0.08 / 60, 2.1) +""" +Default standard deviation :math:`\\sigma`. +""" + +E_DEFAULT: NDArrayFloat = retinal_illuminance_Barten1999(20, 2.1) +""" +Default retinal illuminance :math:`E` in Trolands. +""" + + def contrast_sensitivity_function_Barten1999( u: ArrayLike, - sigma: ArrayLike = sigma_Barten1999(0.5 / 60, 0.08 / 60, 2.1), + sigma: ArrayLike = SIGMA_DEFAULT, k: ArrayLike = 3.0, T: ArrayLike = 0.1, X_0: ArrayLike = 60, @@ -304,7 +317,7 @@ def contrast_sensitivity_function_Barten1999( N_max: ArrayLike = 15, n: ArrayLike = 0.03, p: ArrayLike = 1.2274 * 10**6, - E: ArrayLike = retinal_illuminance_Barten1999(20, 2.1), + E: ArrayLike = E_DEFAULT, phi_0: ArrayLike = 3 * 10**-8, u_0: ArrayLike = 7, ) -> NDArrayFloat: diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index 142091c0a..95613adc4 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -584,7 +584,7 @@ def corresponding_chromaticities_prediction_Zhai2018( experiment: (Literal[1, 2, 3, 4, 6, 8, 9, 11, 12] | CorrespondingColourDataset) = 1, D_b: ArrayLike = 1, D_d: ArrayLike = 1, - XYZ_wo: ArrayLike = np.array([1, 1, 1]), + XYZ_wo: ArrayLike = (1, 1, 1), transform: Literal["CAT02", "CAT16"] | str = "CAT02", ) -> Tuple[CorrespondingChromaticitiesPrediction, ...]: """ diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 995d67853..404056ecc 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -52,7 +52,7 @@ def primitive_vertices_quad_mpl( width: float = 1, height: float = 1, depth: float = 0, - origin: ArrayLike = np.array([0, 0]), + origin: ArrayLike = (0, 0), axis: Literal["+z", "+x", "+y", "yz", "xz", "xy"] | str = "+z", ) -> NDArrayFloat: """ @@ -125,7 +125,7 @@ def primitive_vertices_grid_mpl( depth: float = 0, width_segments: int = 1, height_segments: int = 1, - origin: ArrayLike = np.array([0, 0]), + origin: ArrayLike = (0, 0), axis: Literal["+z", "+x", "+y", "yz", "xz", "xy"] | str = "+z", ) -> NDArrayFloat: """ @@ -203,7 +203,7 @@ def primitive_vertices_cube_mpl( width_segments: int = 1, height_segments: int = 1, depth_segments: int = 1, - origin: ArrayLike = np.array([0, 0, 0]), + origin: ArrayLike = (0, 0, 0), planes: ( Sequence[ Literal[ @@ -338,7 +338,7 @@ def primitive_vertices_sphere( radius: float = 0.5, segments: int = 8, intermediate: bool = False, - origin: ArrayLike = np.array([0, 0, 0]), + origin: ArrayLike = (0, 0, 0), axis: Literal["+z", "+x", "+y", "yz", "xz", "xy"] | str = "+z", ) -> NDArrayFloat: """ diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index f1776830c..ca89427fc 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -69,6 +69,7 @@ "sd_to_spectrum_attribute_Fichet2021", "spectrum_attribute_to_sd_Fichet2021", "Specification_Fichet2021", + "SPECIFICATION_FICHET2021_DEFAULT", "read_spectral_image_Fichet2021", "sds_and_msds_to_components_Fichet2021", "components_to_sRGB_Fichet2021", @@ -418,6 +419,12 @@ def from_spectral_image(path: str | Path) -> Specification_Fichet2021: ) +SPECIFICATION_FICHET2021_DEFAULT: Specification_Fichet2021 = Specification_Fichet2021() +""" +Default *Fichet et al. (2021)* spectral image specification. +""" + + @required("OpenImageIO") def read_spectral_image_Fichet2021( path: str | Path, @@ -510,7 +517,7 @@ def sds_and_msds_to_components_Fichet2021( | SpectralDistribution | MultiSpectralDistributions | ValuesView, - specification: Specification_Fichet2021 = Specification_Fichet2021(), + specification: Specification_Fichet2021 = SPECIFICATION_FICHET2021_DEFAULT, **kwargs: Any, ) -> ComponentsFichet2021: """ @@ -579,7 +586,7 @@ def sds_and_msds_to_components_Fichet2021( @required("OpenImageIO") def components_to_sRGB_Fichet2021( components: ComponentsFichet2021, - specification: Specification_Fichet2021 = Specification_Fichet2021(), + specification: Specification_Fichet2021 = SPECIFICATION_FICHET2021_DEFAULT, ) -> Tuple[NDArrayFloat | None, Sequence[Image_Specification_Attribute]]: """ Convert given *Fichet et al. (2021)* components to *sRGB* colourspace values. @@ -722,7 +729,7 @@ def write_spectral_image_Fichet2021( | ValuesView, path: str | Path, bit_depth: Literal["float16", "float32"] = "float32", - specification: Specification_Fichet2021 = Specification_Fichet2021(), + specification: Specification_Fichet2021 = SPECIFICATION_FICHET2021_DEFAULT, components_to_RGB_callable: Callable = components_to_sRGB_Fichet2021, **kwargs: Any, ) -> bool: diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index 649e5f80b..a527c3436 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -291,7 +291,7 @@ def uv_to_Luv( illuminant: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ "D65" ], - L: ArrayLike = np.array(100), + L: ArrayLike = 100, ) -> NDArrayFloat: """ Return the *CIE L\\*u\\*v\\** colourspace array from given :math:`uv^p` diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index 82a999363..0cf2d3968 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -195,7 +195,7 @@ def UCS_to_uv(UVW: ArrayLike) -> NDArrayFloat: return uv -def uv_to_UCS(uv: ArrayLike, V: ArrayLike = np.array(1)) -> NDArrayFloat: +def uv_to_UCS(uv: ArrayLike, V: ArrayLike = 1) -> NDArrayFloat: """ Return the *CIE 1960 UCS* :math:`UVW` colourspace array from given *uv* chromaticity coordinates. diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index 525a1ca3f..30fea6067 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -203,7 +203,7 @@ def xyY_to_xy(xyY: ArrayLike) -> NDArrayFloat: return xy -def xy_to_xyY(xy: ArrayLike, Y: ArrayLike = np.array(1)) -> NDArrayFloat: +def xy_to_xyY(xy: ArrayLike, Y: ArrayLike = 1) -> NDArrayFloat: """ Convert from *CIE xy* chromaticity coordinates to *CIE xyY* colourspace by extending the array last dimension with given :math:`Y` *luminance*. diff --git a/colour/plotting/colorimetry.py b/colour/plotting/colorimetry.py index 28b2dfff6..827c1675b 100644 --- a/colour/plotting/colorimetry.py +++ b/colour/plotting/colorimetry.py @@ -82,6 +82,7 @@ domain_range_scale, first_item, ones, + optional, tstack, ) @@ -1079,7 +1080,7 @@ def plot_blackbody_spectral_radiance( } ) def plot_blackbody_colours( - shape: SpectralShape = SpectralShape(150, 12500, 50), + shape: SpectralShape | None = None, cmfs: ( MultiSpectralDistributions | str | Sequence[MultiSpectralDistributions | str] ) = "CIE 1931 2 Degree Standard Observer", @@ -1119,6 +1120,8 @@ def plot_blackbody_colours( :alt: plot_blackbody_colours """ + shape = optional(shape, SpectralShape(150, 12500, 50)) + _figure, axes = artist(**kwargs) cmfs = cast(MultiSpectralDistributions, first_item(filter_cmfs(cmfs).values())) diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 3d8571278..f990e7671 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -373,7 +373,7 @@ def find_coefficients_Jakob2019( XYZ: ArrayLike, cmfs: MultiSpectralDistributions | None = None, illuminant: SpectralDistribution | None = None, - coefficients_0: ArrayLike = zeros(3), + coefficients_0: ArrayLike = (0, 0, 0), max_error: float = JND_CIE1976 / 100, dimensionalise: bool = True, ) -> Tuple[NDArrayFloat, float]: diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index 59a01f718..26321f18b 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -75,7 +75,7 @@ def _wrapper_RGB_colourspace_volume_MonteCarlo(arguments: tuple) -> int: def sample_RGB_colourspace_volume_MonteCarlo( colourspace: RGB_Colourspace, samples: int = 1000000, - limits: ArrayLike = np.array([[0, 100], [-150, 150], [-150, 150]]), + limits: ArrayLike = ([0, 100], [-150, 150], [-150, 150]), illuminant_Lab: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ "D65" ], @@ -199,7 +199,7 @@ def RGB_colourspace_limits(colourspace: RGB_Colourspace) -> NDArrayFloat: def RGB_colourspace_volume_MonteCarlo( colourspace: RGB_Colourspace, samples: int = 1000000, - limits: ArrayLike = np.array([[0, 100], [-150, 150], [-150, 150]]), + limits: ArrayLike = ([0, 100], [-150, 150], [-150, 150]), illuminant_Lab: ArrayLike = CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"][ "D65" ], diff --git a/pyproject.toml b/pyproject.toml index ffcdab3dd..f1f9354ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -192,8 +192,7 @@ select = [ "YTT", # flake8-2020 ] ignore = [ - "ANN401", - "B008", + "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` "B905", "D104", "D200", From 44e614207a33ff4a54b9f9809e1fdb4972881ece Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 20:57:49 +1300 Subject: [PATCH 08/42] Enable `B905` check. --- colour/adaptation/tests/test__init__.py | 2 +- colour/algebra/interpolation.py | 2 +- .../chromaticity_coordinates.py | 14 ++++++++ colour/colorimetry/generation.py | 2 +- colour/colorimetry/spectrum.py | 1 + colour/colorimetry/tests/test_correction.py | 1 + colour/colorimetry/tests/test_lightness.py | 2 +- colour/colorimetry/tests/test_luminance.py | 2 +- colour/colorimetry/tests/test_spectrum.py | 4 +-- colour/colorimetry/tests/test_whiteness.py | 2 +- colour/colorimetry/tests/test_yellowness.py | 2 +- colour/continuous/multi_signals.py | 14 +++++--- colour/continuous/tests/test_multi_signal.py | 27 +++++++++------- colour/continuous/tests/test_signal.py | 14 ++++---- colour/difference/tests/test__init__.py | 2 +- .../characterisation/examples_aces_it.py | 4 +-- .../plotting/examples_section_plots.py | 2 +- colour/io/fichet2021.py | 4 +-- colour/io/luts/lut.py | 2 +- colour/io/tabular.py | 2 +- colour/io/tests/test_tabular.py | 10 ++++-- colour/notation/tests/test_munsell.py | 1 + colour/plotting/characterisation.py | 1 + colour/plotting/common.py | 2 +- colour/plotting/diagrams.py | 2 +- colour/recovery/jakob2019.py | 2 +- colour/recovery/tests/test__init__.py | 2 +- colour/utilities/structures.py | 32 ++++++++++++------- colour/utilities/tests/test_array.py | 3 +- pyproject.toml | 1 - 30 files changed, 102 insertions(+), 59 deletions(-) diff --git a/colour/adaptation/tests/test__init__.py b/colour/adaptation/tests/test__init__.py index 22018f9aa..abf179ec4 100644 --- a/colour/adaptation/tests/test__init__.py +++ b/colour/adaptation/tests/test__init__.py @@ -102,7 +102,7 @@ def test_domain_range_scale_chromatic_adaptation(self) -> None: ] d_r = (("reference", 1), ("1", 1), ("100", 100)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 7673ede5b..3a39aea7c 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -1742,7 +1742,7 @@ def vertices_and_relative_coordinates( vertices = np.array( [ table[i_f_c[i[0]][..., 0], i_f_c[i[1]][..., 1], i_f_c[i[2]][..., 2]] - for i in itertools.product(*zip([0, 0, 0], [1, 1, 1])) + for i in itertools.product(*zip([0, 0, 0], [1, 1, 1], strict=True)) ] ) diff --git a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py index 998809841..614940ecd 100644 --- a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py +++ b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py @@ -192,6 +192,7 @@ class ColourChecker( np.array([0.3101, 0.3163, 0.0900]), np.array([0.3101, 0.3163, 0.0313]), ], + strict=True, ) ) @@ -241,6 +242,7 @@ class ColourChecker( np.array([0.3401, 0.3548, 0.0883]), np.array([0.3406, 0.3537, 0.0311]), ], + strict=True, ) ) @@ -286,6 +288,7 @@ class ColourChecker( np.array([0.3423, 0.3576, 0.0893]), np.array([0.3439, 0.3565, 0.0320]), ], + strict=True, ) ) @@ -332,6 +335,7 @@ class ColourChecker( np.array([35.656, -0.421, -1.231]), np.array([20.461, -0.079, -0.973]), ], + strict=True, ) ) @@ -344,6 +348,7 @@ class ColourChecker( CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["ICC D50"], ) ), + strict=True, ) ) @@ -398,6 +403,7 @@ class ColourChecker( np.array([35.63, -0.46, -0.48]), np.array([20.64, 0.07, -0.46]), ], + strict=True, ) ) @@ -410,6 +416,7 @@ class ColourChecker( CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["ICC D50"], ) ), + strict=True, ) ) @@ -719,6 +726,7 @@ class ColourChecker( np.array([6.47, 0, -0.38]), np.array([96.46, -0.89, 0.71]), ], + strict=True, ) ) @@ -730,6 +738,7 @@ class ColourChecker( zip( SAMPLE_LABELS_COLORCHECKER_SG, DATA_COLORCHECKERSG_BEFORE_NOV2014_CIE_LAB.values(), + strict=True, ) ), dtype=object, @@ -750,6 +759,7 @@ class ColourChecker( CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["ICC D50"], ) ), + strict=True, ) ) @@ -916,6 +926,7 @@ class ColourChecker( np.array([8.11, 0.15, -0.90]), np.array([96.55, -0.64, 2.02]), ], + strict=True, ) ) @@ -927,6 +938,7 @@ class ColourChecker( zip( SAMPLE_LABELS_COLORCHECKER_SG, DATA_COLORCHECKERSG_AFTER_NOV2014_CIE_LAB.values(), + strict=True, ) ), dtype=object, @@ -947,6 +959,7 @@ class ColourChecker( CCS_ILLUMINANTS["CIE 1931 2 Degree Standard Observer"]["ICC D50"], ) ), + strict=True, ) ) @@ -1021,6 +1034,7 @@ class ColourChecker( zip( tuple(DATA_TE226_V2_CIE_XYZ.keys()), XYZ_to_xyY(list(DATA_TE226_V2_CIE_XYZ.values())), + strict=True, ) ) diff --git a/colour/colorimetry/generation.py b/colour/colorimetry/generation.py index 114a756d9..027baf505 100644 --- a/colour/colorimetry/generation.py +++ b/colour/colorimetry/generation.py @@ -751,7 +751,7 @@ def sd_multi_leds_Ohno2005( sd = sd_zeros(shape) for peak_wavelength, half_spectral_width, peak_power_ratio in zip( - peak_wavelengths, half_spectral_widths, peak_power_ratios + peak_wavelengths, half_spectral_widths, peak_power_ratios, strict=True ): sd += ( sd_single_led_Ohno2005(peak_wavelength, half_spectral_width, **kwargs) diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 5337bcbea..e5d242a69 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -1169,6 +1169,7 @@ def interpolate( for x in zip( (shape.start, shape.end, shape.interval), (shape_start, shape_end, shape_interval), + strict=True, ) ] ) diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index c46c5d7cf..6ba8e78b6 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -79,6 +79,7 @@ def test_bandpass_correction_Stearns1988(self) -> None: zip( range(len(DATA_NON_BANDPASS_CORRECTED)), DATA_NON_BANDPASS_CORRECTED, + strict=True, ) ) ) diff --git a/colour/colorimetry/tests/test_lightness.py b/colour/colorimetry/tests/test_lightness.py index 0449a6220..b7405c43f 100644 --- a/colour/colorimetry/tests/test_lightness.py +++ b/colour/colorimetry/tests/test_lightness.py @@ -723,7 +723,7 @@ def test_domain_range_scale_lightness(self) -> None: v = [lightness(12.19722535, method, Y_n=100) for method in m] d_r = (("reference", 1), ("1", 0.01), ("100", 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/colorimetry/tests/test_luminance.py b/colour/colorimetry/tests/test_luminance.py index 4bb9b03e4..487bb90d1 100644 --- a/colour/colorimetry/tests/test_luminance.py +++ b/colour/colorimetry/tests/test_luminance.py @@ -723,7 +723,7 @@ def test_domain_range_scale_luminance(self) -> None: v = [luminance(41.527875844653451, method, Y_n=100) for method in m] d_r = (("reference", 1), ("1", 0.01), ("100", 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/colorimetry/tests/test_spectrum.py b/colour/colorimetry/tests/test_spectrum.py index 3bafe34ad..c72a1ad1f 100644 --- a/colour/colorimetry/tests/test_spectrum.py +++ b/colour/colorimetry/tests/test_spectrum.py @@ -1567,7 +1567,7 @@ def test_extrapolate(self) -> None: SpectralDistribution.extrapolate` method. """ - data = dict(zip(range(25, 35), [0] * 5 + [1] * 5)) + data = dict(zip(range(25, 35), [0] * 5 + [1] * 5, strict=True)) sd = SpectralDistribution(data) sd.extrapolate(SpectralShape(10, 50, 5)) @@ -1844,7 +1844,7 @@ def test_extrapolate(self) -> None: MultiSpectralDistributions.extrapolate` method. """ - data = dict(zip(range(25, 35), tstack([[0] * 5 + [1] * 5] * 3))) + data = dict(zip(range(25, 35), tstack([[0] * 5 + [1] * 5] * 3), strict=True)) msds = MultiSpectralDistributions(data) msds.extrapolate(SpectralShape(10, 50, 5)) diff --git a/colour/colorimetry/tests/test_whiteness.py b/colour/colorimetry/tests/test_whiteness.py index a6e86d9aa..52676c63c 100644 --- a/colour/colorimetry/tests/test_whiteness.py +++ b/colour/colorimetry/tests/test_whiteness.py @@ -600,7 +600,7 @@ def test_domain_range_scale_whiteness(self) -> None: v = [whiteness(XYZ, XYZ_0, method) for method in m] d_r = (("reference", 1), ("1", 0.01), ("100", 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index fce52f93f..560e50359 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -315,7 +315,7 @@ def test_domain_range_scale_yellowness(self) -> None: v = [yellowness(XYZ, method) for method in m] d_r = (("reference", 1), ("1", 0.01), ("100", 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 0f3f7d95f..1d8e702fa 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -412,7 +412,7 @@ def range(self, value: ArrayLike) -> None: 'same count than underlying "Signal" components!', ) - for signal, y in zip(self._signals.values(), tsplit(value)): + for signal, y in zip(self._signals.values(), tsplit(value), strict=True): signal.range = y @property @@ -934,7 +934,7 @@ def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: 'underlying "Signal" components!', ) - values = list(zip(self._signals.values(), tsplit(y))) + values = list(zip(self._signals.values(), tsplit(y), strict=True)) for signal, y in values[x_c]: # pyright: ignore signal[x_r] = y @@ -1178,7 +1178,7 @@ def arithmetical_operation( ) for signal_a, signal_b in zip( - multi_signals.signals.values(), a.signals.values() + multi_signals.signals.values(), a.signals.values(), strict=True ): signal_a.arithmetical_operation(signal_b, operation, True) else: @@ -1200,7 +1200,9 @@ def arithmetical_operation( 'underlying "Signal" components!', ) - for signal, y in zip(multi_signals.signals.values(), tsplit(a)): + for signal, y in zip( + multi_signals.signals.values(), tsplit(a), strict=True + ): signal.arithmetical_operation(y, operation, True) return multi_signals @@ -1477,7 +1479,9 @@ def multi_signals_unpack_data( signal.range, signal.domain, **settings ) else: - domain_unpacked, range_unpacked = zip(*sorted(data_mapping.items())) + domain_unpacked, range_unpacked = zip( + *sorted(data_mapping.items()), strict=True + ) for i, values_unpacked in enumerate(tsplit(range_unpacked)): signals[str(i)] = signal_type( values_unpacked, domain_unpacked, **settings diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index 26efec2b5..a2ad76680 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -364,7 +364,9 @@ def test__init__(self) -> None: np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_2) - multi_signals = MultiSignals(dict(zip(self._domain_2, self._range_2))) + multi_signals = MultiSignals( + dict(zip(self._domain_2, self._range_2, strict=True)) + ) np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_2) @@ -384,12 +386,12 @@ class NotSignal(Signal): from pandas import DataFrame, Series multi_signals = MultiSignals( - Series(dict(zip(self._domain_2, self._range_1))) + Series(dict(zip(self._domain_2, self._range_1, strict=True))) ) np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_1[:, None]) - data = dict(zip(["a", "b", "c"], tsplit(self._range_2))) + data = dict(zip(["a", "b", "c"], tsplit(self._range_2), strict=True)) multi_signals = MultiSignals(DataFrame(data, self._domain_2)) np.testing.assert_array_equal(multi_signals.domain, self._domain_2) np.testing.assert_array_equal(multi_signals.range, self._range_2) @@ -959,7 +961,7 @@ def test_multi_signals_unpack_data(self) -> None: np.testing.assert_array_equal(signals["0"].range, self._range_1) signals = MultiSignals.multi_signals_unpack_data( - self._range_1, dict(zip(self._domain_2, self._range_1)).keys() + self._range_1, dict(zip(self._domain_2, self._range_1, strict=True)).keys() ) np.testing.assert_array_equal(signals["0"].domain, self._domain_2) @@ -973,7 +975,7 @@ def test_multi_signals_unpack_data(self) -> None: next( iter( MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)) + dict(zip(self._domain_2, self._range_2, strict=True)) ).values() ) ) @@ -982,7 +984,7 @@ def test_multi_signals_unpack_data(self) -> None: signals = MultiSignals.multi_signals_unpack_data( MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)) + dict(zip(self._domain_2, self._range_2, strict=True)) ).values() ) np.testing.assert_array_equal(signals["0"].range, self._range_1) @@ -990,7 +992,7 @@ def test_multi_signals_unpack_data(self) -> None: np.testing.assert_array_equal(signals["2"].range, self._range_1 + 20) signals = MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)) + dict(zip(self._domain_2, self._range_2, strict=True)) ) assert list(signals.keys()) == ["0", "1", "2"] np.testing.assert_array_equal(signals["0"].range, self._range_1) @@ -999,7 +1001,7 @@ def test_multi_signals_unpack_data(self) -> None: signals = MultiSignals.multi_signals_unpack_data( MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)) + dict(zip(self._domain_2, self._range_2, strict=True)) ) ) assert list(signals.keys()) == ["0", "1", "2"] @@ -1008,7 +1010,8 @@ def test_multi_signals_unpack_data(self) -> None: np.testing.assert_array_equal(signals["2"].range, self._range_1 + 20) signals = MultiSignals.multi_signals_unpack_data( - dict(zip(self._domain_2, self._range_2)), labels=["0", "0", "0"] + dict(zip(self._domain_2, self._range_2, strict=True)), + labels=["0", "0", "0"], ) assert list(signals.keys()) == ["0 - 0", "0 - 1", "0 - 2"] @@ -1016,13 +1019,13 @@ def test_multi_signals_unpack_data(self) -> None: from pandas import DataFrame, Series signals = MultiSignals.multi_signals_unpack_data( - Series(dict(zip(self._domain_1, self._range_1))) + Series(dict(zip(self._domain_1, self._range_1, strict=True))) ) assert list(signals.keys()) == ["0"] np.testing.assert_array_equal(signals["0"].domain, self._domain_1) np.testing.assert_array_equal(signals["0"].range, self._range_1) - data = dict(zip(["a", "b", "c"], tsplit(self._range_2))) + data = dict(zip(["a", "b", "c"], tsplit(self._range_2), strict=True)) signals = MultiSignals.multi_signals_unpack_data( DataFrame(data, self._domain_1) ) @@ -1108,7 +1111,7 @@ def test_to_dataframe(self) -> None: if is_pandas_installed(): from pandas import DataFrame - data = dict(zip(["a", "b", "c"], tsplit(self._range_2))) + data = dict(zip(["a", "b", "c"], tsplit(self._range_2), strict=True)) attest( MultiSignals(self._range_2, self._domain_2, labels=["a", "b", "c"]) diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index c0ba40d3d..f660260d0 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -273,7 +273,7 @@ def test__init__(self) -> None: np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) - signal = Signal(dict(zip(self._domain, self._range))) + signal = Signal(dict(zip(self._domain, self._range, strict=True))) np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) @@ -284,7 +284,7 @@ def test__init__(self) -> None: if is_pandas_installed(): from pandas import Series - signal = Signal(Series(dict(zip(self._domain, self._range)))) + signal = Signal(Series(dict(zip(self._domain, self._range, strict=True)))) np.testing.assert_array_equal(signal.domain, self._domain) np.testing.assert_array_equal(signal.range, self._range) @@ -692,11 +692,13 @@ def test_signal_unpack_data(self) -> None: np.testing.assert_array_equal(domain, self._domain) domain, range_ = Signal.signal_unpack_data( - self._range, dict(zip(self._domain, self._range)).keys() + self._range, dict(zip(self._domain, self._range, strict=True)).keys() ) np.testing.assert_array_equal(domain, self._domain) - domain, range_ = Signal.signal_unpack_data(dict(zip(self._domain, self._range))) + domain, range_ = Signal.signal_unpack_data( + dict(zip(self._domain, self._range, strict=True)) + ) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) @@ -708,7 +710,7 @@ def test_signal_unpack_data(self) -> None: from pandas import Series domain, range_ = Signal.signal_unpack_data( - Series(dict(zip(self._domain, self._range))) + Series(dict(zip(self._domain, self._range, strict=True))) ) np.testing.assert_array_equal(range_, self._range) np.testing.assert_array_equal(domain, self._domain) @@ -757,5 +759,5 @@ def test_to_series(self) -> None: assert ( Signal(self._range, self._domain).to_series().all() - == Series(dict(zip(self._domain, self._range))).all() + == Series(dict(zip(self._domain, self._range, strict=True))).all() ) diff --git a/colour/difference/tests/test__init__.py b/colour/difference/tests/test__init__.py index a4a248e23..36d9af385 100644 --- a/colour/difference/tests/test__init__.py +++ b/colour/difference/tests/test__init__.py @@ -36,7 +36,7 @@ def test_domain_range_scale_delta_E(self) -> None: v = [delta_E(Lab_1, Lab_2, method) for method in m] d_r = (("reference", 1), ("1", 0.01), ("100", 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/examples/characterisation/examples_aces_it.py b/colour/examples/characterisation/examples_aces_it.py index b0ed5a4ef..190d2fd6b 100644 --- a/colour/examples/characterisation/examples_aces_it.py +++ b/colour/examples/characterisation/examples_aces_it.py @@ -36,12 +36,12 @@ ) wavelengths = colour.characterisation.MSDS_ACES_RICD.wavelengths gray_reflector = colour.SpectralDistribution( - dict(zip(wavelengths, [0.18] * len(wavelengths))), name="18%" + dict(zip(wavelengths, [0.18] * len(wavelengths), strict=True)), name="18%" ) print(repr(colour.sd_to_aces_relative_exposure_values(gray_reflector))) perfect_reflector = colour.SpectralDistribution( - dict(zip(wavelengths, [1.0] * len(wavelengths))), name="100%" + dict(zip(wavelengths, [1.0] * len(wavelengths), strict=True)), name="100%" ) print(colour.sd_to_aces_relative_exposure_values(perfect_reflector)) diff --git a/colour/examples/plotting/examples_section_plots.py b/colour/examples/plotting/examples_section_plots.py index d3bdfb67a..90d37b554 100644 --- a/colour/examples/plotting/examples_section_plots.py +++ b/colour/examples/plotting/examples_section_plots.py @@ -115,7 +115,7 @@ origins = [] legend_lines = [] -for i, RGB in zip(np.arange(0.5, 0.9, 0.1), section_colours): +for i, RGB in zip(np.arange(0.5, 0.9, 0.1), section_colours, strict=True): origins.append(i * 100) plot_RGB_colourspace_section( colourspace="sRGB", diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index ca89427fc..cef72e166 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -222,7 +222,7 @@ def sd_to_spectrum_attribute_Fichet2021( return ";".join( f"{wavelength:.{decimals}f}nm:{value:.{decimals}f}" - for wavelength, value in zip(sd.wavelengths, sd.values) + for wavelength, value in zip(sd.wavelengths, sd.values, strict=True) ) @@ -496,7 +496,7 @@ def read_spectral_image_Fichet2021( components = {} for component, wavelengths_indexes in specification.components.items(): - wavelengths, indexes = zip(*wavelengths_indexes.items()) + wavelengths, indexes = zip(*wavelengths_indexes.items(), strict=True) values = as_float_array( image[:, :, indexes], dtype=bit_depth_specification.numpy, diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index ef0612a6f..ea34843b5 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -1571,7 +1571,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: interpolator(a[0], a[1], **interpolator_kwargs), **extrapolator_kwargs, )(a[2]) - for a in zip((s_R, s_G, s_B), (R_t, G_t, B_t), (R, G, B)) + for a in zip((s_R, s_G, s_B), (R_t, G_t, B_t), (R, G, B), strict=True) ] return tstack(RGB_i) diff --git a/colour/io/tabular.py b/colour/io/tabular.py index a884ccdde..9754e8a49 100644 --- a/colour/io/tabular.py +++ b/colour/io/tabular.py @@ -137,7 +137,7 @@ def read_spectral_data_from_csv_file( delimiter = cast(str, settings.get("delimiter", ",")) with open(path) as csv_file: - content = zip(*csv.reader(csv_file, delimiter=delimiter)) + content = zip(*csv.reader(csv_file, delimiter=delimiter), strict=True) settings["delimiter"] = "," diff --git a/colour/io/tests/test_tabular.py b/colour/io/tests/test_tabular.py index 7b6b276f1..c4ee1555b 100644 --- a/colour/io/tests/test_tabular.py +++ b/colour/io/tests/test_tabular.py @@ -132,7 +132,10 @@ def test_read_spectral_data_from_csv_file(self) -> None: colour_checker_n_ohta = os.path.join(ROOT_RESOURCES, "colorchecker_n_ohta.csv") data = read_spectral_data_from_csv_file(colour_checker_n_ohta) assert list(data.keys()) == ["wavelength"] + [str(x) for x in range(1, 25)] - assert dict(zip(data["wavelength"], data["1"])) == COLOURCHECKER_N_OHTA_1 + assert ( + dict(zip(data["wavelength"], data["1"], strict=True)) + == COLOURCHECKER_N_OHTA_1 + ) colour_checker_n_ohta_transposed = os.path.join( ROOT_RESOURCES, "colorchecker_n_ohta_transposed.csv" @@ -141,7 +144,10 @@ def test_read_spectral_data_from_csv_file(self) -> None: colour_checker_n_ohta_transposed, transpose=True, delimiter="\t" ) assert list(data.keys()) == ["wavelength"] + [str(x) for x in range(1, 25)] - assert dict(zip(data["wavelength"], data["1"])) == COLOURCHECKER_N_OHTA_1 + assert ( + dict(zip(data["wavelength"], data["1"], strict=True)) + == COLOURCHECKER_N_OHTA_1 + ) linss2_10e_5 = os.path.join(ROOT_RESOURCES, "linss2_10e_5.csv") data = read_spectral_data_from_csv_file( diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index a5723d2a6..47b8735d4 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -581,6 +581,7 @@ def _generate_unit_tests_specifications() -> tuple: # pragma: no cover [0.31006, 0.31616, 0.89710353], [0.31006, 0.31616, 1.00000000], ), + strict=True, ) ), dtype=object, # pyright: ignore diff --git a/colour/plotting/characterisation.py b/colour/plotting/characterisation.py index 88103e685..e91f048ba 100644 --- a/colour/plotting/characterisation.py +++ b/colour/plotting/characterisation.py @@ -171,6 +171,7 @@ def plot_multi_colour_checkers( for pairs in zip( colour_swatches[0 : len(colour_swatches) // 2], colour_swatches[len(colour_swatches) // 2 :], + strict=True, ) for swatch in pairs ] diff --git a/colour/plotting/common.py b/colour/plotting/common.py index cf6696982..a3cff567e 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -878,7 +878,7 @@ def uniform_axes3d(**kwargs: Any) -> Tuple[Figure, Axes3D]: centers = np.mean(extents, axis=1) extent = np.max(np.abs(extents[..., 1] - extents[..., 0])) - for center, axis in zip(centers, "xyz"): + for center, axis in zip(centers, "xyz", strict=True): getattr(axes, f"set_{axis}lim")(center - extent / 2, center + extent / 2) return figure, axes diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index f74619748..c5f2d4231 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -297,7 +297,7 @@ def lines_spectral_locus( # Labels Normals ij_n, colour_l, normal_l = [], [], [] - wl_ij_cmfs = dict(zip(wavelengths, ij_cmfs)) + wl_ij_cmfs = dict(zip(wavelengths, ij_cmfs, strict=True)) for label in cast(Tuple, labels): ij_l = wl_ij_cmfs.get(label) diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index f990e7671..dc26308a9 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -932,7 +932,7 @@ def optimize( return coefficients with tqdm(total=total_coefficients) as progress: - for ijk, chroma in zip(cube_indexes, chromas): + for ijk, chroma in zip(cube_indexes, chromas, strict=True): progress.update() # Starts from somewhere in the middle, similarly to how diff --git a/colour/recovery/tests/test__init__.py b/colour/recovery/tests/test__init__.py index e2d27e1cf..eb8dab758 100644 --- a/colour/recovery/tests/test__init__.py +++ b/colour/recovery/tests/test__init__.py @@ -68,7 +68,7 @@ def test_domain_range_scale_XYZ_to_sd(self) -> None: ] d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1)) - for method, value in zip(m, v): + for method, value in zip(m, v, strict=True): for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): np.testing.assert_allclose( diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index 3194d167c..86d1b6828 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -333,9 +333,9 @@ def __repr__(self) -> str: """ if is_documentation_building(): # pragma: no cover - representation = repr(dict(zip(self.keys(), ["..."] * len(self)))).replace( - "'...'", "..." - ) + representation = repr( + dict(zip(self.keys(), ["..."] * len(self), strict=True)) + ).replace("'...'", "...") return f"{self.__class__.__name__}({representation})" else: return f"{self.__class__.__name__}({dict(self.items())})" @@ -385,16 +385,22 @@ def __getitem__(self, item: str | Any) -> Any: pass try: - return self[dict(zip(self.lower_keys(), self.keys()))[str(item).lower()]] + return self[ + dict(zip(self.lower_keys(), self.keys(), strict=True))[ + str(item).lower() + ] + ] except KeyError: pass try: - return self[dict(zip(self.slugified_keys(), self.keys()))[item]] + return self[ + dict(zip(self.slugified_keys(), self.keys(), strict=True))[item] + ] except KeyError: pass - return self[dict(zip(self.canonical_keys(), self.keys()))[item]] + return self[dict(zip(self.canonical_keys(), self.keys(), strict=True))[item]] def __delitem__(self, item: str | Any) -> None: """ @@ -420,18 +426,22 @@ def __delitem__(self, item: str | Any) -> None: pass try: - del self._data[dict(zip(self.lower_keys(), self.keys()))[str(item).lower()]] + del self._data[ + dict(zip(self.lower_keys(), self.keys(), strict=True))[ + str(item).lower() + ] + ] return except KeyError: pass try: - del self[dict(zip(self.slugified_keys(), self.keys()))[item]] + del self[dict(zip(self.slugified_keys(), self.keys(), strict=True))[item]] return except KeyError: pass - del self[dict(zip(self.canonical_keys(), self.keys()))[item]] + del self[dict(zip(self.canonical_keys(), self.keys(), strict=True))[item]] def __contains__(self, item: str | Any) -> bool: """ @@ -639,7 +649,7 @@ def slugified_items(self) -> Generator: Item generator. """ - yield from zip(self.slugified_keys(), self.values()) + yield from zip(self.slugified_keys(), self.values(), strict=True) def canonical_keys(self) -> Generator: """ @@ -669,7 +679,7 @@ def canonical_items(self) -> Generator: Item generator. """ - yield from zip(self.canonical_keys(), self.values()) + yield from zip(self.canonical_keys(), self.values(), strict=True) class LazyCanonicalMapping(CanonicalMapping): diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index e5fdcad14..a929f688e 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -485,7 +485,8 @@ def test_as_array(self) -> None: assert as_array([1, 2, 3], DTYPE_INT_DEFAULT).dtype == DTYPE_INT_DEFAULT np.testing.assert_equal( - as_array(dict(zip("abc", [1, 2, 3])).values()), np.array([1, 2, 3]) + as_array(dict(zip("abc", [1, 2, 3], strict=True)).values()), + np.array([1, 2, 3]), ) diff --git a/pyproject.toml b/pyproject.toml index f1f9354ee..f01f0932f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,7 +193,6 @@ select = [ ] ignore = [ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` - "B905", "D104", "D200", "D202", From 227af2c5db7eb49609777176c64bf97801a4d608 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:00:19 +1300 Subject: [PATCH 09/42] Enable `D104` check. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f01f0932f..01c043509 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,7 +193,6 @@ select = [ ] ignore = [ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` - "D104", "D200", "D202", "D205", @@ -231,6 +230,7 @@ typing-modules = ["colour.hints"] convention = "numpy" [tool.ruff.per-file-ignores] +"__init__.py" = ["D104"] "colour/examples/*" = ["INP", "T201", "T203"] "docs/*" = ["INP"] "tasks.py" = ["INP"] From 9bbfe9ec4899e3644d756e885675a8114bd6a761 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:09:15 +1300 Subject: [PATCH 10/42] Enable `PIE804` check. --- colour/io/tm2714.py | 104 ++++---- .../rgb/transfer_functions/itur_bt_2100.py | 4 +- colour/plotting/common.py | 230 ++++++++---------- colour/plotting/volume.py | 46 ++-- colour/utilities/tests/test_structures.py | 2 +- pyproject.toml | 29 ++- 6 files changed, 194 insertions(+), 221 deletions(-) diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 1a7e8a2df..69e8e6c2a 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -177,34 +177,32 @@ def __init__( comments: str | None = None, ) -> None: self._mapping: Structure = Structure( - **{ - "element": "Header", - "elements": ( - Element_Specification_IESTM2714("Manufacturer", "manufacturer"), - Element_Specification_IESTM2714("CatalogNumber", "catalog_number"), - Element_Specification_IESTM2714( - "Description", "description", required=True - ), - Element_Specification_IESTM2714( - "DocumentCreator", "document_creator", required=True - ), - Element_Specification_IESTM2714( - "UniqueIdentifier", "unique_identifier" - ), - Element_Specification_IESTM2714( - "MeasurementEquipment", "measurement_equipment" - ), - Element_Specification_IESTM2714("Laboratory", "laboratory"), - Element_Specification_IESTM2714("ReportNumber", "report_number"), - Element_Specification_IESTM2714("ReportDate", "report_date"), - Element_Specification_IESTM2714( - "DocumentCreationDate", - "document_creation_date", - required=True, - ), - Element_Specification_IESTM2714("Comments", "comments", False), + element="Header", + elements=( + Element_Specification_IESTM2714("Manufacturer", "manufacturer"), + Element_Specification_IESTM2714("CatalogNumber", "catalog_number"), + Element_Specification_IESTM2714( + "Description", "description", required=True ), - } + Element_Specification_IESTM2714( + "DocumentCreator", "document_creator", required=True + ), + Element_Specification_IESTM2714( + "UniqueIdentifier", "unique_identifier" + ), + Element_Specification_IESTM2714( + "MeasurementEquipment", "measurement_equipment" + ), + Element_Specification_IESTM2714("Laboratory", "laboratory"), + Element_Specification_IESTM2714("ReportNumber", "report_number"), + Element_Specification_IESTM2714("ReportDate", "report_date"), + Element_Specification_IESTM2714( + "DocumentCreationDate", + "document_creation_date", + required=True, + ), + Element_Specification_IESTM2714("Comments", "comments", False), + ), ) self._manufacturer: str | None = None @@ -913,36 +911,34 @@ def __init__( super().__init__(**kwargs) self._mapping: Structure = Structure( - **{ - "element": "SpectralDistribution", - "elements": ( - Element_Specification_IESTM2714( - "SpectralQuantity", "spectral_quantity", required=True - ), - Element_Specification_IESTM2714( - "ReflectionGeometry", "reflection_geometry" - ), - Element_Specification_IESTM2714( - "TransmissionGeometry", "transmission_geometry" - ), - Element_Specification_IESTM2714( - "BandwidthFWHM", - "bandwidth_FWHM", - read_conversion=( - lambda x: (None if x == "None" else as_float_scalar(x)) - ), - ), - Element_Specification_IESTM2714( - "BandwidthCorrected", - "bandwidth_corrected", - read_conversion=(lambda x: bool(x == "true")), - write_conversion=(lambda x: "true" if x is True else "false"), + element="SpectralDistribution", + elements=( + Element_Specification_IESTM2714( + "SpectralQuantity", "spectral_quantity", required=True + ), + Element_Specification_IESTM2714( + "ReflectionGeometry", "reflection_geometry" + ), + Element_Specification_IESTM2714( + "TransmissionGeometry", "transmission_geometry" + ), + Element_Specification_IESTM2714( + "BandwidthFWHM", + "bandwidth_FWHM", + read_conversion=( + lambda x: (None if x == "None" else as_float_scalar(x)) ), ), - "data": Element_Specification_IESTM2714( - "SpectralData", "wavelength", required=True + Element_Specification_IESTM2714( + "BandwidthCorrected", + "bandwidth_corrected", + read_conversion=(lambda x: bool(x == "true")), + write_conversion=(lambda x: "true" if x is True else "false"), ), - } + ), + data=Element_Specification_IESTM2714( + "SpectralData", "wavelength", required=True + ), ) self._path: str | None = None diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 6dabeeeb5..8136e9c1e 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -1328,7 +1328,7 @@ def ootf_BT2100_HLG( return function( E, - **filter_kwargs(function, **{"L_B": L_B, "L_W": L_W, "gamma": gamma}), + **filter_kwargs(function, L_B=L_B, L_W=L_W, gamma=gamma), ) @@ -1622,5 +1622,5 @@ def ootf_inverse_BT2100_HLG( return function( F_D, - **filter_kwargs(function, **{"L_B": L_B, "L_W": L_W, "gamma": gamma}), + **filter_kwargs(function, L_B=L_B, L_W=L_W, gamma=gamma), ) diff --git a/colour/plotting/common.py b/colour/plotting/common.py index a3cff567e..366325f14 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -128,98 +128,90 @@ ] CONSTANTS_COLOUR_STYLE: Structure = Structure( - **{ - "colour": Structure( - **{ - "darkest": "#111111", - "darker": "#222222", - "dark": "#333333", - "dim": "#505050", - "average": "#808080", - "light": "#D5D5D5", - "bright": "#EEEEEE", - "brighter": "#F0F0F0", - "brightest": "#F5F5F5", - "cycle": ( - "#F44336", - "#9C27B0", - "#3F51B5", - "#03A9F4", - "#009688", - "#8BC34A", - "#FFEB3B", - "#FF9800", - "#795548", - "#607D8B", - ), - "map": LinearSegmentedColormap.from_list( - "colour", - ( - "#F44336", - "#9C27B0", - "#3F51B5", - "#03A9F4", - "#009688", - "#8BC34A", - "#FFEB3B", - "#FF9800", - "#795548", - "#607D8B", - ), - ), - "colourspace": RGB_COLOURSPACES["sRGB"], - } + colour=Structure( + darkest="#111111", + darker="#222222", + dark="#333333", + dim="#505050", + average="#808080", + light="#D5D5D5", + bright="#EEEEEE", + brighter="#F0F0F0", + brightest="#F5F5F5", + cycle=( + "#F44336", + "#9C27B0", + "#3F51B5", + "#03A9F4", + "#009688", + "#8BC34A", + "#FFEB3B", + "#FF9800", + "#795548", + "#607D8B", ), - "font": Structure( - { - "size": 10, - "scaling": Structure( - **{ - "xx_small": 0.579, - "x_small": 0.694, - "small": 0.833, - "medium": 1, - "large": 1 / 0.579, - "x_large": 1 / 0.694, - "xx_large": 1 / 0.833, - } - ), - } + map=LinearSegmentedColormap.from_list( + "colour", + ( + "#F44336", + "#9C27B0", + "#3F51B5", + "#03A9F4", + "#009688", + "#8BC34A", + "#FFEB3B", + "#FF9800", + "#795548", + "#607D8B", + ), ), - "opacity": Structure(**{"high": 0.75, "medium": 0.5, "low": 0.25}), - "geometry": Structure(**{"long": 5, "medium": 2.5, "short": 1}), - "hatch": Structure( - **{ - "patterns": ( - "\\\\", - "o", - "x", - ".", - "*", - "//", - ) - } - ), - "zorder": Structure( - { - "background_polygon": -140, - "background_scatter": -130, - "background_line": -120, - "background_annotation": -110, - "background_label": -100, - "midground_polygon": -90, - "midground_scatter": -80, - "midground_line": -70, - "midground_annotation": -60, - "midground_label": -50, - "foreground_polygon": -40, - "foreground_scatter": -30, - "foreground_line": -20, - "foreground_annotation": -10, - "foreground_label": 0, - } - ), - } + colourspace=RGB_COLOURSPACES["sRGB"], + ), + font=Structure( + { + "size": 10, + "scaling": Structure( + xx_small=0.579, + x_small=0.694, + small=0.833, + medium=1, + large=1 / 0.579, + x_large=1 / 0.694, + xx_large=1 / 0.833, + ), + } + ), + opacity=Structure(high=0.75, medium=0.5, low=0.25), + geometry=Structure(long=5, medium=2.5, short=1), + hatch=Structure( + patterns=( + "\\\\", + "o", + "x", + ".", + "*", + "//", + ) + ), + zorder=Structure( + { + "background_polygon": -140, + "background_scatter": -130, + "background_line": -120, + "background_annotation": -110, + "background_label": -100, + "midground_polygon": -90, + "midground_scatter": -80, + "midground_line": -70, + "midground_annotation": -60, + "midground_label": -50, + "foreground_polygon": -40, + "foreground_scatter": -30, + "foreground_line": -20, + "foreground_annotation": -10, + "foreground_label": 0, + } + ), ) """Various defaults settings used across the plotting sub-package.""" @@ -233,14 +225,12 @@ del _scaling, _value CONSTANTS_ARROW_STYLE: Structure = Structure( - **{ - "color": CONSTANTS_COLOUR_STYLE.colour.dark, - "headwidth": CONSTANTS_COLOUR_STYLE.geometry.short * 4, - "headlength": CONSTANTS_COLOUR_STYLE.geometry.long, - "width": CONSTANTS_COLOUR_STYLE.geometry.short * 0.5, - "shrink": CONSTANTS_COLOUR_STYLE.geometry.short * 0.1, - "connectionstyle": "arc3,rad=-0.2", - } + color=CONSTANTS_COLOUR_STYLE.colour.dark, + headwidth=CONSTANTS_COLOUR_STYLE.geometry.short * 4, + headlength=CONSTANTS_COLOUR_STYLE.geometry.long, + width=CONSTANTS_COLOUR_STYLE.geometry.short * 0.5, + shrink=CONSTANTS_COLOUR_STYLE.geometry.short * 0.1, + connectionstyle="arc3,rad=-0.2", ) """Annotation arrow settings used across the plotting sub-package.""" @@ -488,10 +478,8 @@ def colour_cycle(**kwargs: Any) -> itertools.cycle: """ settings = Structure( - **{ - "colour_cycle_map": CONSTANTS_COLOUR_STYLE.colour.map, - "colour_cycle_count": len(CONSTANTS_COLOUR_STYLE.colour.cycle), - } + colour_cycle_map=CONSTANTS_COLOUR_STYLE.colour.map, + colour_cycle_count=len(CONSTANTS_COLOUR_STYLE.colour.cycle), ) settings.update(kwargs) @@ -601,9 +589,7 @@ def camera(**kwargs: KwargsCamera | Any) -> Tuple[Figure, Axes3D]: figure = cast(Figure, kwargs.get("figure", plt.gcf())) axes = cast(Axes3D, kwargs.get("axes", plt.gca())) - settings = Structure( - **{"camera_aspect": "equal", "elevation": None, "azimuth": None} - ) + settings = Structure(camera_aspect="equal", elevation=None, azimuth=None) settings.update(kwargs) if settings.camera_aspect == "equal": @@ -719,24 +705,22 @@ def render( ) settings = Structure( - **{ - "filename": None, - "show": True, - "block": True, - "aspect": None, - "axes_visible": True, - "bounding_box": None, - "tight_layout": True, - "legend": False, - "legend_columns": 1, - "transparent_background": True, - "title": None, - "wrap_title": True, - "x_label": None, - "y_label": None, - "x_ticker": True, - "y_ticker": True, - } + filename=None, + show=True, + block=True, + aspect=None, + axes_visible=True, + bounding_box=None, + tight_layout=True, + legend=False, + legend_columns=1, + transparent_background=True, + title=None, + wrap_title=True, + x_label=None, + y_label=None, + x_ticker=True, + y_ticker=True, ) settings.update(kwargs) diff --git a/colour/plotting/volume.py b/colour/plotting/volume.py index a199d3834..6f30461d5 100644 --- a/colour/plotting/volume.py +++ b/colour/plotting/volume.py @@ -191,19 +191,17 @@ def nadir_grid( extent = np.max(np.abs(limits[..., 1] - limits[..., 0])) settings = Structure( - **{ - "grid_face_colours": (0.25, 0.25, 0.25), - "grid_edge_colours": (0.50, 0.50, 0.50), - "grid_face_alpha": 0.1, - "grid_edge_alpha": 0.5, - "x_axis_colour": (0.0, 0.0, 0.0, 1.0), - "y_axis_colour": (0.0, 0.0, 0.0, 1.0), - "x_ticks_colour": (0.0, 0.0, 0.0, 0.85), - "y_ticks_colour": (0.0, 0.0, 0.0, 0.85), - "x_label_colour": (0.0, 0.0, 0.0, 0.85), - "y_label_colour": (0.0, 0.0, 0.0, 0.85), - "ticks_and_label_location": ("-x", "-y"), - } + grid_face_colours=(0.25, 0.25, 0.25), + grid_edge_colours=(0.50, 0.50, 0.50), + grid_face_alpha=0.1, + grid_edge_alpha=0.5, + x_axis_colour=(0.0, 0.0, 0.0, 1.0), + y_axis_colour=(0.0, 0.0, 0.0, 1.0), + x_ticks_colour=(0.0, 0.0, 0.0, 0.85), + y_ticks_colour=(0.0, 0.0, 0.0, 0.85), + x_label_colour=(0.0, 0.0, 0.0, 0.85), + y_label_colour=(0.0, 0.0, 0.0, 0.85), + ticks_and_label_location=("-x", "-y"), ) settings.update(**kwargs) @@ -522,13 +520,11 @@ def plot_RGB_colourspaces_gamuts( convert_settings.update(convert_kwargs) settings = Structure( - **{ - "face_colours": [None] * count_c, - "edge_colours": [None] * count_c, - "face_alpha": [1] * count_c, - "edge_alpha": [1] * count_c, - "title": title, - } + face_colours=[None] * count_c, + edge_colours=[None] * count_c, + face_alpha=[1] * count_c, + edge_alpha=[1] * count_c, + title=title, ) settings.update(kwargs) @@ -754,12 +750,10 @@ def plot_RGB_scatter( count_c = len(colourspaces) settings = Structure( - **{ - "face_colours": [None] * count_c, - "edge_colours": [(0.25, 0.25, 0.25)] * count_c, - "face_alpha": [0.0] * count_c, - "edge_alpha": [0.1] * count_c, - } + face_colours=[None] * count_c, + edge_colours=[(0.25, 0.25, 0.25)] * count_c, + face_alpha=[0.0] * count_c, + edge_alpha=[0.1] * count_c, ) settings.update(kwargs) settings["show"] = False diff --git a/colour/utilities/tests/test_structures.py b/colour/utilities/tests/test_structures.py index fb0ea1d17..e2ce64b5f 100644 --- a/colour/utilities/tests/test_structures.py +++ b/colour/utilities/tests/test_structures.py @@ -66,7 +66,7 @@ def test_Structure(self) -> None: assert structure.John is None assert structure["John"] is None - structure.update(**{"John": "Doe", "Jane": "Doe"}) + structure.update(John="Doe", Jane="Doe") assert structure.John == "Doe" assert structure["John"] == "Doe" diff --git a/pyproject.toml b/pyproject.toml index 01c043509..bc39d77f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,21 +193,20 @@ select = [ ] ignore = [ "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` - "D200", - "D202", - "D205", - "D301", - "D400", - "I001", - "N801", - "N802", - "N803", - "N806", - "N813", - "N815", - "N816", - "PGH003", - "PIE804", + "D200", # One-line docstring should fit on one line + "D202", # No blank lines allowed after function docstring + "D205", # 1 blank line required between summary line and description + "D301", # Use `r"""` if any backslashes in a docstring + "D400", # First line should end with a period + "I001", # Import block is un-sorted or un-formatted + "N801", # Class name `.*` should use CapWords convention + "N802", # Function name `.*` should be lowercase + "N803", # Argument name `.*` should be lowercase + "N806", # Variable `.*` in function should be lowercase + "N813", # Camelcase `.*` imported as lowercase `.*` + "N815", # Variable `.*` in class scope should not be mixedCase + "N816", # Variable `.*` in global scope should not be mixedCase + "PGH003", # Use specific rule codes when ignoring type issues "PLE0605", "PLR0911", "PLR0912", From 7b6453e3155dea195840b4497028e273b1c5add0 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:09:53 +1300 Subject: [PATCH 11/42] Enable `PLE0605` check. --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index bc39d77f7..60fc6060a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -207,7 +207,6 @@ ignore = [ "N815", # Variable `.*` in class scope should not be mixedCase "N816", # Variable `.*` in global scope should not be mixedCase "PGH003", # Use specific rule codes when ignoring type issues - "PLE0605", "PLR0911", "PLR0912", "PLR0913", From a90c3aeb3954345e485815e02cb008b07e7d8943 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:13:51 +1300 Subject: [PATCH 12/42] Enable `PLR0911` check. --- colour/characterisation/correction.py | 50 +++++++++++++++------------ pyproject.toml | 1 - 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 3b1b69839..985bb6696 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -166,12 +166,12 @@ def matrix_augmented_Cheung2004( f"{closest_terms} terms!" ) - if terms == 3: # noqa: RET503 - return RGB + if terms == 3: + expansion = RGB elif terms == 4: - return tstack([R, G, B, tail]) + expansion = tstack([R, G, B, tail]) elif terms == 5: - return tstack( + expansion = tstack( [ R, G, @@ -181,7 +181,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 7: - return tstack( + expansion = tstack( [ R, G, @@ -193,7 +193,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 8: - return tstack( + expansion = tstack( [ R, G, @@ -206,7 +206,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 10: - return tstack( + expansion = tstack( [ R, G, @@ -221,7 +221,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 11: - return tstack( + expansion = tstack( [ R, G, @@ -237,7 +237,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 14: - return tstack( + expansion = tstack( [ R, G, @@ -256,7 +256,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 16: - return tstack( + expansion = tstack( [ R, G, @@ -277,7 +277,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 17: - return tstack( + expansion = tstack( [ R, G, @@ -299,7 +299,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 19: - return tstack( + expansion = tstack( [ R, G, @@ -323,7 +323,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 20: - return tstack( + expansion = tstack( [ R, G, @@ -348,7 +348,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 22: - return tstack( + expansion = tstack( [ R, G, @@ -375,7 +375,7 @@ def matrix_augmented_Cheung2004( ] ) elif terms == 35: - return tstack( + expansion = tstack( [ R, G, @@ -415,6 +415,8 @@ def matrix_augmented_Cheung2004( ] ) + return expansion + def polynomial_expansion_Finlayson2015( RGB: ArrayLike, @@ -466,11 +468,11 @@ def polynomial_expansion_Finlayson2015( f"{closest_degree} degree!" ) - if degree == 1: # noqa: RET503 - return RGB + if degree == 1: + expansion = RGB elif degree == 2: if root_polynomial_expansion: - return tstack( + expansion = tstack( [ as_float(R), as_float(G), @@ -482,7 +484,7 @@ def polynomial_expansion_Finlayson2015( ) else: - return tstack( + expansion = tstack( [ R, G, @@ -497,7 +499,7 @@ def polynomial_expansion_Finlayson2015( ) elif degree == 3: if root_polynomial_expansion: - return tstack( + expansion = tstack( [ as_float(R), as_float(G), @@ -515,7 +517,7 @@ def polynomial_expansion_Finlayson2015( ] ) else: - return tstack( + expansion = tstack( [ R, G, @@ -540,7 +542,7 @@ def polynomial_expansion_Finlayson2015( ) elif degree == 4: if root_polynomial_expansion: - return tstack( + expansion = tstack( [ as_float(R), as_float(G), @@ -567,7 +569,7 @@ def polynomial_expansion_Finlayson2015( ] ) else: - return tstack( + expansion = tstack( [ R, G, @@ -606,6 +608,8 @@ def polynomial_expansion_Finlayson2015( ] ) + return expansion + def polynomial_expansion_Vandermonde(a: ArrayLike, degree: int = 1) -> NDArrayFloat: """ diff --git a/pyproject.toml b/pyproject.toml index 60fc6060a..7147bd8e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -207,7 +207,6 @@ ignore = [ "N815", # Variable `.*` in class scope should not be mixedCase "N816", # Variable `.*` in global scope should not be mixedCase "PGH003", # Use specific rule codes when ignoring type issues - "PLR0911", "PLR0912", "PLR0913", "PLR0915", From 14c3271b458fc397a061d019fdf775c9c34a80e4 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:40:19 +1300 Subject: [PATCH 13/42] Enable `RET504` check. --- colour/adaptation/cie1994.py | 16 +--- colour/adaptation/fairchild1990.py | 4 +- colour/adaptation/fairchild2020.py | 4 +- colour/adaptation/vonkries.py | 4 +- colour/algebra/coordinates/transformations.py | 8 +- colour/algebra/interpolation.py | 8 +- colour/appearance/ciecam02.py | 84 +++++-------------- colour/appearance/hellwig2022.py | 32 ++----- colour/appearance/hunt.py | 36 ++------ colour/appearance/llab.py | 16 +--- colour/appearance/nayatani95.py | 4 +- colour/colorimetry/dominant.py | 8 +- colour/colorimetry/lefs.py | 4 +- colour/colorimetry/transformations.py | 16 +--- colour/colorimetry/tristimulus_values.py | 4 +- colour/continuous/signal.py | 4 +- colour/contrast/__init__.py | 4 +- colour/difference/delta_e.py | 4 +- colour/difference/din99.py | 4 +- colour/difference/huang2015.py | 4 +- colour/geometry/ellipse.py | 4 +- colour/geometry/intersection.py | 4 +- colour/geometry/section.py | 4 +- colour/io/luts/lut.py | 20 ++--- colour/io/tabular.py | 4 +- colour/models/cam02_ucs.py | 4 +- colour/models/cie_luv.py | 12 +-- colour/models/cie_ucs.py | 12 +-- colour/models/cie_xyy.py | 8 +- colour/models/common.py | 8 +- colour/models/hunter_lab.py | 4 +- colour/models/jzazbz.py | 12 +-- colour/models/rgb/cylindrical.py | 4 +- colour/models/rgb/derivation.py | 12 +-- colour/models/rgb/ictcp.py | 12 +-- colour/models/rgb/rgb_colourspace.py | 4 +- colour/models/rgb/ycbcr.py | 4 +- colour/notation/hexadecimal.py | 4 +- colour/phenomena/rayleigh.py | 27 ++---- colour/quality/cqs.py | 8 +- colour/utilities/deprecation.py | 4 +- colour/volume/macadam_limits.py | 4 +- colour/volume/mesh.py | 4 +- pyproject.toml | 9 +- 44 files changed, 117 insertions(+), 343 deletions(-) diff --git a/colour/adaptation/cie1994.py b/colour/adaptation/cie1994.py index 4c3459eee..3129efe15 100644 --- a/colour/adaptation/cie1994.py +++ b/colour/adaptation/cie1994.py @@ -244,9 +244,7 @@ def intermediate_values(xy_o: ArrayLike) -> NDArrayFloat: eta = (-0.27200 * x_o + 1.11962 * y_o + 0.04570) / y_o zeta = (0.91822 * (1 - x_o - y_o)) / y_o - xez = tstack([xi, eta, zeta]) - - return xez + return tstack([xi, eta, zeta]) def effective_adapting_responses( @@ -284,9 +282,7 @@ def effective_adapting_responses( Y_o = as_float_array(Y_o) E_o = as_float_array(E_o) - RGB_o = ((Y_o[..., None] * E_o[..., None]) / (100 * np.pi)) * xez - - return RGB_o + return ((Y_o[..., None] * E_o[..., None]) / (100 * np.pi)) * xez def beta_1(x: ArrayLike) -> NDArrayFloat: @@ -370,9 +366,7 @@ def exponential_factors(RGB_o: ArrayLike) -> NDArrayFloat: bG_o = beta_1(G_o) bB_o = beta_2(B_o) - bRGB_o = tstack([bR_o, bG_o, bB_o]) - - return bRGB_o + return tstack([bR_o, bG_o, bB_o]) def K_coefficient( @@ -529,6 +523,4 @@ def RGB_c( G_2 = RGB_c(eta_1, eta_2, bG_o1, bG_o2, G_1, n) B_2 = RGB_c(zeta_1, zeta_2, bB_o1, bB_o2, B_1, n) - RGB_2 = tstack([R_2, G_2, B_2]) - - return RGB_2 + return tstack([R_2, G_2, B_2]) diff --git a/colour/adaptation/fairchild1990.py b/colour/adaptation/fairchild1990.py index 4e92fbfcc..249a10708 100644 --- a/colour/adaptation/fairchild1990.py +++ b/colour/adaptation/fairchild1990.py @@ -265,6 +265,4 @@ def P_c(x: NDArrayFloat) -> NDArrayFloat: ) with sdiv_mode(): - p_LMS = P_c(m_E(LMS, LMS_E)) - - return p_LMS + return P_c(m_E(LMS, LMS_E)) diff --git a/colour/adaptation/fairchild2020.py b/colour/adaptation/fairchild2020.py index 86ca34a78..a23cbe6e7 100644 --- a/colour/adaptation/fairchild2020.py +++ b/colour/adaptation/fairchild2020.py @@ -210,9 +210,7 @@ def matrix_chromatic_adaptation_vk20( D = row_as_diagonal(sdiv(1, (D_n * LMS_n + D_r * LMS_r + D_p * LMS_p))) M_CAT = np.matmul(np.linalg.inv(M), D) - M_CAT = np.matmul(M_CAT, M) - - return M_CAT + return np.matmul(M_CAT, M) def chromatic_adaptation_vK20( diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index 919a3298b..6e02c7dea 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -126,9 +126,7 @@ def matrix_chromatic_adaptation_VonKries( D = row_as_diagonal(D) M_CAT = np.matmul(np.linalg.inv(M), D) - M_CAT = np.matmul(M_CAT, M) - - return M_CAT + return np.matmul(M_CAT, M) def chromatic_adaptation_VonKries( diff --git a/colour/algebra/coordinates/transformations.py b/colour/algebra/coordinates/transformations.py index 8bbb2475d..946a03809 100644 --- a/colour/algebra/coordinates/transformations.py +++ b/colour/algebra/coordinates/transformations.py @@ -90,9 +90,7 @@ def cartesian_to_spherical(a: ArrayLike) -> NDArrayFloat: theta = np.arccos(sdiv(z, rho)) phi = np.arctan2(y, x) - rtp = tstack([rho, theta, phi]) - - return rtp + return tstack([rho, theta, phi]) def spherical_to_cartesian(a: ArrayLike) -> NDArrayFloat: @@ -131,9 +129,7 @@ def spherical_to_cartesian(a: ArrayLike) -> NDArrayFloat: y = rho * np.sin(theta) * np.sin(phi) z = rho * np.cos(theta) - xyz = tstack([x, y, z]) - - return xyz + return tstack([x, y, z]) def cartesian_to_polar(a: ArrayLike) -> NDArrayFloat: diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 3a39aea7c..9279e9112 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -1822,9 +1822,7 @@ def table_interpolation_trilinear(V_xyz: ArrayLike, table: ArrayLike) -> NDArray -1, ) - xyz_o = np.reshape(np.sum(vertices * weights, 1), V_xyz.shape) - - return xyz_o + return np.reshape(np.sum(vertices * weights, 1), V_xyz.shape) def table_interpolation_tetrahedral(V_xyz: ArrayLike, table: ArrayLike) -> NDArrayFloat: @@ -1903,9 +1901,7 @@ def table_interpolation_tetrahedral(V_xyz: ArrayLike, table: ArrayLike) -> NDArr ], ) - xyz_o = np.reshape(xyz_o, V_xyz.shape) - - return xyz_o + return np.reshape(xyz_o, V_xyz.shape) TABLE_INTERPOLATION_METHODS = CanonicalMapping( diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 6f6346c0b..712af20a6 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -616,9 +616,7 @@ def chromatic_induction_factors(n: ArrayLike) -> NDArrayFloat: with sdiv_mode(): N_bb = N_cb = 0.725 * spow(sdiv(1, n), 0.2) - N_bbcb = tstack([N_bb, N_cb]) - - return N_bbcb + return tstack([N_bb, N_cb]) def base_exponential_non_linearity( @@ -645,9 +643,7 @@ def base_exponential_non_linearity( n = as_float_array(n) - z = 1.48 + np.sqrt(n) - - return z + return 1.48 + np.sqrt(n) def viewing_conditions_dependent_parameters( @@ -725,9 +721,7 @@ def degree_of_adaptation(F: ArrayLike, L_A: ArrayLike) -> NDArrayFloat: F = as_float_array(F) L_A = as_float_array(L_A) - D = F * (1 - (1 / 3.6) * np.exp((-L_A - 42) / 92)) - - return D + return F * (1 - (1 / 3.6) * np.exp((-L_A - 42) / 92)) def full_chromatic_adaptation_forward( @@ -849,9 +843,7 @@ def RGB_to_rgb(RGB: ArrayLike) -> NDArrayFloat: array([ 19.9969397..., 20.0018612..., 20.0135053...]) """ - rgb = vecmul(np.matmul(MATRIX_XYZ_TO_HPE, CAT_INVERSE_CAT02), RGB) - - return rgb + return vecmul(np.matmul(MATRIX_XYZ_TO_HPE, CAT_INVERSE_CAT02), RGB) def rgb_to_RGB(rgb: ArrayLike) -> NDArrayFloat: @@ -876,9 +868,7 @@ def rgb_to_RGB(rgb: ArrayLike) -> NDArrayFloat: array([ 19.9937078..., 20.0039363..., 20.0132638...]) """ - RGB = vecmul(np.matmul(CAT_CAT02, MATRIX_HPE_TO_XYZ), rgb) - - return RGB + return vecmul(np.matmul(CAT_CAT02, MATRIX_HPE_TO_XYZ), rgb) def post_adaptation_non_linear_response_compression_forward( @@ -918,9 +908,7 @@ def post_adaptation_non_linear_response_compression_forward( F_L = as_float_array(F_L) F_L_RGB = spow(F_L[..., None] * np.absolute(RGB) / 100, 0.42) - RGB_c = (400 * np.sign(RGB) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1 - - return RGB_c + return (400 * np.sign(RGB) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1 def post_adaptation_non_linear_response_compression_inverse( @@ -954,7 +942,7 @@ def post_adaptation_non_linear_response_compression_inverse( RGB = as_float_array(RGB) F_L = as_float_array(F_L) - RGB_p = ( + return ( np.sign(RGB - 0.1) * 100 / F_L[..., None] @@ -964,8 +952,6 @@ def post_adaptation_non_linear_response_compression_inverse( ) ) - return RGB_p - def opponent_colour_dimensions_forward(RGB: ArrayLike) -> NDArrayFloat: """ @@ -994,9 +980,7 @@ def opponent_colour_dimensions_forward(RGB: ArrayLike) -> NDArrayFloat: a = R - 12 * G / 11 + B / 11 b = (R + G - 2 * B) / 9 - ab = tstack([a, b]) - - return ab + return tstack([a, b]) def opponent_colour_dimensions_inverse(P_n: ArrayLike, h: ArrayLike) -> NDArrayFloat: @@ -1080,9 +1064,7 @@ def opponent_colour_dimensions_inverse(P_n: ArrayLike, h: ArrayLike) -> NDArrayF b, ) - ab = tstack([a, b]) - - return ab + return tstack([a, b]) def hue_angle(a: ArrayLike, b: ArrayLike) -> NDArrayFloat: @@ -1191,9 +1173,7 @@ def eccentricity_factor(h: ArrayLike) -> NDArrayFloat: h = as_float_array(h) - e_t = 1 / 4 * (np.cos(2 + h * np.pi / 180) + 3.8) - - return e_t + return 1 / 4 * (np.cos(2 + h * np.pi / 180) + 3.8) def achromatic_response_forward(RGB: ArrayLike, N_bb: ArrayLike) -> NDArrayFloat: @@ -1224,9 +1204,7 @@ def achromatic_response_forward(RGB: ArrayLike, N_bb: ArrayLike) -> NDArrayFloat R, G, B = tsplit(RGB) - A = (2 * R + G + (1 / 20) * B - 0.305) * N_bb - - return A + return (2 * R + G + (1 / 20) * B - 0.305) * N_bb def achromatic_response_inverse( @@ -1272,9 +1250,7 @@ def achromatic_response_inverse( c = as_float_array(c) z = as_float_array(z) - A = A_w * spow(J / 100, 1 / (c * z)) - - return A + return A_w * spow(J / 100, 1 / (c * z)) def lightness_correlate( @@ -1318,9 +1294,7 @@ def lightness_correlate( z = as_float_array(z) with sdiv_mode(): - J = 100 * spow(sdiv(A, A_w), c * z) - - return J + return 100 * spow(sdiv(A, A_w), c * z) def brightness_correlate( @@ -1363,9 +1337,7 @@ def brightness_correlate( A_w = as_float_array(A_w) F_L = as_float_array(F_L) - Q = (4 / c) * np.sqrt(J / 100) * (A_w + 4) * spow(F_L, 0.25) - - return Q + return (4 / c) * np.sqrt(J / 100) * (A_w + 4) * spow(F_L, 0.25) def temporary_magnitude_quantity_forward( @@ -1421,12 +1393,10 @@ def temporary_magnitude_quantity_forward( Ra, Ga, Ba = tsplit(RGB_a) with sdiv_mode(): - t = ((50000 / 13) * N_c * N_cb) * sdiv( + return ((50000 / 13) * N_c * N_cb) * sdiv( e_t * spow(a**2 + b**2, 0.5), Ra + Ga + 21 * Ba / 20 ) - return t - def temporary_magnitude_quantity_inverse( C: ArrayLike, J: ArrayLike, n: ArrayLike @@ -1462,9 +1432,7 @@ def temporary_magnitude_quantity_inverse( J = np.maximum(J, EPSILON) n = as_float_array(n) - t = spow(C / (np.sqrt(J / 100) * spow(1.64 - 0.29**n, 0.73)), 1 / 0.9) - - return t + return spow(C / (np.sqrt(J / 100) * spow(1.64 - 0.29**n, 0.73)), 1 / 0.9) def chroma_correlate( @@ -1523,9 +1491,7 @@ def chroma_correlate( n = as_float_array(n) t = temporary_magnitude_quantity_forward(N_c, N_cb, e_t, a, b, RGB_a) - C = spow(t, 0.9) * spow(J / 100, 0.5) * spow(1.64 - 0.29**n, 0.73) - - return C + return spow(t, 0.9) * spow(J / 100, 0.5) * spow(1.64 - 0.29**n, 0.73) def colourfulness_correlate(C: ArrayLike, F_L: ArrayLike) -> NDArrayFloat: @@ -1555,9 +1521,7 @@ def colourfulness_correlate(C: ArrayLike, F_L: ArrayLike) -> NDArrayFloat: C = as_float_array(C) F_L = as_float_array(F_L) - M = C * spow(F_L, 0.25) - - return M + return C * spow(F_L, 0.25) def saturation_correlate(M: ArrayLike, Q: ArrayLike) -> NDArrayFloat: @@ -1588,9 +1552,7 @@ def saturation_correlate(M: ArrayLike, Q: ArrayLike) -> NDArrayFloat: Q = as_float_array(Q) with sdiv_mode(): - s = 100 * spow(sdiv(M, Q), 0.5) - - return s + return 100 * spow(sdiv(M, Q), 0.5) def P( @@ -1649,9 +1611,7 @@ def P( P_2 = A / N_bb + 0.305 P_3 = ones(P_1.shape) * (21 / 20) - P_n = tstack([P_1, P_2, P_3]) - - return P_n + return tstack([P_1, P_2, P_3]) def matrix_post_adaptation_non_linear_response_compression( @@ -1688,7 +1648,7 @@ def matrix_post_adaptation_non_linear_response_compression( a = as_float_array(a) b = as_float_array(b) - RGB_a = ( + return ( vecmul( [ [460, 451, 288], @@ -1699,5 +1659,3 @@ def matrix_post_adaptation_non_linear_response_compression( ) / 1403 ) - - return RGB_a diff --git a/colour/appearance/hellwig2022.py b/colour/appearance/hellwig2022.py index 11c294014..0d4c3241e 100644 --- a/colour/appearance/hellwig2022.py +++ b/colour/appearance/hellwig2022.py @@ -677,9 +677,7 @@ def achromatic_response_forward(RGB: ArrayLike) -> NDArrayFloat: R, G, B = tsplit(RGB) - A = 2 * R + G + 0.05 * B - 0.305 - - return A + return 2 * R + G + 0.05 * B - 0.305 def opponent_colour_dimensions_inverse( @@ -724,9 +722,7 @@ def opponent_colour_dimensions_inverse( a = gamma * np.cos(hr) b = gamma * np.sin(hr) - ab = tstack([a, b]) - - return ab + return tstack([a, b]) def eccentricity_factor(h: ArrayLike) -> NDArrayFloat: @@ -759,7 +755,7 @@ def eccentricity_factor(h: ArrayLike) -> NDArrayFloat: _3_h = 3 * hr _4_h = 4 * hr - e_t = ( + return ( -0.0582 * np.cos(_h) - 0.0258 * np.cos(_2_h) - 0.1347 * np.cos(_3_h) @@ -771,8 +767,6 @@ def eccentricity_factor(h: ArrayLike) -> NDArrayFloat: + 1 ) - return e_t - def brightness_correlate( c: ArrayLike, @@ -810,9 +804,7 @@ def brightness_correlate( A_w = as_float_array(A_w) with sdiv_mode(): - Q = (2 / c) * (J / 100) * A_w - - return Q + return (2 / c) * (J / 100) * A_w def colourfulness_correlate( @@ -855,9 +847,7 @@ def colourfulness_correlate( a = as_float_array(a) b = as_float_array(b) - M = 43.0 * N_c * e_t * np.hypot(a, b) - - return M + return 43.0 * N_c * e_t * np.hypot(a, b) def chroma_correlate( @@ -891,9 +881,7 @@ def chroma_correlate( A_w = as_float_array(A_w) with sdiv_mode(): - C = 35 * sdiv(M, A_w) - - return C + return 35 * sdiv(M, A_w) def saturation_correlate(M: ArrayLike, Q: ArrayLike) -> NDArrayFloat: @@ -924,9 +912,7 @@ def saturation_correlate(M: ArrayLike, Q: ArrayLike) -> NDArrayFloat: Q = as_float_array(Q) with sdiv_mode(): - s = 100 * sdiv(M, Q) - - return s + return 100 * sdiv(M, Q) def P_p( @@ -967,9 +953,7 @@ def P_p( P_p_1 = 43 * N_c * e_t P_p_2 = A - P_p_n = tstack([P_p_1, P_p_2]) - - return P_p_n + return tstack([P_p_1, P_p_2]) def hue_angle_dependency_Hellwig2022( diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index cf85d0a02..c9fb65a96 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -763,9 +763,7 @@ def chromatic_adaptation( rgb_w = adjusted_reference_white_signals(rgb_p, B_rgb, rgb_w, p) # Computing adapted cone responses. - rgb_a = 1.0 + B_rgb * (f_n(F_L[..., None] * F_rgb * rgb / rgb_w) + D_rgb) - - return rgb_a + return 1.0 + B_rgb * (f_n(F_L[..., None] * F_rgb * rgb / rgb_w) + D_rgb) def adjusted_reference_white_signals( @@ -816,14 +814,12 @@ def adjusted_reference_white_signals( p = as_float_array(p) p_rgb = rgb_p / rgb_b - rgb_w = ( + return ( rgb_w * (spow((1 - p) * p_rgb + (1 + p) / p_rgb, 0.5)) / (spow((1 + p) * p_rgb + (1 - p) / p_rgb, 0.5)) ) - return rgb_w - def achromatic_post_adaptation_signal(rgb: ArrayLike) -> NDArrayFloat: """ @@ -849,9 +845,7 @@ def achromatic_post_adaptation_signal(rgb: ArrayLike) -> NDArrayFloat: r, g, b = tsplit(rgb) - A = 2 * r + g + (1 / 20) * b - 3.05 + 1 - - return A + return 2 * r + g + (1 / 20) * b - 3.05 + 1 def colour_difference_signals(rgb: ArrayLike) -> NDArrayFloat: @@ -883,9 +877,7 @@ def colour_difference_signals(rgb: ArrayLike) -> NDArrayFloat: C_2 = g - b C_3 = b - r - C = tstack([C_1, C_2, C_3]) - - return C + return tstack([C_1, C_2, C_3]) def hue_angle(C: ArrayLike) -> NDArrayFloat: @@ -1102,9 +1094,7 @@ def overall_chromatic_response(M_yb: ArrayLike, M_rg: ArrayLike) -> NDArrayFloat M_yb = as_float_array(M_yb) M_rg = as_float_array(M_rg) - M = spow((M_yb**2) + (M_rg**2), 0.5) - - return M + return spow((M_yb**2) + (M_rg**2), 0.5) def saturation_correlate(M: ArrayLike, rgb_a: ArrayLike) -> NDArrayFloat: @@ -1251,9 +1241,7 @@ def brightness_correlate( N_1 = spow(7 * A_w, 0.5) / (5.33 * spow(N_b, 0.13)) N_2 = (7 * A_w * spow(N_b, 0.362)) / 200 - Q = spow(7 * (A + (M / 100)), 0.6) * N_1 - N_2 - - return Q + return spow(7 * (A + (M / 100)), 0.6) * N_1 - N_2 def lightness_correlate( @@ -1297,9 +1285,7 @@ def lightness_correlate( Q_w = as_float_array(Q_w) Z = 1 + spow(Y_b / Y_w, 0.5) - J = 100 * spow(Q / Q_w, Z) - - return J + return 100 * spow(Q / Q_w, Z) def chroma_correlate( @@ -1349,12 +1335,10 @@ def chroma_correlate( Y_b_Y_w = Y_b / Y_w - C_94 = ( + return ( 2.44 * spow(s, 0.69) * (spow(Q / Q_w, Y_b_Y_w)) * (1.64 - spow(0.29, Y_b_Y_w)) ) - return C_94 - def colourfulness_correlate(F_L: ArrayLike, C_94: ArrayLike) -> NDArrayFloat: """ @@ -1383,6 +1367,4 @@ def colourfulness_correlate(F_L: ArrayLike, C_94: ArrayLike) -> NDArrayFloat: F_L = as_float_array(F_L) C_94 = as_float_array(C_94) - M_94 = spow(F_L, 0.15) * C_94 - - return M_94 + return spow(F_L, 0.15) * C_94 diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index 993a4f30a..33e150eea 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -463,9 +463,7 @@ def chromatic_adaptation( Y = tstack([Y, Y, Y]) - XYZ_r = vecmul(MATRIX_RGB_TO_XYZ_LLAB, RGB_r * Y) - - return XYZ_r + return vecmul(MATRIX_RGB_TO_XYZ_LLAB, RGB_r * Y) def f(x: ArrayLike, F_S: ArrayLike) -> NDArrayFloat: @@ -559,9 +557,7 @@ def opponent_colour_dimensions( a = 500 * (f(X / 95.05, F_S) - f(Y / 100, F_S)) b = 200 * (f(Y / 100, F_S) - f(Z / 108.88, F_S)) - Lab = tstack([L, a, b]) - - return Lab + return tstack([L, a, b]) def hue_angle(a: ArrayLike, b: ArrayLike) -> NDArrayFloat: @@ -701,9 +697,7 @@ def saturation_correlate(Ch_L: ArrayLike, L_L: ArrayLike) -> NDArrayFloat: Ch_L = as_float_array(Ch_L) L_L = as_float_array(L_L) - S_L = Ch_L / L_L - - return S_L + return Ch_L / L_L def final_opponent_signals(C_L: ArrayLike, h_L: ArrayLike) -> NDArrayFloat: @@ -730,6 +724,4 @@ def final_opponent_signals(C_L: ArrayLike, h_L: ArrayLike) -> NDArrayFloat: array([-0.0119478..., -0.0139711...]) """ - AB_L = polar_to_cartesian(tstack([as_float_array(C_L), np.radians(h_L)])) - - return AB_L + return polar_to_cartesian(tstack([as_float_array(C_L), np.radians(h_L)])) diff --git a/colour/appearance/nayatani95.py b/colour/appearance/nayatani95.py index c8911408f..ef9e3fa5f 100644 --- a/colour/appearance/nayatani95.py +++ b/colour/appearance/nayatani95.py @@ -943,9 +943,7 @@ def chroma_correlate(L_star_P: ArrayLike, S: ArrayLike) -> NDArrayFloat: L_star_P = as_float_array(L_star_P) S = as_float_array(S) - C = spow(L_star_P / 50, 0.7) * S - - return C + return spow(L_star_P / 50, 0.7) * S def colourfulness_components( diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index ab2d9b83b..63be60d91 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -333,13 +333,11 @@ def excitation_purity( _wl, xy_wl, _xy_cwl = dominant_wavelength(xy, xy_n, cmfs) with sdiv_mode(): - P_e = sdiv( + return sdiv( euclidean_distance(xy_n, xy), euclidean_distance(xy_n, xy_wl), ) - return P_e - def colorimetric_purity( xy: ArrayLike, @@ -385,6 +383,4 @@ def colorimetric_purity( P_e = excitation_purity(xy, xy_n, cmfs) with sdiv_mode(): - P_c = P_e * sdiv(xy_wl[..., 1], xy[..., 1]) - - return P_c + return P_e * sdiv(xy_wl[..., 1], xy[..., 1]) diff --git a/colour/colorimetry/lefs.py b/colour/colorimetry/lefs.py index 322759c50..9316f4b91 100644 --- a/colour/colorimetry/lefs.py +++ b/colour/colorimetry/lefs.py @@ -102,9 +102,7 @@ def mesopic_weighting_function( index = mesopic_x_luminance_values.index(closest(mesopic_x_luminance_values, L_p)) x = DATA_MESOPIC_X[mesopic_x_luminance_values[index]][source][method] - V_m = (1 - x) * scotopic_lef[wavelength] + x * photopic_lef[wavelength] - - return V_m + return (1 - x) * scotopic_lef[wavelength] + x * photopic_lef[wavelength] def sd_mesopic_luminous_efficiency_function( diff --git a/colour/colorimetry/transformations.py b/colour/colorimetry/transformations.py index 2cccb70ed..668471727 100644 --- a/colour/colorimetry/transformations.py +++ b/colour/colorimetry/transformations.py @@ -131,9 +131,7 @@ def RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs( y_bar = L z_bar = z / y * L - xyz_bar = tstack([x_bar, y_bar, z_bar]) - - return xyz_bar + return tstack([x_bar, y_bar, z_bar]) def RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs( @@ -183,9 +181,7 @@ def RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs( ] ) - xyz_bar = vecmul(M, rgb_bar) - - return xyz_bar + return vecmul(M, rgb_bar) def RGB_10_degree_cmfs_to_LMS_10_degree_cmfs( @@ -289,9 +285,7 @@ def LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs( ] ) - xyz_bar = vecmul(M, lms_bar) - - return xyz_bar + return vecmul(M, lms_bar) def LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs( @@ -341,6 +335,4 @@ def LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs( ] ) - xyz_bar = vecmul(M, lms_bar) - - return xyz_bar + return vecmul(M, lms_bar) diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index f12d402ff..fbbf57cbd 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -2086,6 +2086,4 @@ def wavelength_to_XYZ( f'"[{shape.start}, {shape.end}]" domain!' ) - XYZ = np.reshape(cmfs[np.ravel(wavelength)], (*wavelength.shape, 3)) - - return XYZ + return np.reshape(cmfs[np.ravel(wavelength)], (*wavelength.shape, 3)) diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 5340b8c79..b6f19c6c6 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -1088,9 +1088,7 @@ def arithmetical_operation( return self else: - copy = ioperator(self.copy(), a) - - return copy + return ioperator(self.copy(), a) @staticmethod @ndarray_copy_enable(True) diff --git a/colour/contrast/__init__.py b/colour/contrast/__init__.py index bd3cedba8..86d6387bb 100644 --- a/colour/contrast/__init__.py +++ b/colour/contrast/__init__.py @@ -148,9 +148,7 @@ def contrast_sensitivity_function( function = CONTRAST_SENSITIVITY_METHODS[method] - S = function(**filter_kwargs(function, **kwargs)) - - return S + return function(**filter_kwargs(function, **kwargs)) __all__ += [ diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 77c7aa61b..61bfd9263 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -155,9 +155,7 @@ def delta_E_CIE1976(Lab_1: ArrayLike, Lab_2: ArrayLike) -> NDArrayFloat: 2.7335037... """ - d_E = euclidean_distance(to_domain_100(Lab_1), to_domain_100(Lab_2)) - - return d_E + return euclidean_distance(to_domain_100(Lab_1), to_domain_100(Lab_2)) def delta_E_CIE1994( diff --git a/colour/difference/din99.py b/colour/difference/din99.py index e89669c78..49e4e6960 100644 --- a/colour/difference/din99.py +++ b/colour/difference/din99.py @@ -92,9 +92,7 @@ def delta_E_DIN99( factor = 100 if get_domain_range_scale() == "1" else 1 - d_E = euclidean_distance( + return euclidean_distance( Lab_to_DIN99(Lab_1, k_E, k_CH) * factor, Lab_to_DIN99(Lab_2, k_E, k_CH) * factor, ) - - return d_E diff --git a/colour/difference/huang2015.py b/colour/difference/huang2015.py index 39854b3b6..18fe0b67e 100644 --- a/colour/difference/huang2015.py +++ b/colour/difference/huang2015.py @@ -133,6 +133,4 @@ def power_function_Huang2015( a, b = tsplit(COEFFICIENTS_HUANG2015[coefficients]) - d_E_p = a * d_E**b - - return d_E_p + return a * d_E**b diff --git a/colour/geometry/ellipse.py b/colour/geometry/ellipse.py index 87a3a535d..c0ac70dfa 100644 --- a/colour/geometry/ellipse.py +++ b/colour/geometry/ellipse.py @@ -275,9 +275,7 @@ def ellipse_fitting_Halir1998(a: ArrayLike) -> NDArrayFloat: A1 = v[:, np.nonzero(4 * v[0, :] * v[2, :] - v[1, :] ** 2 > 0)[0]] A2 = np.dot(T, A1) - A = cast(NDArrayFloat, np.ravel([A1, A2])) - - return A + return cast(NDArrayFloat, np.ravel([A1, A2])) ELLIPSE_FITTING_METHODS: CanonicalMapping = CanonicalMapping( diff --git a/colour/geometry/intersection.py b/colour/geometry/intersection.py index 966cfd185..5a7756576 100644 --- a/colour/geometry/intersection.py +++ b/colour/geometry/intersection.py @@ -89,9 +89,7 @@ def extend_line_segment( x_c = x_b + sdiv(x_b - x_a, d) * distance y_c = y_b + sdiv(y_b - y_a, d) * distance - xy_c = tstack([x_c, y_c]) - - return xy_c + return tstack([x_c, y_c]) @dataclass diff --git a/colour/geometry/section.py b/colour/geometry/section.py index 0663d4327..91dc786ec 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -245,6 +245,4 @@ def hull_section( if len(section) == 0: raise ValueError(f'No section exists on "{axis}" axis at {origin} origin!') - section = close_chord(unique_vertices(edges_to_chord(section))) - - return section + return close_chord(unique_vertices(edges_to_chord(section))) diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index ea34843b5..2f0d14960 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -610,9 +610,7 @@ def arithmetical_operation( return self else: - copy = ioperator(self.copy(), a) - - return copy + return ioperator(self.copy(), a) @abstractmethod def _validate_table(self, table: ArrayLike) -> NDArrayFloat: @@ -1050,14 +1048,12 @@ def invert(self, **kwargs: Any) -> LUT1D: # noqa: ARG002 domain_min, domain_max = self.domain domain = np.linspace(domain_min, domain_max, self.size) - LUT_i = LUT1D( + return LUT1D( table=domain, name=f"{self.name} - Inverse", domain=self.table, ) - return LUT_i - def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: """ Apply the *LUT* to given *RGB* colourspace array using given method. @@ -1465,14 +1461,12 @@ def invert(self, **kwargs: Any) -> LUT3x1D: # noqa: ARG002 domain_min, domain_max = self.domain domain = [np.linspace(domain_min[i], domain_max[i], size) for i in range(3)] - LUT_i = LUT3x1D( + return LUT3x1D( table=tstack(domain), name=f"{self.name} - Inverse", domain=self.table, ) - return LUT_i - def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: """ Apply the *LUT* to given *RGB* colourspace array using given method. @@ -1907,7 +1901,7 @@ def linear_table( np.linspace(a[0], a[1], size_array[i]) for i, a in enumerate([B, G, R]) ] - table = np.flip( + return np.flip( np.reshape( np.transpose(np.meshgrid(*samples, indexing="ij")), np.hstack([np.flip(size_array, -1), 3]), @@ -1915,8 +1909,6 @@ def linear_table( -1, ) - return table - def invert(self, **kwargs: Any) -> LUT3D: """ Compute and returns an inverse copy of the *LUT*. @@ -2114,9 +2106,7 @@ def apply(self, RGB: ArrayLike, **kwargs: Any) -> NDArrayFloat: for i, j in enumerate((R, G, B)) ] - RGB_i = interpolator(tstack(RGB_l), LUT.table, **interpolator_kwargs) - - return RGB_i + return interpolator(tstack(RGB_l), LUT.table, **interpolator_kwargs) def LUT_to_LUT( diff --git a/colour/io/tabular.py b/colour/io/tabular.py index 9754e8a49..7e868ebad 100644 --- a/colour/io/tabular.py +++ b/colour/io/tabular.py @@ -287,15 +287,13 @@ def read_sds_from_csv_file( fields = list(data.keys()) wavelength_field, sd_fields = fields[0], fields[1:] - sds = { + return { sd_field: SpectralDistribution( data[sd_field], data[wavelength_field], name=sd_field ) for sd_field in sd_fields } - return sds - def write_sds_to_csv_file( sds: Dict[str, SpectralDistribution], path: str | Path diff --git a/colour/models/cam02_ucs.py b/colour/models/cam02_ucs.py index dd9f00501..aae251777 100644 --- a/colour/models/cam02_ucs.py +++ b/colour/models/cam02_ucs.py @@ -241,7 +241,7 @@ def UCS_Luo2006_to_JMh_CIECAM02( M = np.expm1(M_p / (1 / c_2)) / c_2 - JMh = tstack( + return tstack( [ from_range_100(J), from_range_100(M), @@ -249,8 +249,6 @@ def UCS_Luo2006_to_JMh_CIECAM02( ] ) - return JMh - def JMh_CIECAM02_to_CAM02LCD(JMh: ArrayLike) -> NDArrayFloat: """ diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index a527c3436..15cb7b653 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -281,9 +281,7 @@ def Luv_to_uv( X_Y_Z = X + 15 * Y + 3 * Z with sdiv_mode(): - uv = tstack([4 * sdiv(X, X_Y_Z), 9 * sdiv(Y, X_Y_Z)]) - - return uv + return tstack([4 * sdiv(X, X_Y_Z), 9 * sdiv(Y, X_Y_Z)]) def uv_to_Luv( @@ -390,9 +388,7 @@ def Luv_uv_to_xy(uv: ArrayLike) -> NDArrayFloat: d = 6 * u - 16 * v + 12 with sdiv_mode(): - xy = tstack([sdiv(9 * u, d), sdiv(4 * v, d)]) - - return xy + return tstack([sdiv(9 * u, d), sdiv(4 * v, d)]) def xy_to_Luv_uv(xy: ArrayLike) -> NDArrayFloat: @@ -427,9 +423,7 @@ def xy_to_Luv_uv(xy: ArrayLike) -> NDArrayFloat: d = -2 * x + 12 * y + 3 with sdiv_mode(): - uv = tstack([sdiv(4 * x, d), sdiv(9 * y, d)]) - - return uv + return tstack([sdiv(4 * x, d), sdiv(9 * y, d)]) def XYZ_to_CIE1976UCS( diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index 0cf2d3968..9fba4ec3d 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -190,9 +190,7 @@ def UCS_to_uv(UVW: ArrayLike) -> NDArrayFloat: U_V_W = U + V + W with sdiv_mode(): - uv = tstack([sdiv(U, U_V_W), sdiv(V, U_V_W)]) - - return uv + return tstack([sdiv(U, U_V_W), sdiv(V, U_V_W)]) def uv_to_UCS(uv: ArrayLike, V: ArrayLike = 1) -> NDArrayFloat: @@ -267,9 +265,7 @@ def UCS_uv_to_xy(uv: ArrayLike) -> NDArrayFloat: d = 2 * u - 8 * v + 4 with sdiv_mode(): - xy = tstack([sdiv(3 * u, d), sdiv(2 * v, d)]) - - return xy + return tstack([sdiv(3 * u, d), sdiv(2 * v, d)]) def xy_to_UCS_uv(xy: ArrayLike) -> NDArrayFloat: @@ -304,9 +300,7 @@ def xy_to_UCS_uv(xy: ArrayLike) -> NDArrayFloat: d = 12 * y - 2 * x + 3 with sdiv_mode(): - uv = tstack([sdiv(4 * x, d), sdiv(6 * y, d)]) - - return uv + return tstack([sdiv(4 * x, d), sdiv(6 * y, d)]) def XYZ_to_CIE1960UCS( diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index 30fea6067..3c6be32c1 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -94,9 +94,7 @@ def XYZ_to_xyY(XYZ: ArrayLike) -> NDArrayFloat: x = sdiv(X, X_Y_Z) y = sdiv(Y, X_Y_Z) - xyY = tstack([x, y, from_range_1(Y)]) - - return xyY + return tstack([x, y, from_range_1(Y)]) def xyY_to_XYZ(xyY: ArrayLike) -> NDArrayFloat: @@ -198,9 +196,7 @@ def xyY_to_xy(xyY: ArrayLike) -> NDArrayFloat: if xyY.shape[-1] == 2: return xyY - xy = xyY[..., 0:2] - - return xy + return xyY[..., 0:2] def xy_to_xyY(xy: ArrayLike, Y: ArrayLike = 1) -> NDArrayFloat: diff --git a/colour/models/common.py b/colour/models/common.py index f8df51358..6e35237df 100644 --- a/colour/models/common.py +++ b/colour/models/common.py @@ -248,9 +248,7 @@ def Jab_to_JCh(Jab: ArrayLike) -> NDArrayFloat: C, H = tsplit(cartesian_to_polar(tstack([a, b]))) - JCh = tstack([L, C, from_range_degrees(np.degrees(H) % 360)]) - - return JCh + return tstack([L, C, from_range_degrees(np.degrees(H) % 360)]) def JCh_to_Jab(JCh: ArrayLike) -> NDArrayFloat: @@ -310,9 +308,7 @@ def JCh_to_Jab(JCh: ArrayLike) -> NDArrayFloat: a, b = tsplit(polar_to_cartesian(tstack([C, np.radians(to_domain_degrees(H))]))) - Jab = tstack([L, a, b]) - - return Jab + return tstack([L, a, b]) def XYZ_to_Iab( diff --git a/colour/models/hunter_lab.py b/colour/models/hunter_lab.py index d9637ca35..33e5fe385 100644 --- a/colour/models/hunter_lab.py +++ b/colour/models/hunter_lab.py @@ -73,9 +73,7 @@ def XYZ_to_K_ab_HunterLab1966(XYZ: ArrayLike) -> NDArrayFloat: K_a = 175 * np.sqrt(X / 98.043) K_b = 70 * np.sqrt(Z / 118.115) - K_ab = tstack([K_a, K_b]) - - return K_ab + return tstack([K_a, K_b]) def XYZ_to_Hunter_Lab( diff --git a/colour/models/jzazbz.py b/colour/models/jzazbz.py index c52e7510e..e0b12e79f 100644 --- a/colour/models/jzazbz.py +++ b/colour/models/jzazbz.py @@ -357,9 +357,7 @@ def Izazbz_to_XYZ( X_D65 = (X_p_D65 + (constants.b - 1) * Z_p_D65) / constants.b Y_D65 = (Y_p_D65 + (constants.g - 1) * X_D65) / constants.g - XYZ_D65 = tstack([X_D65, Y_D65, Z_p_D65]) - - return XYZ_D65 + return tstack([X_D65, Y_D65, Z_p_D65]) def XYZ_to_Jzazbz( @@ -434,9 +432,7 @@ def XYZ_to_Jzazbz( J_z = ((1 + constants.d) * I_z) / (1 + constants.d * I_z) - constants.d_0 - Jzazbz = tstack([J_z, a_z, b_z]) - - return Jzazbz + return tstack([J_z, a_z, b_z]) def Jzazbz_to_XYZ( @@ -507,8 +503,6 @@ def Jzazbz_to_XYZ( ) with domain_range_scale("ignore"): - XYZ_D65 = Izazbz_to_XYZ( + return Izazbz_to_XYZ( tstack([I_z, a_z, b_z]), CONSTANTS_JZAZBZ_SAFDAR2017, "Safdar 2017" ) - - return XYZ_D65 diff --git a/colour/models/rgb/cylindrical.py b/colour/models/rgb/cylindrical.py index b0040508b..6e1b838f2 100644 --- a/colour/models/rgb/cylindrical.py +++ b/colour/models/rgb/cylindrical.py @@ -342,9 +342,7 @@ def H_to_RGB(vi: NDArrayFloat, vj: NDArrayFloat, vH: NDArrayFloat) -> NDArrayFlo vi + (vj - vi) * ((2 / 3) - vH) * 6, v, ) - v = np.where(np.isnan(v), vi, v) - - return v + return np.where(np.isnan(v), vi, v) j = np.where(L < 0.5, L * (1 + S), (L + S) - (S * L)) i = 2 * L - j diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index 91289f6bb..ea049608d 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -76,9 +76,7 @@ def xy_to_z(xy: ArrayLike) -> float: x, y = tsplit(xy) - z = 1 - x - y - - return z + return 1 - x - y def normalised_primary_matrix( @@ -125,9 +123,7 @@ def normalised_primary_matrix( coefficients = np.dot(np.linalg.inv(primaries), whitepoint) coefficients = np.diagflat(coefficients) - npm = np.dot(primaries, coefficients) - - return npm + return np.dot(primaries, coefficients) def chromatically_adapted_primaries( @@ -180,9 +176,7 @@ def chromatically_adapted_primaries( chromatic_adaptation_transform, ) - P_a = XYZ_to_xyY(XYZ_a)[..., 0:2] - - return P_a + return XYZ_to_xyY(XYZ_a)[..., 0:2] def primaries_whitepoint(npm: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]: diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 14186ae17..8596c4d26 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -256,14 +256,12 @@ def RGB_to_ICtCp( with domain_range_scale("ignore"): LMS_p = oetf_BT2100_HLG(LMS) if is_hlg_method else eotf_inverse_ST2084(LMS, L_p) - ICtCp = ( + return ( vecmul(MATRIX_ICTCP_LMS_P_TO_ICTCP_BT2100_HLG_2, LMS_p) if (is_hlg_method and is_BT2100_2_method) else vecmul(MATRIX_ICTCP_LMS_P_TO_ICTCP, LMS_p) ) - return ICtCp - def ICtCp_to_RGB( ICtCp: ArrayLike, @@ -393,9 +391,7 @@ def ICtCp_to_RGB( oetf_inverse_BT2100_HLG(LMS_p) if is_hlg_method else eotf_ST2084(LMS_p, L_p) ) - RGB = vecmul(MATRIX_ICTCP_LMS_TO_RGB, LMS) - - return RGB + return vecmul(MATRIX_ICTCP_LMS_TO_RGB, LMS) def XYZ_to_ICtCp( @@ -635,11 +631,9 @@ def ICtCp_to_XYZ( RGB = ICtCp_to_RGB(ICtCp, method, L_p) - XYZ = RGB_to_XYZ( + return RGB_to_XYZ( RGB, RGB_COLOURSPACES["ITU-R BT.2020"], illuminant, chromatic_adaptation_transform, ) - - return XYZ diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 06be42397..8e1f3eeb8 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -1267,9 +1267,7 @@ def matrix_RGB_to_RGB( M = np.matmul(M_CAT, input_colourspace.matrix_RGB_to_XYZ) - M = np.matmul(output_colourspace.matrix_XYZ_to_RGB, M) - - return M + return np.matmul(output_colourspace.matrix_XYZ_to_RGB, M) def RGB_to_RGB( diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index 5647ae888..ed5d7d8aa 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -646,7 +646,7 @@ def YCbCr_to_RGB( RGB *= RGB_max - RGB_min RGB += RGB_min - RGB = ( + return ( as_int_array( round_BT2100(np.clip(RGB, 0, 2**out_bits - 1) if clamp_int else RGB) ) @@ -654,8 +654,6 @@ def YCbCr_to_RGB( else from_range_1(RGB) ) - return RGB - def RGB_to_YcCbcCrc( RGB: ArrayLike, diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 0a17d4cdb..25b72ad47 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -86,9 +86,7 @@ def RGB_to_HEX(RGB: ArrayLike) -> NDArrayStr: to_HEX = np.vectorize("{:02x}".format) HEX = to_HEX(as_int_array(RGB * 255, dtype=np.uint8)).astype(object) - HEX = np.asarray("#") + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] - - return HEX + return np.asarray("#") + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] def HEX_to_RGB(HEX: ArrayLike) -> NDArrayFloat: diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index e885b36d3..00e560427 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -240,9 +240,7 @@ def N2_depolarisation(wavelength: ArrayLike) -> NDArrayFloat: wl = as_float_array(wavelength) - N2 = 1.034 + 3.17 * 1.0e-4 * (1 / wl**2) - - return N2 + return 1.034 + 3.17 * 1.0e-4 * (1 / wl**2) def O2_depolarisation(wavelength: ArrayLike) -> NDArrayFloat: @@ -268,9 +266,7 @@ def O2_depolarisation(wavelength: ArrayLike) -> NDArrayFloat: wl = as_float_array(wavelength) - O2 = 1.096 + 1.385 * 1.0e-3 * (1 / wl**2) + 1.448 * 1.0e-4 * (1 / wl**4) - - return O2 + return 1.096 + 1.385 * 1.0e-3 * (1 / wl**2) + 1.448 * 1.0e-4 * (1 / wl**4) def F_air_Penndorf1957(wavelength: ArrayLike) -> NDArrayFloat: @@ -364,9 +360,7 @@ def F_air_Bates1984(wavelength: ArrayLike) -> NDArrayFloat: Ar = 1.00 CO2 = 1.15 - F_air = (78.084 * N2 + 20.946 * O2 + CO2 + Ar) / (78.084 + 20.946 + Ar + CO2) - - return F_air + return (78.084 * N2 + 20.946 * O2 + CO2 + Ar) / (78.084 + 20.946 + Ar + CO2) def F_air_Bodhaine1999( @@ -404,12 +398,10 @@ def F_air_Bodhaine1999( # Converting from parts per million (ppm) to parts per volume per percent. CO2_c = CO2_c * 1e-4 - F_air = (78.084 * N2 + 20.946 * O2 + 0.934 * 1 + CO2_c * 1.15) / ( + return (78.084 * N2 + 20.946 * O2 + 0.934 * 1 + CO2_c * 1.15) / ( 78.084 + 20.946 + 0.934 + CO2_c ) - return F_air - def molecular_density( temperature: ArrayLike = CONSTANT_STANDARD_AIR_TEMPERATURE, @@ -450,9 +442,7 @@ def molecular_density( avogadro_constant = as_float_array(avogadro_constant) with sdiv_mode(): - N_s = (avogadro_constant / 22.4141) * sdiv(273.15, T) * (1 / 1000) - - return N_s + return (avogadro_constant / 22.4141) * sdiv(273.15, T) * (1 / 1000) def mean_molecular_weights( @@ -482,8 +472,7 @@ def mean_molecular_weights( CO2_c = CO2_concentration * 1.0e-6 - m_a = 15.0556 * CO2_c + 28.9595 - return m_a + return 15.0556 * CO2_c + 28.9595 def gravity_List1968( @@ -528,15 +517,13 @@ def gravity_List1968( # Sea level acceleration of gravity. g0 = 980.6160 * (1 - 0.0026373 * cos2phi + 0.0000059 * cos2phi**2) - g = ( + return ( g0 - (3.085462e-4 + 2.27e-7 * cos2phi) * altitude + (7.254e-11 + 1.0e-13 * cos2phi) * altitude**2 - (1.517e-17 + 6e-20 * cos2phi) * altitude**3 ) - return g - def scattering_cross_section( wavelength: ArrayLike, diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 0c1177d21..479b68fbc 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -464,9 +464,7 @@ def CCT_factor( ) G_r = gamut_area(Lab) / GAMUT_AREA_D65 - CCT_f = 1 if G_r > 1 else G_r - - return CCT_f + return 1 if G_r > 1 else G_r def scale_conversion(D_E_ab: float, CCT_f: float, scaling_f: float) -> float: @@ -489,9 +487,7 @@ def scale_conversion(D_E_ab: float, CCT_f: float, scaling_f: float) -> float: *Colour Quality Scale* (CQS). """ - Q_a = 10 * np.log1p(np.exp((100 - scaling_f * D_E_ab) / 10)) * CCT_f - - return Q_a + return 10 * np.log1p(np.exp((100 - scaling_f * D_E_ab) / 10)) * CCT_f def delta_E_RMS( diff --git a/colour/utilities/deprecation.py b/colour/utilities/deprecation.py index 8ea2d84e4..934fc7575 100644 --- a/colour/utilities/deprecation.py +++ b/colour/utilities/deprecation.py @@ -375,14 +375,12 @@ def __dir__(self) -> list: Filtered list of names in the module local scope. """ - attributes = [ + return [ attribute for attribute in dir(self._module) if attribute not in self._changes ] - return attributes - def get_attribute(attribute: str) -> Any: """ diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index b6d149aa3..2fb3c9ad8 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -127,6 +127,4 @@ def is_within_macadam_limits( ) simplex = triangulation.find_simplex(xyY_to_XYZ(xyY), tol=tolerance) - simplex = np.where(simplex >= 0, True, False) - - return simplex + return np.where(simplex >= 0, True, False) diff --git a/colour/volume/mesh.py b/colour/volume/mesh.py index cec91bb72..09c69a240 100644 --- a/colour/volume/mesh.py +++ b/colour/volume/mesh.py @@ -67,6 +67,4 @@ def is_within_mesh_volume( triangulation = Delaunay(mesh) simplex = triangulation.find_simplex(points, tol=tolerance) - simplex = np.where(simplex >= 0, True, False) - - return simplex + return np.where(simplex >= 0, True, False) diff --git a/pyproject.toml b/pyproject.toml index 7147bd8e7..6e91cf972 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -207,11 +207,10 @@ ignore = [ "N815", # Variable `.*` in class scope should not be mixedCase "N816", # Variable `.*` in global scope should not be mixedCase "PGH003", # Use specific rule codes when ignoring type issues - "PLR0912", - "PLR0913", - "PLR0915", - "PLR2004", - "RET504", + "PLR0912", # Too many branches + "PLR0913", # Too many arguments in function definition + "PLR0915", # Too many statements + "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable "RET505", "RET506", "RET507", From 2e59bf9585a438c5a5560ae15ef7e3b8b7e738dc Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:46:33 +1300 Subject: [PATCH 14/42] Enable `RET505` check. --- colour/adaptation/cmccat2000.py | 7 +- colour/blindness/machado2009.py | 3 +- colour/characterisation/aces_it.py | 3 +- colour/colorimetry/spectrum.py | 7 +- colour/colorimetry/tristimulus_values.py | 9 +- colour/continuous/multi_signals.py | 3 +- colour/continuous/signal.py | 9 +- colour/io/ctl.py | 5 +- colour/io/fichet2021.py | 3 +- colour/io/image.py | 3 +- colour/io/luts/__init__.py | 3 +- colour/io/luts/lut.py | 48 ++- colour/io/ocio.py | 5 +- colour/io/tm2714.py | 10 +- colour/models/rgb/rgb_colourspace.py | 6 +- colour/models/rgb/transfer_functions/aces.py | 3 +- .../models/rgb/transfer_functions/common.py | 6 +- colour/models/rgb/transfer_functions/dcdm.py | 3 +- .../rgb/transfer_functions/dicom_gsdf.py | 3 +- colour/models/rgb/transfer_functions/gamma.py | 8 +- .../rgb/transfer_functions/itur_bt_2100.py | 20 +- colour/models/rgb/transfer_functions/log.py | 12 +- .../rgb/transfer_functions/rimm_romm_rgb.py | 9 +- colour/models/rgb/ycbcr.py | 6 +- colour/notation/munsell.py | 333 +++++++++--------- colour/plotting/common.py | 11 +- colour/plotting/tm3018/report.py | 6 +- colour/quality/cfi2017.py | 3 +- colour/quality/cqs.py | 3 +- colour/quality/cri.py | 3 +- colour/recovery/jakob2019.py | 13 +- colour/recovery/jiang2013.py | 3 +- colour/recovery/otsu2018.py | 43 +-- colour/utilities/array.py | 6 +- colour/utilities/common.py | 3 +- colour/utilities/deprecation.py | 3 +- colour/utilities/network.py | 9 +- colour/utilities/requirements.py | 19 +- colour/utilities/structures.py | 3 +- pyproject.toml | 1 - 40 files changed, 290 insertions(+), 366 deletions(-) diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index b1855a2f8..a249c3839 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -380,7 +380,6 @@ def chromatic_adaptation_CMCCAT2000( return chromatic_adaptation_forward_CMCCAT2000( XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround ) - else: - return chromatic_adaptation_inverse_CMCCAT2000( - XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround - ) + return chromatic_adaptation_inverse_CMCCAT2000( + XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround + ) diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index 8eaeb1826..53cc158fb 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -377,5 +377,4 @@ def matrix_cvd_Machado2009( if a == b: # 1.0 severity CVD matrix, returning directly. return m1 - else: - return m1 + (severity - a) * ((m2 - m1) / (b - a)) + return m1 + (severity - a) * ((m2 - m1) / (b - a)) diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 0e11e93b7..298f5ab7b 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -1102,8 +1102,7 @@ def matrix_idt( if additional_data: return M, RGB_w, XYZ, RGB - else: - return M, RGB_w + return M, RGB_w def camera_RGB_to_ACES2065_1( diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index e5d242a69..1e1acdb8d 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -450,8 +450,7 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, SpectralShape): return np.array_equal(self.wavelengths, other.wavelengths) - else: - return False + return False def __ne__(self, other: Any) -> bool: """ @@ -2824,7 +2823,7 @@ def sds_and_msds_to_sds( if isinstance(sds, SpectralDistribution): return sds_and_msds_to_sds([sds]) - elif isinstance(sds, MultiSpectralDistributions): + if isinstance(sds, MultiSpectralDistributions): sds_converted = sds.to_sds() else: sds_converted = [] @@ -2925,7 +2924,7 @@ def sds_and_msds_to_msds( if isinstance(sds, SpectralDistribution): return sds_and_msds_to_msds([sds]) - elif isinstance(sds, MultiSpectralDistributions): + if isinstance(sds, MultiSpectralDistributions): msds_converted = sds else: sds_converted = sds_and_msds_to_sds(sds) diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index fbbf57cbd..85023576c 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -1737,11 +1737,10 @@ def msds_to_XYZ_ASTME308( for sd in msds.to_sds() ] ) - else: - raise TypeError( - '"ASTM E308-15" method does not support "ArrayLike" ' - "multi-spectral distributions!" - ) + raise TypeError( + '"ASTM E308-15" method does not support "ArrayLike" ' + "multi-spectral distributions!" + ) MSDS_TO_XYZ_METHODS = CanonicalMapping( diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 1d8e702fa..bca659b4a 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -1016,8 +1016,7 @@ def __eq__(self, other: Any) -> bool: self.labels == other.labels, ] ) - else: - return False + return False def __ne__(self, other: Any) -> bool: """ diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index b6f19c6c6..dc7172b3b 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -714,8 +714,7 @@ def __getitem__(self, x: ArrayLike | slice) -> NDArrayFloat: if isinstance(x, slice): return self._range[x] - else: - return self.function(x) + return self.function(x) def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: """ @@ -894,8 +893,7 @@ def __eq__(self, other: Any) -> bool: repr(self._extrapolator_kwargs) == repr(other.extrapolator_kwargs), ] ) - else: - return False + return False def __ne__(self, other: Any) -> bool: """ @@ -1087,8 +1085,7 @@ def arithmetical_operation( self.range = ioperator(self._range, a) return self - else: - return ioperator(self.copy(), a) + return ioperator(self.copy(), a) @staticmethod @ndarray_copy_enable(True) diff --git a/colour/io/ctl.py b/colour/io/ctl.py index cddf6f6d3..a71923e41 100644 --- a/colour/io/ctl.py +++ b/colour/io/ctl.py @@ -297,10 +297,9 @@ def process_image_ctl( if len(shape) == 0: return as_float(np.squeeze(b)[0]) - elif shape[-1] == 1: + if shape[-1] == 1: return np.reshape(b[..., 0], shape) - else: - return np.reshape(b, shape) + return np.reshape(b, shape) def template_ctl_transform_float( diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index cef72e166..dcfaedf86 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -508,8 +508,7 @@ def read_spectral_image_Fichet2021( if additional_data: return components, specification - else: - return components + return components def sds_and_msds_to_components_Fichet2021( diff --git a/colour/io/image.py b/colour/io/image.py index b8997bc22..163a81c6b 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -415,8 +415,7 @@ def read_image_OpenImageIO( ) return image, tuple(extra_attributes) - else: - return image + return image def read_image_Imageio( diff --git a/colour/io/luts/__init__.py b/colour/io/luts/__init__.py index 0047dc906..8287271b1 100644 --- a/colour/io/luts/__init__.py +++ b/colour/io/luts/__init__.py @@ -228,8 +228,7 @@ def read_LUT( if method == "iridas cube": function = LUT_READ_METHODS["Resolve Cube"] return function(path, **filter_kwargs(function, **kwargs)) - else: - raise ValueError from error + raise ValueError from error LUT_WRITE_METHODS = CanonicalMapping( diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 2f0d14960..594b44fc3 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -609,8 +609,7 @@ def arithmetical_operation( self.table = operator(self.table, operand) return self - else: - return ioperator(self.copy(), a) + return ioperator(self.copy(), a) @abstractmethod def _validate_table(self, table: ArrayLike) -> NDArrayFloat: @@ -1000,10 +999,9 @@ def linear_table( if len(domain) != 2: return domain - else: - attest(is_numeric(size), "Linear table size must be a numeric!") + attest(is_numeric(size), "Linear table size must be a numeric!") - return np.linspace(domain[0], domain[1], as_int_scalar(size)) + return np.linspace(domain[0], domain[1], as_int_scalar(size)) def invert(self, **kwargs: Any) -> LUT1D: # noqa: ARG002 """ @@ -1366,32 +1364,30 @@ def linear_table( if domain.shape != (2, 3): return domain - else: - size_array = np.tile(size, 3) if is_numeric(size) else as_int_array(size) + size_array = np.tile(size, 3) if is_numeric(size) else as_int_array(size) - R, G, B = tsplit(domain) + R, G, B = tsplit(domain) - samples = [ - np.linspace(a[0], a[1], size_array[i]) for i, a in enumerate([R, G, B]) - ] + samples = [ + np.linspace(a[0], a[1], size_array[i]) for i, a in enumerate([R, G, B]) + ] + + if len(np.unique(size_array)) != 1: + runtime_warning( + 'Table is non uniform, axis will be padded with "NaNs" accordingly!' + ) - if len(np.unique(size_array)) != 1: - runtime_warning( - "Table is non uniform, axis will be " - 'padded with "NaNs" accordingly!' + samples = [ + np.pad( + axis, + (0, np.max(size_array) - len(axis)), # pyright: ignore + mode="constant", + constant_values=np.nan, ) + for axis in samples + ] - samples = [ - np.pad( - axis, - (0, np.max(size_array) - len(axis)), # pyright: ignore - mode="constant", - constant_values=np.nan, - ) - for axis in samples - ] - - return tstack(samples) + return tstack(samples) def invert(self, **kwargs: Any) -> LUT3x1D: # noqa: ARG002 """ diff --git a/colour/io/ocio.py b/colour/io/ocio.py index 8ea1ce90c..a4070e51b 100644 --- a/colour/io/ocio.py +++ b/colour/io/ocio.py @@ -152,7 +152,6 @@ def process_image_OpenColorIO(a: ArrayLike, *args: Any, **kwargs: Any) -> NDArra if len(shape) == 0: return as_float(np.squeeze(b)[0]) - elif shape[-1] == 1: + if shape[-1] == 1: return np.reshape(b[..., 0], shape) - else: - return np.reshape(b, shape) + return np.reshape(b, shape) diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 69e8e6c2a..55f3c5015 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -1718,10 +1718,7 @@ def read(self) -> SpectralDistribution_IESTM2714: self.values = as_float_array(values) return self - else: - raise ValueError( - 'The "IES TM-27-14" spectral distribution path is undefined!' - ) + raise ValueError('The "IES TM-27-14" spectral distribution path is undefined!') def write(self) -> bool: """ @@ -1783,7 +1780,4 @@ def write(self) -> bool: file.write(xml) return True - else: - raise ValueError( - 'The "IES TM-27-14" spectral distribution path is undefined!' - ) + raise ValueError('The "IES TM-27-14" spectral distribution path is undefined!') diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 8e1f3eeb8..38c54f21f 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -429,8 +429,7 @@ def matrix_RGB_to_XYZ(self) -> NDArrayFloat: if self._derived_matrix_RGB_to_XYZ.size == 0: self._derive_transformation_matrices() return self._derived_matrix_RGB_to_XYZ - else: - return self._matrix_RGB_to_XYZ + return self._matrix_RGB_to_XYZ @matrix_RGB_to_XYZ.setter def matrix_RGB_to_XYZ(self, value: ArrayLike | None) -> None: @@ -470,8 +469,7 @@ def matrix_XYZ_to_RGB(self) -> NDArrayFloat: if self._derived_matrix_XYZ_to_RGB.size == 0: self._derive_transformation_matrices() return self._derived_matrix_XYZ_to_RGB - else: - return self._matrix_XYZ_to_RGB + return self._matrix_XYZ_to_RGB @matrix_XYZ_to_RGB.setter def matrix_XYZ_to_RGB(self, value: ArrayLike | None) -> None: diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index beb6e7ffa..21ab17363 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -195,8 +195,7 @@ def float_2_cv(x: float) -> float: if out_int: return as_int(np.round(ACESproxy)) - else: - return as_float(from_range_1(ACESproxy / (2**bit_depth - 1))) + return as_float(from_range_1(ACESproxy / (2**bit_depth - 1))) def log_decoding_ACESproxy( diff --git a/colour/models/rgb/transfer_functions/common.py b/colour/models/rgb/transfer_functions/common.py index a209a30a3..3293bdc26 100644 --- a/colour/models/rgb/transfer_functions/common.py +++ b/colour/models/rgb/transfer_functions/common.py @@ -132,8 +132,7 @@ def legal_to_full( if out_int: return as_int(np.round(CV_full * MV)) - else: - return as_float(CV_full) + return as_float(CV_full) def full_to_legal( @@ -199,5 +198,4 @@ def full_to_legal( if out_int: return as_int(np.round(CV_legal)) - else: - return as_float(CV_legal / MV) + return as_float(CV_legal / MV) diff --git a/colour/models/rgb/transfer_functions/dcdm.py b/colour/models/rgb/transfer_functions/dcdm.py index 2d10b4d31..c54b48550 100644 --- a/colour/models/rgb/transfer_functions/dcdm.py +++ b/colour/models/rgb/transfer_functions/dcdm.py @@ -100,8 +100,7 @@ def eotf_inverse_DCDM(XYZ: ArrayLike, out_int: bool = False) -> NDArrayReal: if out_int: return as_int(np.round(4095 * XYZ_p)) - else: - return as_float(XYZ_p) + return as_float(XYZ_p) def eotf_DCDM( diff --git a/colour/models/rgb/transfer_functions/dicom_gsdf.py b/colour/models/rgb/transfer_functions/dicom_gsdf.py index 9c93d8312..51fddd397 100644 --- a/colour/models/rgb/transfer_functions/dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/dicom_gsdf.py @@ -151,8 +151,7 @@ def eotf_inverse_DICOMGSDF( if out_int: return as_int(np.round(J)) - else: - return as_float(from_range_1(J / 1023)) + return as_float(from_range_1(J / 1023)) def eotf_DICOMGSDF( diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index 74c47e455..1b7455920 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -89,9 +89,9 @@ def gamma_function( if negative_number_handling == "indeterminate": return as_float(a**exponent) - elif negative_number_handling == "mirror": + if negative_number_handling == "mirror": return spow(a, exponent) - elif negative_number_handling == "preserve": + if negative_number_handling == "preserve": return as_float(np.where(a <= 0, a, a**exponent)) - else: # negative_number_handling == 'clamp': - return as_float(np.where(a <= 0, 0, a**exponent)) + # negative_number_handling == 'clamp': + return as_float(np.where(a <= 0, 0, a**exponent)) diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 8136e9c1e..237560766 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -1149,10 +1149,9 @@ def ootf_BT2100_HLG_1( if is_single_channel: return as_float(from_range_1(R_D)) - else: - RGB_D = tstack([R_D, G_D, B_D]) + RGB_D = tstack([R_D, G_D, B_D]) - return from_range_1(RGB_D) + return from_range_1(RGB_D) def ootf_BT2100_HLG_2( @@ -1236,10 +1235,9 @@ def ootf_BT2100_HLG_2( if is_single_channel: return as_float(from_range_1(R_D)) - else: - RGB_D = tstack([R_D, G_D, B_D]) + RGB_D = tstack([R_D, G_D, B_D]) - return from_range_1(RGB_D) + return from_range_1(RGB_D) BT2100_HLG_OOTF_METHODS: CanonicalMapping = CanonicalMapping( @@ -1432,10 +1430,9 @@ def ootf_inverse_BT2100_HLG_1( if is_single_channel: return as_float(from_range_1(R_S)) - else: - RGB_S = tstack([R_S, G_S, B_S]) + RGB_S = tstack([R_S, G_S, B_S]) - return from_range_1(RGB_S) + return from_range_1(RGB_S) def ootf_inverse_BT2100_HLG_2( @@ -1531,10 +1528,9 @@ def ootf_inverse_BT2100_HLG_2( if is_single_channel: return as_float(from_range_1(R_S)) - else: - RGB_S = tstack([R_S, G_S, B_S]) + RGB_S = tstack([R_S, G_S, B_S]) - return from_range_1(RGB_S) + return from_range_1(RGB_S) BT2100_HLG_OOTF_INVERSE_METHODS: CanonicalMapping = CanonicalMapping( diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index bb9c557cd..32f351abc 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -139,16 +139,16 @@ def logarithmic_function_basic( if style == "log10": return as_float(np.where(x >= FLT_MIN, np.log10(x), np.log10(FLT_MIN))) - elif style == "antilog10": + if style == "antilog10": return as_float(10**x) - elif style == "log2": + if style == "log2": return as_float(np.where(x >= FLT_MIN, np.log2(x), np.log2(FLT_MIN))) - elif style == "antilog2": + if style == "antilog2": return as_float(2**x) - elif style == "logb": + if style == "logb": return as_float(np.log(x) / np.log(base)) - else: # style == 'antilogb' - return as_float(base**x) + # style == 'antilogb' + return as_float(base**x) def logarithmic_function_quasilog( diff --git a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py index d699d32e3..375e3ddbf 100644 --- a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py @@ -119,8 +119,7 @@ def cctf_encoding_ROMMRGB( if out_int: return as_int(np.round(X_p)) - else: - return as_float(from_range_1(X_p / I_max)) + return as_float(from_range_1(X_p / I_max)) def cctf_decoding_ROMMRGB( @@ -285,8 +284,7 @@ def cctf_encoding_RIMMRGB( if out_int: return as_int(np.round(X_p)) - else: - return as_float(from_range_1(X_p / I_max)) + return as_float(from_range_1(X_p / I_max)) def cctf_decoding_RIMMRGB( @@ -451,8 +449,7 @@ def log_encoding_ERIMMRGB( if out_int: return as_int(np.round(X_p)) - else: - return as_float(from_range_1(X_p / I_max)) + return as_float(from_range_1(X_p / I_max)) def log_decoding_ERIMMRGB( diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index ed5d7d8aa..bb7e72e83 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -516,8 +516,7 @@ def RGB_to_YCbCr( return as_int_array( round_BT2100(np.clip(YCbCr, 0, 2**out_bits - 1) if clamp_int else YCbCr) ) - else: - return from_range_1(YCbCr) + return from_range_1(YCbCr) def YCbCr_to_RGB( @@ -764,8 +763,7 @@ def RGB_to_YcCbcCrc( if out_int: return as_int_array(np.round(YcCbcCrc)) - else: - return from_range_1(YcCbcCrc) + return from_range_1(YcCbcCrc) def YcCbcCrc_to_RGB( diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index a26bd322e..68518bd2e 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -1570,17 +1570,15 @@ def normalise_munsell_specification(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return specification * np.array([np.nan, 1, np.nan, np.nan]) # pyright: ignore - else: - hue, value, chroma, code = specification + hue, value, chroma, code = specification - if hue == 0: - # 0YR is equivalent to 10R. - hue, code = 10, (code + 1) % 10 + if hue == 0: + # 0YR is equivalent to 10R. + hue, code = 10, (code + 1) % 10 - if chroma == 0: - return tstack([np.nan, value, np.nan, np.nan]) - else: - return tstack([hue, value, chroma, code]) + if chroma == 0: + return tstack([np.nan, value, np.nan, np.nan]) + return tstack([hue, value, chroma, code]) def munsell_colour_to_munsell_specification( @@ -1648,49 +1646,47 @@ def munsell_specification_to_munsell_colour( if is_grey_munsell_colour(specification): return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) - else: - hue = round(hue, hue_decimals) - attest( - 0 <= hue <= 10, - f'"{specification!r}" specification hue must be normalised to ' - f"domain [0, 10]!", - ) + hue = round(hue, hue_decimals) + attest( + 0 <= hue <= 10, + f'"{specification!r}" specification hue must be normalised to ' + f"domain [0, 10]!", + ) - value = round(value, value_decimals) - attest( - 0 <= value <= 10, - f'"{specification!r}" specification value must be normalised to ' - f"domain [0, 10]!", - ) + value = round(value, value_decimals) + attest( + 0 <= value <= 10, + f'"{specification!r}" specification value must be normalised to ' + f"domain [0, 10]!", + ) - chroma = round(chroma, chroma_decimals) - attest( - 2 <= chroma <= 50, - f'"{specification!r}" specification chroma must be normalised to ' - f"domain [2, 50]!", - ) + chroma = round(chroma, chroma_decimals) + attest( + 2 <= chroma <= 50, + f'"{specification!r}" specification chroma must be normalised to ' + f"domain [2, 50]!", + ) - code_values = MUNSELL_HUE_LETTER_CODES.values() - code = round(code, 1) - attest( - code in code_values, - f'"{specification!r}" specification code must one of "{code_values}"!', - ) + code_values = MUNSELL_HUE_LETTER_CODES.values() + code = round(code, 1) + attest( + code in code_values, + f'"{specification!r}" specification code must one of "{code_values}"!', + ) - if value == 0: - return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) - else: - hue_letter = MUNSELL_HUE_LETTER_CODES.first_key_from_value(code) + if value == 0: + return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) + hue_letter = MUNSELL_HUE_LETTER_CODES.first_key_from_value(code) - return MUNSELL_COLOUR_EXTENDED_FORMAT.format( - hue, - hue_decimals, - hue_letter, - value, - value_decimals, - chroma, - chroma_decimals, - ) + return MUNSELL_COLOUR_EXTENDED_FORMAT.format( + hue, + hue_decimals, + hue_letter, + value, + value_decimals, + chroma, + chroma_decimals, + ) def xyY_from_renotation( @@ -2304,119 +2300,117 @@ def xy_from_renotation_ovoid(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return CCS_ILLUMINANT_MUNSELL - else: - hue, value, chroma, code = specification + hue, value, chroma, code = specification - attest( - 1 <= value <= 9, - f'"{specification}" specification value must be normalised to ' - f"domain [1, 9]!", - ) + attest( + 1 <= value <= 9, + f'"{specification}" specification value must be normalised to ' + f"domain [1, 9]!", + ) - attest( - is_integer(value), - f'"{specification}" specification value must be an int!', - ) + attest( + is_integer(value), + f'"{specification}" specification value must be an int!', + ) - value = round(value) + value = round(value) - attest( - 2 <= chroma <= 50, - f'"{specification}" specification chroma must be normalised to ' - f"domain [2, 50]!", - ) + attest( + 2 <= chroma <= 50, + f'"{specification}" specification chroma must be normalised to ' + f"domain [2, 50]!", + ) - attest( - abs(2 * (chroma / 2 - round(chroma / 2))) <= THRESHOLD_INTEGER, - f'"{specification}" specification chroma must be an int and ' - f"multiple of 2!", - ) + attest( + abs(2 * (chroma / 2 - round(chroma / 2))) <= THRESHOLD_INTEGER, + f'"{specification}" specification chroma must be an int and multiple of 2!', + ) - chroma = 2 * round(chroma / 2) + chroma = 2 * round(chroma / 2) - # Checking if renotation data is available without interpolation using - # given threshold. - if ( - abs(hue) < THRESHOLD_INTEGER - or abs(hue - 2.5) < THRESHOLD_INTEGER - or abs(hue - 5) < THRESHOLD_INTEGER - or abs(hue - 7.5) < THRESHOLD_INTEGER - or abs(hue - 10) < THRESHOLD_INTEGER - ): - hue = 2.5 * round(hue / 2.5) + # Checking if renotation data is available without interpolation using + # given threshold. + if ( + abs(hue) < THRESHOLD_INTEGER + or abs(hue - 2.5) < THRESHOLD_INTEGER + or abs(hue - 5) < THRESHOLD_INTEGER + or abs(hue - 7.5) < THRESHOLD_INTEGER + or abs(hue - 10) < THRESHOLD_INTEGER + ): + hue = 2.5 * round(hue / 2.5) - x, y, _Y = xyY_from_renotation([hue, value, chroma, code]) + x, y, _Y = xyY_from_renotation([hue, value, chroma, code]) - return tstack([x, y]) + return tstack([x, y]) - hue_code_cw, hue_code_ccw = bounding_hues_from_renotation([hue, code]) - hue_minus, code_minus = hue_code_cw - hue_plus, code_plus = hue_code_ccw + hue_code_cw, hue_code_ccw = bounding_hues_from_renotation([hue, code]) + hue_minus, code_minus = hue_code_cw + hue_plus, code_plus = hue_code_ccw - x_grey, y_grey = CCS_ILLUMINANT_MUNSELL + x_grey, y_grey = CCS_ILLUMINANT_MUNSELL - specification_minus = (hue_minus, value, chroma, code_minus) - x_minus, y_minus, Y_minus = xyY_from_renotation(specification_minus) - rho_minus, phi_minus, _z_minus = cartesian_to_cylindrical( - [x_minus - x_grey, y_minus - y_grey, Y_minus] - ) - phi_minus = np.degrees(phi_minus) + specification_minus = (hue_minus, value, chroma, code_minus) + x_minus, y_minus, Y_minus = xyY_from_renotation(specification_minus) + rho_minus, phi_minus, _z_minus = cartesian_to_cylindrical( + [x_minus - x_grey, y_minus - y_grey, Y_minus] + ) + phi_minus = np.degrees(phi_minus) - specification_plus = (hue_plus, value, chroma, code_plus) - x_plus, y_plus, Y_plus = xyY_from_renotation(specification_plus) - rho_plus, phi_plus, _z_plus = cartesian_to_cylindrical( - [x_plus - x_grey, y_plus - y_grey, Y_plus] - ) - phi_plus = np.degrees(phi_plus) + specification_plus = (hue_plus, value, chroma, code_plus) + x_plus, y_plus, Y_plus = xyY_from_renotation(specification_plus) + rho_plus, phi_plus, _z_plus = cartesian_to_cylindrical( + [x_plus - x_grey, y_plus - y_grey, Y_plus] + ) + phi_plus = np.degrees(phi_plus) - hue_angle_lower = hue_to_hue_angle([hue_minus, code_minus]) - hue_angle = hue_to_hue_angle([hue, code]) - hue_angle_upper = hue_to_hue_angle([hue_plus, code_plus]) + hue_angle_lower = hue_to_hue_angle([hue_minus, code_minus]) + hue_angle = hue_to_hue_angle([hue, code]) + hue_angle_upper = hue_to_hue_angle([hue_plus, code_plus]) - if phi_minus - phi_plus > 180: - phi_plus += 360 + if phi_minus - phi_plus > 180: + phi_plus += 360 - if hue_angle_lower == 0: - hue_angle_lower = 360 + if hue_angle_lower == 0: + hue_angle_lower = 360 - if hue_angle_lower > hue_angle_upper: - if hue_angle_lower > hue_angle: - hue_angle_lower -= 360 - else: - hue_angle_lower -= 360 - hue_angle -= 360 + if hue_angle_lower > hue_angle_upper: + if hue_angle_lower > hue_angle: + hue_angle_lower -= 360 + else: + hue_angle_lower -= 360 + hue_angle -= 360 - interpolation_method = interpolation_method_from_renotation_ovoid(specification) + interpolation_method = interpolation_method_from_renotation_ovoid(specification) - attest( - interpolation_method is not None, - f"Interpolation method must be one of: " - f"\"{', '.join(['Linear', 'Radial'])}\"", - ) + attest( + interpolation_method is not None, + f"Interpolation method must be one of: " + f"\"{', '.join(['Linear', 'Radial'])}\"", + ) - hue_angle_lower_upper = np.squeeze([hue_angle_lower, hue_angle_upper]) + hue_angle_lower_upper = np.squeeze([hue_angle_lower, hue_angle_upper]) - if interpolation_method == "Linear": - x_minus_plus = np.squeeze([x_minus, x_plus]) - y_minus_plus = np.squeeze([y_minus, y_plus]) + if interpolation_method == "Linear": + x_minus_plus = np.squeeze([x_minus, x_plus]) + y_minus_plus = np.squeeze([y_minus, y_plus]) - x = LinearInterpolator(hue_angle_lower_upper, x_minus_plus)(hue_angle) - y = LinearInterpolator(hue_angle_lower_upper, y_minus_plus)(hue_angle) - elif interpolation_method == "Radial": - rho_minus_plus = np.squeeze([rho_minus, rho_plus]) - phi_minus_plus = np.squeeze([phi_minus, phi_plus]) + x = LinearInterpolator(hue_angle_lower_upper, x_minus_plus)(hue_angle) + y = LinearInterpolator(hue_angle_lower_upper, y_minus_plus)(hue_angle) + elif interpolation_method == "Radial": + rho_minus_plus = np.squeeze([rho_minus, rho_plus]) + phi_minus_plus = np.squeeze([phi_minus, phi_plus]) - rho = as_float_array( - LinearInterpolator(hue_angle_lower_upper, rho_minus_plus)(hue_angle) - ) - phi = as_float_array( - LinearInterpolator(hue_angle_lower_upper, phi_minus_plus)(hue_angle) - ) + rho = as_float_array( + LinearInterpolator(hue_angle_lower_upper, rho_minus_plus)(hue_angle) + ) + phi = as_float_array( + LinearInterpolator(hue_angle_lower_upper, phi_minus_plus)(hue_angle) + ) - rho_phi = np.squeeze([rho, np.radians(phi)]) - x, y = tsplit(polar_to_cartesian(rho_phi) + tstack([x_grey, y_grey])) + rho_phi = np.squeeze([rho, np.radians(phi)]) + x, y = tsplit(polar_to_cartesian(rho_phi) + tstack([x_grey, y_grey])) - return tstack([x, y]) + return tstack([x, y]) def LCHab_to_munsell_specification(LCHab: ArrayLike) -> NDArrayFloat: @@ -2603,48 +2597,45 @@ def munsell_specification_to_xy(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return CCS_ILLUMINANT_MUNSELL - else: - hue, value, chroma, code = specification + hue, value, chroma, code = specification - attest( - 0 <= value <= 10, - f'"{specification}" specification value must be normalised to ' - f"domain [0, 10]!", - ) + attest( + 0 <= value <= 10, + f'"{specification}" specification value must be normalised to ' + f"domain [0, 10]!", + ) - attest( - is_integer(value), - f'"{specification}" specification value must be an int!', - ) + attest( + is_integer(value), + f'"{specification}" specification value must be an int!', + ) - value = round(value) + value = round(value) - if chroma % 2 == 0: - chroma_minus = chroma_plus = chroma - else: - chroma_minus = 2 * np.floor(chroma / 2) - chroma_plus = chroma_minus + 2 + if chroma % 2 == 0: + chroma_minus = chroma_plus = chroma + else: + chroma_minus = 2 * np.floor(chroma / 2) + chroma_plus = chroma_minus + 2 - if chroma_minus == 0: - # Smallest chroma ovoid collapses to illuminant chromaticity - # coordinates. - x_minus, y_minus = CCS_ILLUMINANT_MUNSELL - else: - x_minus, y_minus = xy_from_renotation_ovoid( - [hue, value, chroma_minus, code] - ) + if chroma_minus == 0: + # Smallest chroma ovoid collapses to illuminant chromaticity + # coordinates. + x_minus, y_minus = CCS_ILLUMINANT_MUNSELL + else: + x_minus, y_minus = xy_from_renotation_ovoid([hue, value, chroma_minus, code]) - x_plus, y_plus = xy_from_renotation_ovoid([hue, value, chroma_plus, code]) + x_plus, y_plus = xy_from_renotation_ovoid([hue, value, chroma_plus, code]) - if chroma_minus == chroma_plus: - x = x_minus - y = y_minus - else: - chroma_minus_plus = np.squeeze([chroma_minus, chroma_plus]) - x_minus_plus = np.squeeze([x_minus, x_plus]) - y_minus_plus = np.squeeze([y_minus, y_plus]) + if chroma_minus == chroma_plus: + x = x_minus + y = y_minus + else: + chroma_minus_plus = np.squeeze([chroma_minus, chroma_plus]) + x_minus_plus = np.squeeze([x_minus, x_plus]) + y_minus_plus = np.squeeze([y_minus, y_plus]) - x = LinearInterpolator(chroma_minus_plus, x_minus_plus)(chroma) - y = LinearInterpolator(chroma_minus_plus, y_minus_plus)(chroma) + x = LinearInterpolator(chroma_minus_plus, x_minus_plus)(chroma) + y = LinearInterpolator(chroma_minus_plus, y_minus_plus)(chroma) - return tstack([x, y]) + return tstack([x, y]) diff --git a/colour/plotting/common.py b/colour/plotting/common.py index 366325f14..1aef7a8fa 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -534,14 +534,13 @@ def artist(**kwargs: KwargsArtist | Any) -> Tuple[Figure, Axes]: figure = plt.figure(figsize=figure_size) return figure, figure.gca() - else: - axes = cast(Axes, axes) - figure = axes.figure + axes = cast(Axes, axes) + figure = axes.figure - if isinstance(figure, SubFigure): - figure = figure.get_figure() + if isinstance(figure, SubFigure): + figure = figure.get_figure() - return cast(Figure, figure), axes + return cast(Figure, figure), axes class KwargsCamera(TypedDict): diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index aa1ce4e50..3cda3b5b3 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -788,7 +788,7 @@ def plot_single_sd_colour_rendition_report( if method == "full": return plot_single_sd_colour_rendition_report_full(sd, **kwargs) - elif method == "intermediate": + if method == "intermediate": return plot_single_sd_colour_rendition_report_intermediate(sd, **kwargs) - else: # method == 'simple' - return plot_single_sd_colour_rendition_report_simple(sd, **kwargs) + # method == 'simple' + return plot_single_sd_colour_rendition_report_simple(sd, **kwargs) diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index ab078ec49..ad28f7da5 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -235,8 +235,7 @@ def colour_fidelity_index_CIE2017( (test_tcs_colorimetry_data, reference_tcs_colorimetry_data), delta_E_s, ) - else: - return R_f + return R_f def load_TCS_CIE2017(shape: SpectralShape) -> MultiSpectralDistributions: diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 479b68fbc..4214cd7ad 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -312,8 +312,7 @@ def colour_quality_scale( Q_as, (test_vs_colorimetry_data, reference_vs_colorimetry_data), ) - else: - return Q_a + return Q_a def gamut_area(Lab: ArrayLike) -> float: diff --git a/colour/quality/cri.py b/colour/quality/cri.py index f732a0c6b..dfc571c58 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -184,8 +184,7 @@ def colour_rendering_index( Q_as, (test_tcs_colorimetry_data, reference_tcs_colorimetry_data), ) - else: - return Q_a + return Q_a def tcs_colorimetry_data( diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index dc26308a9..1f2aad8bc 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -299,8 +299,7 @@ def intermediate_XYZ_to_Lab( if additional_data: return error, derror, R, XYZ, Lab_i - else: - return error, derror + return error, derror def dimensionalise_coefficients( @@ -612,8 +611,7 @@ def XYZ_to_sd_Jakob2019( if additional_data: return sd, error - else: - return sd + return sd class LUT3D_Jakob2019: @@ -1013,10 +1011,9 @@ def RGB_to_coefficients(self, RGB: ArrayLike) -> NDArrayFloat: indexes = np.stack([i_m, i_1, i_2, i_3], axis=-1) return self._interpolator(indexes).squeeze() - else: - raise RuntimeError( - "The pre-computed lookup table has not been read or generated!" - ) + raise RuntimeError( + "The pre-computed lookup table has not been read or generated!" + ) def RGB_to_sd( self, RGB: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019 diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index 9416270b6..99c117b4b 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -130,8 +130,7 @@ def normalised_sensitivity( (R_w_v[1], G_w_v[1], B_w_v[1]), (R_w_v[0], G_w_v[0], B_w_v[0]), ) - else: - return R_w_v[1], G_w_v[1], B_w_v[1] + return R_w_v[1], G_w_v[1], B_w_v[1] def RGB_to_sd_camera_sensitivity_Jiang2013( diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index c5f58cc39..9dbe37609 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -243,8 +243,7 @@ def __str__(self) -> str: f"{self.__class__.__name__}" f"({self._basis_functions.shape[0]} basis functions)" ) - else: - return f"{self.__class__.__name__}()" + return f"{self.__class__.__name__}()" def select(self, xy: ArrayLike) -> int: """ @@ -312,8 +311,7 @@ def cluster(self, xy: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]: index = self.select(xy) return self._basis_functions[index, :, :], self._means[index, :] - else: - raise ValueError('The "basis functions" or "means" are undefined!') + raise ValueError('The "basis functions" or "means" are undefined!') def read(self, path: str | Path) -> None: """ @@ -568,8 +566,7 @@ def XYZ_to_sd_Otsu2018( recovered_sd = np.clip(recovered_sd, 0, 1) if clip else recovered_sd return SpectralDistribution(recovered_sd, shape.wavelengths) - else: - raise ValueError('The dataset "shape" is undefined!') + raise ValueError('The dataset "shape" is undefined!') @dataclass @@ -810,8 +807,7 @@ def origin(self, i: int, direction: int) -> float: if self._xy is not None: return self._xy[i, direction] - else: - raise ValueError('The "chromaticity coordinates" are undefined!') + raise ValueError('The "chromaticity coordinates" are undefined!') def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]: """ @@ -854,11 +850,10 @@ def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]: greater._xy = self._xy[~mask, :] return lesser, greater - else: - raise ValueError( - 'The "tristimulus values" or "chromaticity coordinates" are ' - "undefined!" - ) + + raise ValueError( + 'The "tristimulus values" or "chromaticity coordinates" are undefined!' + ) def PCA(self) -> None: """ @@ -925,11 +920,10 @@ def reconstruct(self, XYZ: ArrayLike) -> SpectralDistribution: reflectance = np.clip(reflectance, 0, 1) return SpectralDistribution(reflectance, self._cmfs.wavelengths) - else: - raise ValueError( - 'The matrix "M", the "mean tristimulus values" or the ' - '"basis functions" are undefined!' - ) + raise ValueError( + 'The matrix "M", the "mean tristimulus values" or the ' + '"basis functions" are undefined!' + ) def reconstruction_error(self) -> float: """ @@ -970,8 +964,7 @@ def reconstruction_error(self) -> float: self._reconstruction_error = error return error - else: - raise ValueError('The "tristimulus values" are undefined!') + raise ValueError('The "tristimulus values" are undefined!') class Node_Otsu2018(TreeNode): @@ -1051,8 +1044,7 @@ def row(self) -> Tuple[float, float, Self, Self]: self.children[0], self.children[1], ) - else: - raise ValueError('The "partition axis" is undefined!') + raise ValueError('The "partition axis" is undefined!') def split(self, children: Sequence[Self], axis: PartitionAxis) -> None: """ @@ -1178,10 +1170,9 @@ def branch_reconstruction_error(self) -> float: if self.is_leaf(): return self.leaf_reconstruction_error() - else: - return as_float_scalar( - np.sum([child.branch_reconstruction_error() for child in self.children]) - ) + return as_float_scalar( + np.sum([child.branch_reconstruction_error() for child in self.children]) + ) class Tree_Otsu2018(Node_Otsu2018): diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 29cc38168..4aa419d7f 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -528,8 +528,7 @@ def arithmetical_operation( for field in self.keys: setattr(self, field, getattr(dataclass, field)) return self - else: - return dataclass + return dataclass # NOTE : The following messages are pre-generated for performance reasons. @@ -1884,8 +1883,7 @@ def ndarray_copy(a: NDArray) -> NDArray: if _NDARRAY_COPY_ENABLED: return np.copy(a) - else: - return a + return a def closest_indexes(a: ArrayLike, b: ArrayLike) -> NDArray: diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 064261ebb..a2af44db0 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -1038,8 +1038,7 @@ def optional(value: T | None, default: T) -> T: if value is None: return default - else: - return value + return value def slugify(object_: Any, allow_unicode: bool = False) -> str: diff --git a/colour/utilities/deprecation.py b/colour/utilities/deprecation.py index 934fc7575..463adfd44 100644 --- a/colour/utilities/deprecation.py +++ b/colour/utilities/deprecation.py @@ -359,8 +359,7 @@ def __getattr__(self, attribute: str) -> Any: if isinstance(change, ObjectFutureRemove) else get_attribute(change[1]) ) - else: - raise AttributeError(str(change)) + raise AttributeError(str(change)) return getattr(self._module, attribute) diff --git a/colour/utilities/network.py b/colour/utilities/network.py index 593ca5d18..b00f1789b 100644 --- a/colour/utilities/network.py +++ b/colour/utilities/network.py @@ -294,8 +294,7 @@ def root(self) -> Self: if self.is_root(): return self - else: - return list(self.walk_hierarchy(ascendants=True))[-1] + return list(self.walk_hierarchy(ascendants=True))[-1] @property def leaves(self) -> Generator: @@ -310,8 +309,7 @@ def leaves(self) -> Generator: if self.is_leaf(): return (node for node in (self,)) - else: - return (node for node in self.walk_hierarchy() if node.is_leaf()) + return (node for node in self.walk_hierarchy() if node.is_leaf()) @property def siblings(self) -> Generator: @@ -326,8 +324,7 @@ def siblings(self) -> Generator: if self.parent is None: return (sibling for sibling in ()) - else: - return (sibling for sibling in self.parent.children if sibling is not self) + return (sibling for sibling in self.parent.children if sibling is not self) @property def data(self) -> Any: diff --git a/colour/utilities/requirements.py b/colour/utilities/requirements.py index 71bc9412b..c5a443e4a 100644 --- a/colour/utilities/requirements.py +++ b/colour/utilities/requirements.py @@ -293,16 +293,15 @@ def is_pydot_installed(raise_exception: bool = False) -> bool: if shutil.which("fdp") is not None: return True - else: - if raise_exception: - raise RuntimeError( - '"Graphviz" is not installed, "Pydot" related API features ' - "are not available!" - "\nSee the installation guide for more information: " - "https://www.colour-science.org/installation-guide/" - ) - - return False + if raise_exception: + raise RuntimeError( + '"Graphviz" is not installed, "Pydot" related API features ' + "are not available!" + "\nSee the installation guide for more information: " + "https://www.colour-science.org/installation-guide/" + ) + + return False def is_tqdm_installed(raise_exception: bool = False) -> bool: diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index 86d1b6828..cefc29587 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -337,8 +337,7 @@ def __repr__(self) -> str: dict(zip(self.keys(), ["..."] * len(self), strict=True)) ).replace("'...'", "...") return f"{self.__class__.__name__}({representation})" - else: - return f"{self.__class__.__name__}({dict(self.items())})" + return f"{self.__class__.__name__}({dict(self.items())})" def __setitem__(self, item: str | Any, value: Any) -> None: """ diff --git a/pyproject.toml b/pyproject.toml index 6e91cf972..61dc7ea39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,6 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable - "RET505", "RET506", "RET507", "RET508", From 6a9ac959be21cdf672a438d709cc6fd60e887b6e Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:47:49 +1300 Subject: [PATCH 15/42] Enable `RET506` check. --- colour/appearance/hunt.py | 4 ++-- pyproject.toml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index c9fb65a96..507241638 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -408,7 +408,7 @@ def XYZ_to_Hunt( "illuminant or its correlated colour temperature " '"CCT_w" must be specified!' ) - elif L_AS is None and CCT_w is not None: + if L_AS is None and CCT_w is not None: L_AS = illuminant_scotopic_luminance(L_A, CCT_w) usage_warning( f'Unspecified "L_AS" argument, using approximation from "CCT": "{L_AS}"' @@ -420,7 +420,7 @@ def XYZ_to_Hunt( 'reference white scotopic response "S_w" arguments ' "need to be specified or none of them!" ) - elif S is None and S_w is None: + if S is None and S_w is None: S_p = Y S_w_p = Y_w usage_warning( diff --git a/pyproject.toml b/pyproject.toml index 61dc7ea39..62d04e8e3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,6 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable - "RET506", "RET507", "RET508", "RUF022", From daa5195d540c66e3d900225fca3e273618d48442 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:49:10 +1300 Subject: [PATCH 16/42] Enable `RET507` check. --- colour/io/luts/cinespace_csp.py | 2 +- colour/utilities/deprecation.py | 3 +-- pyproject.toml | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 8b33034ed..827afd278 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -163,7 +163,7 @@ def _parse_table_section(lines: list[str]) -> tuple[NDArrayInt, NDArrayFloat]: if line == "BEGIN METADATA": is_metadata = True continue - elif line == "END METADATA": + if line == "END METADATA": seek += i break diff --git a/colour/utilities/deprecation.py b/colour/utilities/deprecation.py index 463adfd44..c1670831d 100644 --- a/colour/utilities/deprecation.py +++ b/colour/utilities/deprecation.py @@ -554,8 +554,7 @@ def handle_arguments_deprecation(changes: dict, **kwargs: Any) -> dict: if isinstance(change, ArgumentFutureRemove): continue - else: - kwargs[change[1]] = kwargs.pop(kwarg) + kwargs[change[1]] = kwargs.pop(kwarg) else: kwargs.pop(kwarg) usage_warning(str(change)) diff --git a/pyproject.toml b/pyproject.toml index 62d04e8e3..5ffadaab7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,6 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable - "RET507", "RET508", "RUF022", "TRY003", From 6eb5a2c814f16010294ed46343174d6774613e9e Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:50:14 +1300 Subject: [PATCH 17/42] Enable `RET508` check. --- colour/recovery/jakob2019.py | 7 +++---- pyproject.toml | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 1f2aad8bc..474280f00 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -464,10 +464,9 @@ def optimize( if error > max_error: break - else: - XYZ_g = XYZ_i - coefficients_g = coefficients_0 - keep_divisions = True + XYZ_g = XYZ_i + coefficients_g = coefficients_0 + keep_divisions = True else: break diff --git a/pyproject.toml b/pyproject.toml index 5ffadaab7..259ef0a9f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,7 +211,6 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable - "RET508", "RUF022", "TRY003", "TRY300", From 25e2aa4617e89c0c5d49151c793c5bc26c2fcc8b Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 21:56:55 +1300 Subject: [PATCH 18/42] Enable `TRY300` check. --- colour/notation/munsell.py | 4 ++-- colour/recovery/jakob2019.py | 4 ++-- colour/utilities/requirements.py | 37 ++++++++++++++++---------------- colour/utilities/structures.py | 9 +++++--- pyproject.toml | 5 ++--- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 68518bd2e..de8a4fe56 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -1774,10 +1774,10 @@ def is_specification_in_renotation(specification: ArrayLike) -> bool: try: xyY_from_renotation(specification) - - return True except ValueError: return False + else: + return True def bounding_hues_from_renotation(hue_and_code: ArrayLike) -> NDArrayFloat: diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 474280f00..955b08c08 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -439,10 +439,10 @@ def optimize( method="L-BFGS-B", jac=True, ) - - return result.x, result.fun except StopMinimizationEarlyError as error: return error.coefficients, error.error + else: + return result.x, result.fun xy_n = XYZ_to_xy(sd_to_XYZ_integration(illuminant, cmfs)) diff --git a/colour/utilities/requirements.py b/colour/utilities/requirements.py index c5a443e4a..333b65ea2 100644 --- a/colour/utilities/requirements.py +++ b/colour/utilities/requirements.py @@ -70,8 +70,6 @@ def is_ctlrender_installed(raise_exception: bool = False) -> bool: if "transforms an image using one or more CTL scripts" not in stdout: raise FileNotFoundError # noqa: TRY301 - - return True except FileNotFoundError as error: # pragma: no cover if raise_exception: raise FileNotFoundError( @@ -81,6 +79,8 @@ def is_ctlrender_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_matplotlib_installed(raise_exception: bool = False) -> bool: @@ -105,8 +105,6 @@ def is_matplotlib_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import matplotlib as mpl # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -116,6 +114,8 @@ def is_matplotlib_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_networkx_installed(raise_exception: bool = False) -> bool: @@ -140,8 +140,6 @@ def is_networkx_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import networkx as nx # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -152,6 +150,8 @@ def is_networkx_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_opencolorio_installed(raise_exception: bool = False) -> bool: @@ -176,8 +176,6 @@ def is_opencolorio_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import PyOpenColorIO # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -187,6 +185,8 @@ def is_opencolorio_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_openimageio_installed(raise_exception: bool = False) -> bool: @@ -211,8 +211,6 @@ def is_openimageio_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import OpenImageIO # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -222,6 +220,8 @@ def is_openimageio_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_pandas_installed(raise_exception: bool = False) -> bool: @@ -246,8 +246,6 @@ def is_pandas_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import pandas # noqa: F401, ICN001 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -257,6 +255,8 @@ def is_pandas_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_pydot_installed(raise_exception: bool = False) -> bool: @@ -293,6 +293,7 @@ def is_pydot_installed(raise_exception: bool = False) -> bool: if shutil.which("fdp") is not None: return True + if raise_exception: raise RuntimeError( '"Graphviz" is not installed, "Pydot" related API features ' @@ -326,8 +327,6 @@ def is_tqdm_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import tqdm # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -337,6 +336,8 @@ def is_tqdm_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_trimesh_installed(raise_exception: bool = False) -> bool: @@ -361,8 +362,6 @@ def is_trimesh_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import trimesh # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -372,6 +371,8 @@ def is_trimesh_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True def is_xxhash_installed(raise_exception: bool = False) -> bool: @@ -396,8 +397,6 @@ def is_xxhash_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import xxhash # noqa: F401 - - return True except ImportError as error: # pragma: no cover if raise_exception: raise ImportError( @@ -407,6 +406,8 @@ def is_xxhash_installed(raise_exception: bool = False) -> bool: ) from error return False + else: + return True REQUIREMENTS_TO_CALLABLE: CanonicalMapping = CanonicalMapping( diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index cefc29587..dfd53a503 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -420,9 +420,10 @@ def __delitem__(self, item: str | Any) -> None: try: del self._data[item] - return except KeyError: pass + else: + return try: del self._data[ @@ -430,15 +431,17 @@ def __delitem__(self, item: str | Any) -> None: str(item).lower() ] ] - return except KeyError: pass + else: + return try: del self[dict(zip(self.slugified_keys(), self.keys(), strict=True))[item]] - return except KeyError: pass + else: + return del self[dict(zip(self.canonical_keys(), self.keys(), strict=True))[item]] diff --git a/pyproject.toml b/pyproject.toml index 259ef0a9f..da04954d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -211,9 +211,8 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable - "RUF022", - "TRY003", - "TRY300", + "RUF022", # [*] `__all__` is not sorted + "TRY003", # Avoid specifying long messages outside the exception class "UP038", ] typing-modules = ["colour.hints"] From 68510d7fa418498d495821bb60e5bc2becf8ccbf Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sat, 21 Dec 2024 22:03:08 +1300 Subject: [PATCH 19/42] Update `pyproject.toml` file. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index da04954d5..58e2b3935 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -213,7 +213,7 @@ ignore = [ "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable "RUF022", # [*] `__all__` is not sorted "TRY003", # Avoid specifying long messages outside the exception class - "UP038", + "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` ] typing-modules = ["colour.hints"] From 54732009d98d8c1614e88996c00056a2486415de Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 08:55:21 +1300 Subject: [PATCH 20/42] Enable `BLE001` check. --- colour/io/uprtek_sekonic.py | 5 +++-- colour/notation/tests/test_munsell.py | 2 +- colour/plotting/tm3018/report.py | 2 +- colour/utilities/verbose.py | 6 +++--- pyproject.toml | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/colour/io/uprtek_sekonic.py b/colour/io/uprtek_sekonic.py index efc918009..fb95e37b4 100644 --- a/colour/io/uprtek_sekonic.py +++ b/colour/io/uprtek_sekonic.py @@ -406,9 +406,10 @@ def as_array(a: Any) -> list: self._metadata[attribute] = method( value # pyright: ignore ) - break - except Exception: + except (TypeError, ValueError): self._metadata[attribute] = value + else: + break self.name = os.path.splitext(os.path.basename(path))[0] spectral_data = as_float_array( diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 47b8735d4..826673518 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -137,7 +137,7 @@ def _generate_unit_tests_specifications() -> tuple: # pragma: no cover if len(specifications) == 100: break - except Exception as error: + except (AssertionError, RuntimeError, ValueError) as error: print(specification) # noqa: T201 print(error) # noqa: T201 diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index 3cda3b5b3..5c136b617 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -204,7 +204,7 @@ def _plot_report_footer(axes: Axes) -> Axes: "colour-science.org" ]["colour"] version = f" {describe}." - except Exception: # pragma: no cover + except Exception: # pragma: no cover # noqa: BLE001 version = "." axes.set_axis_off() diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index fc70b2184..2fb8c5c49 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -803,7 +803,7 @@ def describe_environment( stderr=subprocess.STDOUT, ).strip() version = output.decode("utf-8") - except Exception: # pragma: no cover + except Exception: # pragma: no cover # noqa: BLE001 version = colour.__version__ environment["colour-science.org"]["colour"] = version @@ -886,7 +886,7 @@ def _get_package_version(package: str, mapping: Mapping) -> str: package = mapping.get(package, package) # noqa: PLW2901 environment["Development"][package] = version - except Exception: # pragma: no cover # noqa: S112 + except Exception: # pragma: no cover # noqa: BLE001, S112 continue environment["Development"].update(ANCILLARY_DEVELOPMENT_PACKAGES) @@ -899,7 +899,7 @@ def _get_package_version(package: str, mapping: Mapping) -> str: package = mapping.get(package, package) # noqa: PLW2901 environment["Extras"][package] = version - except Exception: # pragma: no cover # noqa: S112 + except Exception: # pragma: no cover # noqa: BLE001, S112 continue environment["Extras"].update(ANCILLARY_EXTRAS_PACKAGES) diff --git a/pyproject.toml b/pyproject.toml index 58e2b3935..b3ca04c8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,7 +153,7 @@ select = [ "ARG", # flake8-unused-arguments "ANN", # flake8-annotations "B", # flake8-bugbear - # "BLE", # flake8-blind-except + "BLE", # flake8-blind-except "C4", # flake8-comprehensions # "C90", # mccabe # "COM", # flake8-commas From 5c78b8f570a00e79077bd25ddf34ca53ad112070 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 09:49:03 +1300 Subject: [PATCH 21/42] Enable `EM` checks. --- colour/algebra/interpolation.py | 48 ++++++++--- colour/appearance/cam16.py | 4 +- colour/appearance/ciecam02.py | 4 +- colour/appearance/ciecam16.py | 4 +- colour/appearance/hellwig2022.py | 8 +- colour/appearance/hunt.py | 8 +- colour/appearance/kim2009.py | 4 +- colour/appearance/zcam.py | 4 +- colour/characterisation/correction.py | 8 +- colour/colorimetry/tristimulus_values.py | 21 +++-- colour/continuous/signal.py | 4 +- colour/geometry/section.py | 4 +- colour/io/ctl.py | 4 +- colour/io/image.py | 8 +- colour/io/luts/cinespace_csp.py | 4 +- colour/io/luts/lut.py | 10 ++- colour/io/luts/resolve_cube.py | 4 +- colour/io/tabular.py | 4 +- colour/io/tm2714.py | 14 ++- colour/models/rgb/itut_h_273.py | 8 +- colour/notation/munsell.py | 26 ++++-- colour/quality/cfi2017.py | 6 +- colour/recovery/jakob2019.py | 13 +-- colour/recovery/meng2015.py | 4 +- colour/recovery/otsu2018.py | 58 +++++++++---- colour/utilities/array.py | 4 +- colour/utilities/requirements.py | 104 ++++++++++++++--------- colour/utilities/structures.py | 4 +- colour/utilities/tests/test_callback.py | 6 +- pyproject.toml | 2 +- tasks.py | 12 ++- 31 files changed, 287 insertions(+), 129 deletions(-) diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 9279e9112..d9408e0d3 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -704,11 +704,13 @@ def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): - raise ValueError( + error = ( '"x" independent and "y" dependent variables have different ' f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) + raise ValueError(error) + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" @@ -716,10 +718,14 @@ def _validate_interpolation_range(self, x: NDArrayFloat) -> None: above_interpolation_range = x > self._x[-1] if below_interpolation_range.any(): - raise ValueError(f'"{x}" is below interpolation range.') + error = f'"{x}" is below interpolation range.' + + raise ValueError(error) if above_interpolation_range.any(): - raise ValueError(f'"{x}" is above interpolation range.') + error = f'"{x}" is above interpolation range.' + + raise ValueError(error) class NearestNeighbourInterpolator(KernelInterpolator): @@ -929,11 +935,13 @@ def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): - raise ValueError( + error = ( '"x" independent and "y" dependent variables have different ' f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) + raise ValueError(error) + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" @@ -941,10 +949,14 @@ def _validate_interpolation_range(self, x: NDArrayFloat) -> None: above_interpolation_range = x > self._x[-1] if below_interpolation_range.any(): - raise ValueError(f'"{x}" is below interpolation range.') + error = f'"{x}" is below interpolation range.' + + raise ValueError(error) if above_interpolation_range.any(): - raise ValueError(f'"{x}" is above interpolation range.') + error = f'"{x}" is above interpolation range.' + + raise ValueError(error) class SpragueInterpolator: @@ -1213,11 +1225,13 @@ def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): - raise ValueError( + error = ( '"x" independent and "y" dependent variables have different ' f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) + raise ValueError(error) + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" @@ -1225,10 +1239,14 @@ def _validate_interpolation_range(self, x: NDArrayFloat) -> None: above_interpolation_range = x > self._x[-1] if below_interpolation_range.any(): - raise ValueError(f'"{x}" is below interpolation range.') + error = f'"{x}" is below interpolation range.' + + raise ValueError(error) if above_interpolation_range.any(): - raise ValueError(f'"{x}" is above interpolation range.') + error = f'"{x}" is above interpolation range.' + + raise ValueError(error) class CubicSplineInterpolator(scipy.interpolate.interp1d): @@ -1584,11 +1602,13 @@ def _validate_dimensions(self) -> None: """Validate that the variables dimensions are the same.""" if len(self._x) != len(self._y): - raise ValueError( + error = ( '"x" independent and "y" dependent variables have different ' f'dimensions: "{len(self._x)}", "{len(self._y)}"' ) + raise ValueError(error) + def _validate_interpolation_range(self, x: NDArrayFloat) -> None: """Validate given point to be in interpolation range.""" @@ -1596,10 +1616,14 @@ def _validate_interpolation_range(self, x: NDArrayFloat) -> None: above_interpolation_range = x > self._x[-1] if below_interpolation_range.any(): - raise ValueError(f'"{x}" is below interpolation range.') + error = f'"{x}" is below interpolation range.' + + raise ValueError(error) if above_interpolation_range.any(): - raise ValueError(f'"{x}" is above interpolation range.') + error = f'"{x}" is above interpolation range.' + + raise ValueError(error) def lagrange_coefficients(r: float, n: int = 4) -> NDArrayFloat: diff --git a/colour/appearance/cam16.py b/colour/appearance/cam16.py index d1f9ddc51..7c159570d 100644 --- a/colour/appearance/cam16.py +++ b/colour/appearance/cam16.py @@ -469,11 +469,13 @@ def CAM16_to_XYZ( if has_only_nan(C) and not has_only_nan(M): C = M / spow(F_L, 0.25) elif has_only_nan(C): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_CAM16" argument!' ) + raise ValueError(error) + # Step 2 # Computing temporary magnitude quantity :math:`t`. t = temporary_magnitude_quantity_inverse(C, J, n) diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 712af20a6..d81e4ead0 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -527,11 +527,13 @@ def CIECAM02_to_XYZ( if has_only_nan(C) and not has_only_nan(M): C = M / spow(F_L, 0.25) elif has_only_nan(C): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_CIECAM02" argument!' ) + raise ValueError(error) + # Converting *CIE XYZ* tristimulus values to *CMCCAT2000* transform # sharpened *RGB* values. RGB_w = vecmul(CAT_CAT02, XYZ_w) diff --git a/colour/appearance/ciecam16.py b/colour/appearance/ciecam16.py index b30c7bb47..91a0ba5c3 100644 --- a/colour/appearance/ciecam16.py +++ b/colour/appearance/ciecam16.py @@ -502,11 +502,13 @@ def CIECAM16_to_XYZ( if has_only_nan(C) and not has_only_nan(M): C = M / spow(F_L, 0.25) elif has_only_nan(C): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_CIECAM16" argument!' ) + raise ValueError(error) + # Step 2 # Computing temporary magnitude quantity :math:`t`. t = temporary_magnitude_quantity_inverse(C, J, n) diff --git a/colour/appearance/hellwig2022.py b/colour/appearance/hellwig2022.py index 0d4c3241e..3b265df7d 100644 --- a/colour/appearance/hellwig2022.py +++ b/colour/appearance/hellwig2022.py @@ -536,10 +536,12 @@ def Hellwig2022_to_XYZ( J = J_HK - hue_angle_dependency_Hellwig2022(h) * spow(C, 0.587) elif has_only_nan(J): - raise ValueError( + error = ( 'Either "J" or "J_HK" correlate must be defined in ' 'the "CAM_Specification_Hellwig2022" argument!' ) + + raise ValueError(error) else: J = to_domain_100(J) @@ -573,11 +575,13 @@ def Hellwig2022_to_XYZ( if has_only_nan(M) and not has_only_nan(C): M = (C * A_w) / 35 elif has_only_nan(M): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_Hellwig2022" argument!' ) + raise ValueError(error) + # Step 2 # Computing eccentricity factor *e_t*. e_t = eccentricity_factor(h) diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 507241638..52354b583 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -403,11 +403,13 @@ def XYZ_to_Hunt( usage_warning(f'Unspecified "N_bb" argument, using approximation: "{N_bb}"') if L_AS is None and CCT_w is None: - raise ValueError( + error = ( 'Either the scotopic luminance "L_AS" of the ' "illuminant or its correlated colour temperature " '"CCT_w" must be specified!' ) + + raise ValueError(error) if L_AS is None and CCT_w is not None: L_AS = illuminant_scotopic_luminance(L_A, CCT_w) usage_warning( @@ -415,11 +417,13 @@ def XYZ_to_Hunt( ) if (S is None and S_w is not None) or (S is not None and S_w is None): - raise ValueError( + error = ( 'Either both stimulus scotopic response "S" and ' 'reference white scotopic response "S_w" arguments ' "need to be specified or none of them!" ) + + raise ValueError(error) if S is None and S_w is None: S_p = Y S_w_p = Y_w diff --git a/colour/appearance/kim2009.py b/colour/appearance/kim2009.py index 5e4e4622b..e8347c18a 100644 --- a/colour/appearance/kim2009.py +++ b/colour/appearance/kim2009.py @@ -504,11 +504,13 @@ def Kim2009_to_XYZ( a_m, b_m = 0.11, 0.61 C = M / (a_m * np.log10(Y_w) + b_m) elif has_only_nan(C): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_Kim2009" argument!' ) + raise ValueError(error) + # Cones absolute response. LMS_w_n_c = spow(LMS_w, n_c) L_A_n_c = spow(L_A, n_c) diff --git a/colour/appearance/zcam.py b/colour/appearance/zcam.py index 646434549..278c67a67 100644 --- a/colour/appearance/zcam.py +++ b/colour/appearance/zcam.py @@ -675,11 +675,13 @@ def ZCAM_to_XYZ( if has_only_nan(M_z) and not has_only_nan(C_z): M_z = (C_z * Q_z_w) / 100 elif has_only_nan(M_z): - raise ValueError( + error = ( 'Either "C" or "M" correlate must be defined in ' 'the "CAM_Specification_ZCAM" argument!' ) + raise ValueError(error) + # Step 3 (Inverse) - Computing hue angle :math:`h_z` # :math:`h_z` is currently required as an input. diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 985bb6696..6745b2ce9 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -160,12 +160,14 @@ def matrix_augmented_Cheung2004( existing_terms = np.array([3, 4, 5, 7, 8, 10, 11, 14, 16, 17, 19, 20, 22, 35]) closest_terms = as_int(closest(existing_terms, terms)) if closest_terms != terms: - raise ValueError( + error = ( f'"Cheung et al. (2004)" method does not define an augmented ' f"matrix with {terms} terms, closest augmented matrix has " f"{closest_terms} terms!" ) + raise ValueError(error) + if terms == 3: expansion = RGB elif terms == 4: @@ -462,12 +464,14 @@ def polynomial_expansion_Finlayson2015( existing_degrees = np.array([1, 2, 3, 4]) closest_degree = as_int(closest(existing_degrees, degree)) if closest_degree != degree: - raise ValueError( + error = ( f'"Finlayson et al. (2015)" method does not define a polynomial ' f"expansion for {degree} degree, closest polynomial expansion is " f"{closest_degree} degree!" ) + raise ValueError(error) + if degree == 1: expansion = RGB elif degree == 2: diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index 85023576c..d20be106f 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -377,10 +377,14 @@ def tristimulus_weighting_factors_ASTME2022( """ if cmfs.shape.interval != 1: - raise ValueError(f'"{cmfs}" shape "interval" must be 1!') + error = f'"{cmfs}" shape "interval" must be 1!' + + raise ValueError(error) if illuminant.shape.interval != 1: - raise ValueError(f'"{illuminant}" shape "interval" must be 1!') + error = f'"{illuminant}" shape "interval" must be 1!' + + raise ValueError(error) global _CACHE_TRISTIMULUS_WEIGHTING_FACTORS # noqa: PLW0602 @@ -986,12 +990,14 @@ def sd_to_XYZ_ASTME308( ) if sd.shape.interval not in (1, 5, 10, 20): - raise ValueError( + error = ( "Tristimulus values conversion from spectral data according to " 'practise "ASTM E308-15" should be performed on spectral data ' "with measurement interval of 1, 5, 10 or 20nm!" ) + raise ValueError(error) + if sd.shape.interval in (10, 20) and ( sd.shape.start % 10 != 0 or sd.shape.end % 10 != 0 ): @@ -1737,11 +1743,14 @@ def msds_to_XYZ_ASTME308( for sd in msds.to_sds() ] ) - raise TypeError( + + error = ( '"ASTM E308-15" method does not support "ArrayLike" ' "multi-spectral distributions!" ) + raise TypeError(error) + MSDS_TO_XYZ_METHODS = CanonicalMapping( {"ASTM E308": msds_to_XYZ_ASTME308, "Integration": msds_to_XYZ_integration} @@ -2080,9 +2089,11 @@ def wavelength_to_XYZ( shape = cmfs.shape if np.min(wavelength) < shape.start or np.max(wavelength) > shape.end: - raise ValueError( + error = ( f'"{wavelength}nm" wavelength is not in ' f'"[{shape.start}, {shape.end}]" domain!' ) + raise ValueError(error) + return np.reshape(cmfs[np.ravel(wavelength)], (*wavelength.shape, 3)) diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index dc7172b3b..24de4ad3d 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -557,12 +557,14 @@ def _undefined_function( ValueError """ - raise ValueError( + error = ( "Underlying signal interpolator function does not " 'exists, please ensure that both "domain" and "range" ' "variables are defined!" ) + raise ValueError(error) + self._function = cast(Callable, _undefined_function) return cast(Callable, self._function) diff --git a/colour/geometry/section.py b/colour/geometry/section.py index 91dc786ec..ca1c55b9a 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -243,6 +243,8 @@ def hull_section( section = trimesh.intersections.mesh_plane(hull, normal, plane) if len(section) == 0: - raise ValueError(f'No section exists on "{axis}" axis at {origin} origin!') + error = f'No section exists on "{axis}" axis at {origin} origin!' + + raise ValueError(error) return close_chord(unique_vertices(edges_to_chord(section))) diff --git a/colour/io/ctl.py b/colour/io/ctl.py index a71923e41..10fc18226 100644 --- a/colour/io/ctl.py +++ b/colour/io/ctl.py @@ -175,7 +175,9 @@ def ctl_render( ctl_transform = temp_filename # noqa: PLW2901 temp_filenames.append(temp_filename) elif not os.path.exists(ctl_transform): - raise FileNotFoundError(f'{ctl_transform} "CTL" transform does not exist!') + error = f'{ctl_transform} "CTL" transform does not exist!' + + raise FileNotFoundError(error) command.extend(["-ctl", ctl_transform]) for parameter in parameters: diff --git a/colour/io/image.py b/colour/io/image.py index 163a81c6b..b27730b24 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -917,17 +917,21 @@ def as_3_channels_image(a: ArrayLike) -> NDArrayFloat: a = np.squeeze(as_float_array(a)) if len(a.shape) > 3: - raise ValueError( + error = ( "Array has more than 3-dimensions and cannot be converted to a " "3-channels image-like representation!" ) + raise ValueError(error) + if len(a.shape) > 0 and a.shape[-1] not in (1, 3): - raise ValueError( + error = ( "Array has more than 1 or 3 channels and cannot be converted to a " "3-channels image-like representation!" ) + raise ValueError(error) + if len(a.shape) == 0 or a.shape[-1] == 1: a = tstack([a, a, a]) diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 827afd278..42d6b9c76 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -324,7 +324,9 @@ def write_LUT_Cinespace( LUT = LUTSequence(LUT3x1D(), LUT) else: - raise TypeError("LUT must be 1D, 3x1D, 3D, 1D + 3D or 3x1D + 3D!") + error = "LUT must be 1D, 3x1D, 3D, 1D + 3D or 3x1D + 3D!" + + raise TypeError(error) if has_3x1D: attest( diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 594b44fc3..bd6359249 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -1954,9 +1954,9 @@ def invert(self, **kwargs: Any) -> LUT3D: """ if self.is_domain_explicit(): - raise NotImplementedError( - 'Inverting a "LUT3D" with an explicit domain is not implemented!' - ) + error = 'Inverting a "LUT3D" with an explicit domain is not implemented!' + + raise NotImplementedError(error) interpolator = kwargs.get("interpolator", table_interpolation_trilinear) extrapolate = kwargs.get("extrapolate", False) @@ -2181,12 +2181,14 @@ def LUT_to_LUT( path = (ranks[LUT.__class__], ranks[cls]) # pyright: ignore path_verbose = [f"{element}D" if element != 2 else "3x1D" for element in path] if path in ((1, 3), (2, 1), (2, 3), (3, 1), (3, 2)) and not force_conversion: - raise ValueError( + error = ( f'Conversion of a "LUT" {path_verbose[0]} to a "LUT" ' f"{path_verbose[1]} is destructive, please use the " f'"force_conversion" argument to proceed!' ) + raise ValueError(error) + suffix = f" - Converted {path_verbose[0]} to {path_verbose[1]}" name = f"{LUT.name}{suffix}" diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index f95e1808b..b06f7743d 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -349,7 +349,9 @@ def write_LUT_ResolveCube( has_3D = True LUT = LUTSequence(LUT3x1D(), LUT) else: - raise TypeError("LUT must be 1D, 3x1D, 3D, 1D + 3D or 3x1D + 3D!") + error = "LUT must be 1D, 3x1D, 3D, 1D + 3D or 3x1D + 3D!" + + raise TypeError(error) for i in range(2): attest(not LUT[i].is_domain_explicit(), '"LUT" domain must be implicit!') diff --git a/colour/io/tabular.py b/colour/io/tabular.py index 7e868ebad..e015d1173 100644 --- a/colour/io/tabular.py +++ b/colour/io/tabular.py @@ -324,11 +324,13 @@ def write_sds_to_csv_file( if len(sds) != 1: shapes = [sd.shape for sd in sds.values()] if not all(shape == shapes[0] for shape in shapes): - raise ValueError( + error = ( "Cannot write spectral distributions " 'with different shapes to "CSV" file!' ) + raise ValueError(error) + wavelengths = next(iter(sds.values())).wavelengths with open(path, "w") as csv_file: fields = sorted(sds.keys()) diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 55f3c5015..de2457a17 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -1670,11 +1670,13 @@ def read(self) -> SpectralDistribution_IESTM2714: if match: namespace = match.group(1) else: - raise ValueError( + error = ( 'The "IES TM-27-14" spectral distribution namespace ' "was not found!" ) + raise ValueError(error) + self.name = os.path.splitext(os.path.basename(self._path))[0] iterator = root.iter @@ -1718,7 +1720,10 @@ def read(self) -> SpectralDistribution_IESTM2714: self.values = as_float_array(values) return self - raise ValueError('The "IES TM-27-14" spectral distribution path is undefined!') + + error = 'The "IES TM-27-14" spectral distribution path is undefined!' + + raise ValueError(error) def write(self) -> bool: """ @@ -1780,4 +1785,7 @@ def write(self) -> bool: file.write(xml) return True - raise ValueError('The "IES TM-27-14" spectral distribution path is undefined!') + + error = 'The "IES TM-27-14" spectral distribution path is undefined!' + + raise ValueError(error) diff --git a/colour/models/rgb/itut_h_273.py b/colour/models/rgb/itut_h_273.py index 96646b2a8..905caded5 100644 --- a/colour/models/rgb/itut_h_273.py +++ b/colour/models/rgb/itut_h_273.py @@ -228,7 +228,9 @@ def _reserved(*args: Any) -> NoReturn: # noqa: ARG001 ... pass """ - raise RuntimeError("Reserved; For future use by ITU-T | ISO/IEC.") + error = "Reserved; For future use by ITU-T | ISO/IEC." + + raise RuntimeError(error) def _unspecified(*args: Any) -> NoReturn: # noqa: ARG001 @@ -243,11 +245,13 @@ def _unspecified(*args: Any) -> NoReturn: # noqa: ARG001 ... pass """ - raise RuntimeError( + error = ( "Unspecified; Image characteristics are unknown or are determined by " "the application." ) + raise RuntimeError(error) + COLOUR_PRIMARIES_ITUTH273: Dict[int, NDArrayFloat] = { 0: np.array("Reserved"), diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index de8a4fe56..7ceb90dea 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -1159,8 +1159,10 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat: # 300K iterations with random numbers never reached this code # path, it is kept for consistency with the reference # implementation. + error = "Maximum inner iterations count reached without convergence!" + raise RuntimeError( # pragma: no cover - "Maximum inner iterations count reached without convergence!" + error ) hue_angle_inner = ( @@ -1269,9 +1271,9 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat: iterations_inner += 1 if iterations_inner > iterations_maximum_inner: - raise RuntimeError( - "Maximum inner iterations count reached without convergence!" - ) + error = "Maximum inner iterations count reached without convergence!" + + raise RuntimeError(error) with sdiv_mode(): chroma_inner = ( @@ -1326,8 +1328,10 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat: # NOTE: This exception is likely never raised in practice: 300K iterations # with random numbers never reached this code path, it is kept for # consistency with the reference # implementation + error = "Maximum outside iterations count reached without convergence!" + raise RuntimeError( # pragma: no cover - "Maximum outside iterations count reached without convergence!" + error ) @@ -1509,11 +1513,13 @@ def parse_munsell_colour(munsell_colour: str) -> NDArrayFloat: ] ) - raise ValueError( + error = ( f'"{munsell_colour}" is not a valid "Munsell Renotation System" ' f"colour specification!" ) + raise ValueError(error) + def is_grey_munsell_colour(specification: ArrayLike) -> bool: """ @@ -1742,11 +1748,13 @@ def xyY_from_renotation( ) return MUNSELL_COLOURS_ALL[as_int_scalar(index[0])][1] - except Exception as error: - raise ValueError( + except Exception as exception: + error = ( f'"{specification}" specification does not exists in ' '"Munsell Renotation System" data!' - ) from error + ) + + raise ValueError(error) from exception def is_specification_in_renotation(specification: ArrayLike) -> bool: diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index ad28f7da5..bc0000b90 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -167,12 +167,14 @@ def colour_fidelity_index_CIE2017( """ if sd_test.shape.interval > 5: - raise ValueError( - "Test spectral distribution interval is greater than" + error = ( + "Test spectral distribution interval is greater than " "5nm which is the maximum recommended value " 'for computing the "CIE 2017 Colour Fidelity Index"!' ) + raise ValueError(error) + shape = SpectralShape( SPECTRAL_SHAPE_CIE2017.start, SPECTRAL_SHAPE_CIE2017.end, diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 955b08c08..0d58921aa 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -1010,9 +1010,10 @@ def RGB_to_coefficients(self, RGB: ArrayLike) -> NDArrayFloat: indexes = np.stack([i_m, i_1, i_2, i_3], axis=-1) return self._interpolator(indexes).squeeze() - raise RuntimeError( - "The pre-computed lookup table has not been read or generated!" - ) + + error = "The pre-computed lookup table has not been read or generated!" + + raise RuntimeError(error) def RGB_to_sd( self, RGB: ArrayLike, shape: SpectralShape = SPECTRAL_SHAPE_JAKOB2019 @@ -1148,9 +1149,9 @@ def read(self, path: str | Path) -> LUT3D_Jakob2019: with open(path, "rb") as coeff_file: if coeff_file.read(4).decode("ISO-8859-1") != "SPEC": - raise ValueError( - "Bad magic number, this is likely not the right file type!" - ) + error = "Bad magic number, this is likely not the right file type!" + + raise ValueError(error) self._size = struct.unpack("i", coeff_file.read(4))[0] self._lightness_scale = np.fromfile( diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 5cef14dcc..6e9542b4f 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -199,11 +199,13 @@ def constraint_function(a: ArrayLike) -> NDArrayFloat: result = minimize(objective_function, sd.values, **optimisation_settings) if not result.success: - raise RuntimeError( + error = ( f"Optimisation failed for {XYZ} after {result.nit} iterations: " f'"{result.message}".' ) + raise RuntimeError(error) + return SpectralDistribution( from_range_100(result.x * 100), wavelengths, diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index 9dbe37609..dac5f8235 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -284,7 +284,9 @@ def select(self, xy: ArrayLike) -> int: else: return index else: - raise ValueError('The "selector array" is undefined!') + error = 'The "selector array" is undefined!' + + raise ValueError(error) def cluster(self, xy: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]: """ @@ -311,7 +313,10 @@ def cluster(self, xy: ArrayLike) -> Tuple[NDArrayFloat, NDArrayFloat]: index = self.select(xy) return self._basis_functions[index, :, :], self._means[index, :] - raise ValueError('The "basis functions" or "means" are undefined!') + + error = 'The "basis functions" or "means" are undefined!' + + raise ValueError(error) def read(self, path: str | Path) -> None: """ @@ -409,7 +414,9 @@ def write(self, path: str | Path) -> None: selector_array=cast(NDArrayFloat, self._selector_array), ) else: - raise ValueError('The "shape" is undefined!') + error = 'The "shape" is undefined!' + + raise ValueError(error) DATASET_REFERENCE_OTSU2018: Dataset_Otsu2018 = Dataset_Otsu2018( @@ -566,7 +573,10 @@ def XYZ_to_sd_Otsu2018( recovered_sd = np.clip(recovered_sd, 0, 1) if clip else recovered_sd return SpectralDistribution(recovered_sd, shape.wavelengths) - raise ValueError('The dataset "shape" is undefined!') + + error = 'The dataset "shape" is undefined!' + + raise ValueError(error) @dataclass @@ -807,7 +817,10 @@ def origin(self, i: int, direction: int) -> float: if self._xy is not None: return self._xy[i, direction] - raise ValueError('The "chromaticity coordinates" are undefined!') + + error = 'The "chromaticity coordinates" are undefined!' + + raise ValueError(error) def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]: """ @@ -851,9 +864,9 @@ def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]: return lesser, greater - raise ValueError( - 'The "tristimulus values" or "chromaticity coordinates" are undefined!' - ) + error = 'The "tristimulus values" or "chromaticity coordinates" are undefined!' + + raise ValueError(error) def PCA(self) -> None: """ @@ -920,11 +933,14 @@ def reconstruct(self, XYZ: ArrayLike) -> SpectralDistribution: reflectance = np.clip(reflectance, 0, 1) return SpectralDistribution(reflectance, self._cmfs.wavelengths) - raise ValueError( + + error = ( 'The matrix "M", the "mean tristimulus values" or the ' '"basis functions" are undefined!' ) + raise ValueError(error) + def reconstruction_error(self) -> float: """ Return the reconstruction error of the data. The error is computed by @@ -954,17 +970,22 @@ def reconstruction_error(self) -> float: if self._XYZ is not None and self._reflectances is not None: self.PCA() - error: float = 0.0 + reconstruction_error: float = 0.0 for i in range(len(self)): sd = self._reflectances[i, :] XYZ = self._XYZ[i, :] recovered_sd = self.reconstruct(XYZ) - error += cast(float, np.sum((sd - recovered_sd.values) ** 2)) + reconstruction_error += cast( + float, np.sum((sd - recovered_sd.values) ** 2) + ) + + self._reconstruction_error = reconstruction_error - self._reconstruction_error = error + return reconstruction_error - return error - raise ValueError('The "tristimulus values" are undefined!') + error = 'The "tristimulus values" are undefined!' + + raise ValueError(error) class Node_Otsu2018(TreeNode): @@ -1044,7 +1065,10 @@ def row(self) -> Tuple[float, float, Self, Self]: self.children[0], self.children[1], ) - raise ValueError('The "partition axis" is undefined!') + + error = 'The "partition axis" is undefined!' + + raise ValueError(error) def split(self, children: Sequence[Self], axis: PartitionAxis) -> None: """ @@ -1136,7 +1160,9 @@ def minimise( ) if self._best_partition is None: - raise RuntimeError("Could not find the best partition!") + error = "Could not find the best partition!" + + raise RuntimeError(error) return self._best_partition diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 4aa419d7f..523929e24 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -2715,10 +2715,12 @@ def index_along_last_axis(a: ArrayLike, indexes: ArrayLike) -> NDArray: indexes = np.array(indexes) if a.shape[:-1] != indexes.shape: - raise ValueError( + error = ( f"Array and indexes have incompatible shapes: {a.shape} and {indexes.shape}" ) + raise ValueError(error) + return np.take_along_axis(a, indexes[..., None], axis=-1).squeeze(axis=-1) diff --git a/colour/utilities/requirements.py b/colour/utilities/requirements.py index 333b65ea2..8e0ffdf06 100644 --- a/colour/utilities/requirements.py +++ b/colour/utilities/requirements.py @@ -70,13 +70,15 @@ def is_ctlrender_installed(raise_exception: bool = False) -> bool: if "transforms an image using one or more CTL scripts" not in stdout: raise FileNotFoundError # noqa: TRY301 - except FileNotFoundError as error: # pragma: no cover + except FileNotFoundError as exception: # pragma: no cover if raise_exception: - raise FileNotFoundError( + error = ( '"ctlrender" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise FileNotFoundError(error) from exception return False else: @@ -105,13 +107,15 @@ def is_matplotlib_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import matplotlib as mpl # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"Matplotlib" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -140,14 +144,16 @@ def is_networkx_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import networkx as nx # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"NetworkX" related API features, e.g., the automatic colour ' - f'conversion graph, are not available: "{error}".\nPlease refer ' + f'conversion graph, are not available: "{exception}".\nPlease refer ' "to the installation guide for more information: " "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -176,13 +182,15 @@ def is_opencolorio_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import PyOpenColorIO # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"OpenColorIO" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -211,13 +219,15 @@ def is_openimageio_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import OpenImageIO # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"OpenImageIO" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -246,13 +256,15 @@ def is_pandas_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import pandas # noqa: F401, ICN001 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( - f'"Pandas" related API features are not available: "{error}".\n' + error = ( + f'"Pandas" related API features are not available: "{exception}".\n' "See the installation guide for more information: " "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -283,25 +295,29 @@ def is_pydot_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import pydot # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"Pydot" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception if shutil.which("fdp") is not None: return True if raise_exception: - raise RuntimeError( + error = ( '"Graphviz" is not installed, "Pydot" related API features ' "are not available!" "\nSee the installation guide for more information: " "https://www.colour-science.org/installation-guide/" ) + raise RuntimeError(error) + return False @@ -327,13 +343,15 @@ def is_tqdm_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import tqdm # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( - f'"tqdm" related API features are not available: "{error}".\n' + error = ( + f'"tqdm" related API features are not available: "{exception}".\n' "See the installation guide for more information: " "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -362,13 +380,15 @@ def is_trimesh_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import trimesh # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"Trimesh" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: @@ -397,13 +417,15 @@ def is_xxhash_installed(raise_exception: bool = False) -> bool: try: # pragma: no cover import xxhash # noqa: F401 - except ImportError as error: # pragma: no cover + except ImportError as exception: # pragma: no cover if raise_exception: - raise ImportError( + error = ( '"xxhash" related API features are not available: ' - f'"{error}".\nSee the installation guide for more information: ' + f'"{exception}".\nSee the installation guide for more information: ' "https://www.colour-science.org/installation-guide/" - ) from error + ) + + raise ImportError(error) from exception return False else: diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index dfd53a503..a2226b6ad 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -529,11 +529,13 @@ def __eq__(self, other: Any) -> bool: if isinstance(other, Mapping): other_mapping = CanonicalMapping(other) else: - raise TypeError( + error = ( f"Impossible to test equality with " f'"{other.__class__.__name__}" class type!' ) + raise TypeError(error) + return self._data == other_mapping.data def __ne__(self, other: Any) -> bool: diff --git a/colour/utilities/tests/test_callback.py b/colour/utilities/tests/test_callback.py index dba6a2f15..43ee8f9e3 100644 --- a/colour/utilities/tests/test_callback.py +++ b/colour/utilities/tests/test_callback.py @@ -43,9 +43,9 @@ def _on_attribute_a_changed( value = value.upper() if getattr(self, name) != "a": - raise RuntimeError( # pragma: no cover - '"self" was not able to retrieve class instance value!' - ) + error = '"self" was not able to retrieve class instance value!' + + raise RuntimeError(error) # pragma: no cover return value diff --git a/pyproject.toml b/pyproject.toml index b3ca04c8f..e21f9898f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -161,7 +161,7 @@ select = [ "D", # pydocstyle "E", # pydocstyle # "ERA", # eradicate - # "EM", # flake8-errmsg + "EM", # flake8-errmsg "EXE", # flake8-executable "F", # flake8 # "FBT", # flake8-boolean-trap diff --git a/tasks.py b/tasks.py index ab41cbbf1..c9ad95caf 100644 --- a/tasks.py +++ b/tasks.py @@ -369,7 +369,9 @@ def build(ctx: Context) -> None: message_box("Building...") if "modified: README.rst" in ctx.run("git status").stdout: # pyright: ignore - raise RuntimeError('Please commit your changes to the "README.rst" file!') + error = 'Please commit your changes to the "README.rst" file!' + + raise RuntimeError(error) with open("README.rst") as readme_file: readme_content = readme_file.read() @@ -446,7 +448,9 @@ def tag(ctx: Context) -> None: result = ctx.run("git rev-parse --abbrev-ref HEAD", hide="both") if result.stdout.strip() != "develop": # pyright: ignore - raise RuntimeError("Are you still on a feature or master branch?") + error = "Are you still on a feature or master branch?" + + raise RuntimeError(error) with open(os.path.join(PYTHON_PACKAGE_NAME, "__init__.py")) as file_handle: file_content = file_handle.read() @@ -475,11 +479,13 @@ def tag(ctx: Context) -> None: tags.add(remote_tag.split("refs/tags/")[1].replace("refs/tags/", "^{}")) version_tags = sorted(tags) if f"v{version}" in version_tags: - raise RuntimeError( + error = ( f'A "{PYTHON_PACKAGE_NAME}" "v{version}" tag already exists in ' f"remote repository!" ) + raise RuntimeError(error) + ctx.run(f"git flow release start v{version}") ctx.run(f"git flow release finish v{version}") From b7af6888e99501f98c7e86a708ba28aa92ca6fa3 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 09:52:03 +1300 Subject: [PATCH 22/42] Enable `PD` checks. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e21f9898f..7352646de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,7 +171,7 @@ select = [ "INP", # flake8-no-pep420 "ISC", # flake8-implicit-str-concat "N", # pep8-naming - # "PD", # pandas-vet + "PD", # pandas-vet "PIE", # flake8-pie "PGH", # pygrep-hooks "PL", # pylint From 1e5c7dbf2974fdb419b87b21ad15342f27605ee5 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 10:02:32 +1300 Subject: [PATCH 23/42] Enable `ASYNC` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 7352646de..ec59ef122 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,6 +152,7 @@ select = [ "A", # flake8-builtins "ARG", # flake8-unused-arguments "ANN", # flake8-annotations + "ASYNC", # flake8-async "B", # flake8-bugbear "BLE", # flake8-blind-except "C4", # flake8-comprehensions From 6ce113e57ea7dd5d570ddf51271e45395fd5ffe5 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 10:02:45 +1300 Subject: [PATCH 24/42] Enable `CPY` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ec59ef122..57402dcf5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,6 +158,7 @@ select = [ "C4", # flake8-comprehensions # "C90", # mccabe # "COM", # flake8-commas + "CPY", # flake8-copyright "DTZ", # flake8-datetimez "D", # pydocstyle "E", # pydocstyle From dc65e7a2d11623dc983120dc4c18893f25181693 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 10:03:01 +1300 Subject: [PATCH 25/42] Enable `FA` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 57402dcf5..700729a11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,6 +166,7 @@ select = [ "EM", # flake8-errmsg "EXE", # flake8-executable "F", # flake8 + "FA", # flake8-future-annotations # "FBT", # flake8-boolean-trap "G", # flake8-logging-format "I", # isort From 044aa30f9aa69736e39a98560970b1fa570ee259 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 10:03:20 +1300 Subject: [PATCH 26/42] Enable `LOG` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 700729a11..8a2b13ecf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -173,6 +173,7 @@ select = [ "ICN", # flake8-import-conventions "INP", # flake8-no-pep420 "ISC", # flake8-implicit-str-concat + "LOG", # flake8-logging "N", # pep8-naming "PD", # pandas-vet "PIE", # flake8-pie From d32dfc19e105d81efafd6671efe9750735a041b9 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 13:19:37 +1300 Subject: [PATCH 27/42] Enable `PYI` checks. --- colour/adaptation/cmccat2000.py | 6 +- colour/adaptation/fairchild2020.py | 14 +- colour/algebra/common.py | 5 +- colour/appearance/cam16.py | 9 +- colour/appearance/ciecam02.py | 11 +- colour/appearance/ciecam16.py | 11 +- colour/appearance/hellwig2022.py | 11 +- colour/appearance/hunt.py | 24 +- colour/appearance/kim2009.py | 22 +- colour/appearance/llab.py | 12 +- colour/appearance/zcam.py | 26 +- .../chromaticity_coordinates.py | 13 +- .../datasets/illuminants/hunterlab.py | 26 +- colour/colorimetry/spectrum.py | 4 +- colour/continuous/abstract.py | 5 +- colour/continuous/multi_signals.py | 4 +- colour/continuous/signal.py | 4 +- colour/corresponding/datasets/breneman1987.py | 1170 +++++++++++++---- colour/corresponding/prediction.py | 71 +- colour/corresponding/tests/test_prediction.py | 4 +- colour/difference/cam02_ucs.py | 6 +- colour/graph/conversion.py | 23 +- colour/io/luts/lut.py | 25 +- colour/io/luts/operator.py | 4 +- colour/io/luts/sequence.py | 4 +- colour/io/tm2714.py | 4 +- colour/models/cam02_ucs.py | 24 +- colour/plotting/corresponding.py | 2 +- colour/utilities/array.py | 25 +- colour/utilities/common.py | 5 +- colour/utilities/deprecation.py | 66 +- colour/utilities/structures.py | 4 +- colour/utilities/verbose.py | 3 +- pyproject.toml | 4 + 34 files changed, 1213 insertions(+), 438 deletions(-) diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index a249c3839..6fa4e8859 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -22,7 +22,7 @@ from __future__ import annotations -from typing import NamedTuple +from dataclasses import dataclass import numpy as np @@ -31,6 +31,7 @@ from colour.hints import ArrayLike, Literal, NDArrayFloat from colour.utilities import ( CanonicalMapping, + MixinDataclassIterable, as_float_array, from_range_100, to_domain_100, @@ -61,7 +62,8 @@ """ -class InductionFactors_CMCCAT2000(NamedTuple): +@dataclass(frozen=True) +class InductionFactors_CMCCAT2000(MixinDataclassIterable): """ *CMCCAT2000* chromatic adaptation model induction factors. diff --git a/colour/adaptation/fairchild2020.py b/colour/adaptation/fairchild2020.py index a23cbe6e7..b1d2c978c 100644 --- a/colour/adaptation/fairchild2020.py +++ b/colour/adaptation/fairchild2020.py @@ -17,7 +17,7 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass import numpy as np @@ -26,6 +26,7 @@ from colour.hints import ArrayLike, Literal, NDArrayFloat from colour.utilities import ( CanonicalMapping, + MixinDataclassIterable, as_float_array, from_range_1, row_as_diagonal, @@ -49,9 +50,8 @@ ] -class Coefficients_DegreeOfAdaptation_vK20( - namedtuple("Coefficients_DegreeOfAdaptation_vK20", ("D_n", "D_r", "D_p")) -): +@dataclass(frozen=True) +class Coefficients_DegreeOfAdaptation_vK20(MixinDataclassIterable): """ *Von Kries 2020* (*vK20*) degree of adaptation coefficients. @@ -69,6 +69,10 @@ class Coefficients_DegreeOfAdaptation_vK20( :cite:`Fairchild2020` """ + D_n: float + D_r: float + D_p: float + CONDITIONS_DEGREE_OF_ADAPTATION_VK20: CanonicalMapping = CanonicalMapping( { @@ -200,7 +204,7 @@ def matrix_chromatic_adaptation_vk20( M = CHROMATIC_ADAPTATION_TRANSFORMS[transform] - D_n, D_r, D_p = coefficients + D_n, D_r, D_p = coefficients.values LMS_n = vecmul(M, XYZ_n) LMS_r = vecmul(M, XYZ_r) diff --git a/colour/algebra/common.py b/colour/algebra/common.py index 333753128..fa80d4204 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -18,6 +18,7 @@ Callable, Literal, NDArrayFloat, + Self, Tuple, cast, ) @@ -202,7 +203,7 @@ def __init__( self._mode = optional(mode, get_sdiv_mode()) self._previous_mode = get_sdiv_mode() - def __enter__(self) -> sdiv_mode: + def __enter__(self) -> Self: """ Set the *Colour* safe division function mode upon entering the context manager. @@ -411,7 +412,7 @@ def __init__(self, enable: bool) -> None: self._enable = enable self._previous_state = is_spow_enabled() - def __enter__(self) -> spow_enable: + def __enter__(self) -> Self: """ Set the *Colour* safe / symmetrical power function enabled state upon entering the context manager. diff --git a/colour/appearance/cam16.py b/colour/appearance/cam16.py index 7c159570d..31fb8901c 100644 --- a/colour/appearance/cam16.py +++ b/colour/appearance/cam16.py @@ -20,7 +20,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -54,6 +53,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_100, @@ -89,7 +89,8 @@ """Inverse adaptation matrix :math:`M^{-1}_{16}`.""" -class InductionFactors_CAM16(namedtuple("InductionFactors_CAM16", ("F", "c", "N_c"))): +@dataclass(frozen=True) +class InductionFactors_CAM16(MixinDataclassIterable): """ *CAM16* colour appearance model induction factors. @@ -112,6 +113,10 @@ class InductionFactors_CAM16(namedtuple("InductionFactors_CAM16", ("F", "c", "N_ :cite:`Li2017` """ + F: float + c: float + N_c: float + VIEWING_CONDITIONS_CAM16: CanonicalMapping = CanonicalMapping( VIEWING_CONDITIONS_CIECAM02 diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index d81e4ead0..60e1bf3b2 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -32,7 +32,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -51,6 +50,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, as_int_array, @@ -117,9 +117,8 @@ """Inverse CAT02 chromatic adaptation transform.""" -class InductionFactors_CIECAM02( - namedtuple("InductionFactors_CIECAM02", ("F", "c", "N_c")) -): +@dataclass(frozen=True) +class InductionFactors_CIECAM02(MixinDataclassIterable): """ *CIECAM02* colour appearance model induction factors. @@ -138,6 +137,10 @@ class InductionFactors_CIECAM02( :cite:`Wikipedia2007a` """ + F: float + c: float + N_c: float + VIEWING_CONDITIONS_CIECAM02: CanonicalMapping = CanonicalMapping( { diff --git a/colour/appearance/ciecam16.py b/colour/appearance/ciecam16.py index 91a0ba5c3..4e7ae3035 100644 --- a/colour/appearance/ciecam16.py +++ b/colour/appearance/ciecam16.py @@ -20,7 +20,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -53,6 +52,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_100, @@ -84,9 +84,8 @@ ] -class InductionFactors_CIECAM16( - namedtuple("InductionFactors_CIECAM16", ("F", "c", "N_c")) -): +@dataclass(frozen=True) +class InductionFactors_CIECAM16(MixinDataclassIterable): """ *CIECAM16* colour appearance model induction factors. @@ -109,6 +108,10 @@ class InductionFactors_CIECAM16( :cite:`CIEDivision12022` """ + F: float + c: float + N_c: float + VIEWING_CONDITIONS_CIECAM16: CanonicalMapping = CanonicalMapping( VIEWING_CONDITIONS_CIECAM02 diff --git a/colour/appearance/hellwig2022.py b/colour/appearance/hellwig2022.py index 3b265df7d..519162a1b 100644 --- a/colour/appearance/hellwig2022.py +++ b/colour/appearance/hellwig2022.py @@ -24,7 +24,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -53,6 +52,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_100, @@ -91,9 +91,8 @@ ] -class InductionFactors_Hellwig2022( - namedtuple("InductionFactors_Hellwig2022", ("F", "c", "N_c")) -): +@dataclass(frozen=True) +class InductionFactors_Hellwig2022(MixinDataclassIterable): """ *Hellwig and Fairchild (2022)* colour appearance model induction factors. @@ -116,6 +115,10 @@ class InductionFactors_Hellwig2022( :cite:`Fairchild2022`, :cite:`Hellwig2022` """ + F: float + c: float + N_c: float + VIEWING_CONDITIONS_HELLWIG2022: CanonicalMapping = CanonicalMapping( VIEWING_CONDITIONS_CIECAM02 diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 52354b583..336d9a0cb 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -19,7 +19,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import dataclass, field import numpy as np @@ -29,6 +28,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_degrees, @@ -79,9 +79,8 @@ ] -class InductionFactors_Hunt( - namedtuple("InductionFactors_Hunt", ("N_c", "N_b", "N_cb", "N_bb")) -): +@dataclass(frozen=True) +class InductionFactors_Hunt(MixinDataclassIterable): """ *Hunt* colour appearance model induction factors. @@ -105,19 +104,10 @@ class InductionFactors_Hunt( :cite:`Fairchild2013u`, :cite:`Hunt2004b` """ - def __new__( - cls, - N_c: float, - N_b: float, - N_cb: float | None = None, - N_bb: float | None = None, - ) -> InductionFactors_Hunt: - """ - Return a new instance of the - :class:`colour.appearance.InductionFactors_Hunt` class. - """ - - return super().__new__(cls, N_c, N_b, N_cb, N_bb) + N_c: float + N_b: float + N_cb: float | None = field(default_factory=lambda: None) + N_bb: float | None = field(default_factory=lambda: None) VIEWING_CONDITIONS_HUNT: CanonicalMapping = CanonicalMapping( diff --git a/colour/appearance/kim2009.py b/colour/appearance/kim2009.py index e8347c18a..ca5ab4341 100644 --- a/colour/appearance/kim2009.py +++ b/colour/appearance/kim2009.py @@ -21,7 +21,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -42,6 +41,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_100, @@ -72,9 +72,8 @@ ] -class InductionFactors_Kim2009( - namedtuple("InductionFactors_Kim2009", ("F", "c", "N_c")) -): +@dataclass(frozen=True) +class InductionFactors_Kim2009(MixinDataclassIterable): """ *Kim, Weyrich and Kautz (2009)* colour appearance model induction factors. @@ -102,6 +101,10 @@ class InductionFactors_Kim2009( :cite:`Kim2009` """ + F: float + c: float + N_c: float + VIEWING_CONDITIONS_KIM2009: CanonicalMapping = CanonicalMapping( VIEWING_CONDITIONS_CIECAM02 @@ -116,7 +119,8 @@ class InductionFactors_Kim2009( """ -class MediaParameters_Kim2009(namedtuple("MediaParameters_Kim2009", ("E",))): +@dataclass(frozen=True) +class MediaParameters_Kim2009: """ *Kim, Weyrich and Kautz (2009)* colour appearance model media parameters. @@ -130,13 +134,7 @@ class MediaParameters_Kim2009(namedtuple("MediaParameters_Kim2009", ("E",))): :cite:`Kim2009` """ - def __new__(cls, E: float) -> MediaParameters_Kim2009: - """ - Return a new instance of the - :class:`colour.appearance.MediaParameters_Kim2009` class. - """ - - return super().__new__(cls, E) + E: float MEDIA_PARAMETERS_KIM2009: CanonicalMapping = CanonicalMapping( diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index 33e150eea..c70aa8a2f 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -27,7 +27,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import dataclass, field import numpy as np @@ -43,6 +42,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, from_range_degrees, @@ -78,9 +78,8 @@ ] -class InductionFactors_LLAB( - namedtuple("InductionFactors_LLAB", ("D", "F_S", "F_L", "F_C")) -): +@dataclass(frozen=True) +class InductionFactors_LLAB(MixinDataclassIterable): """ *:math:`LLAB(l:c)`* colour appearance model induction factors. @@ -100,6 +99,11 @@ class InductionFactors_LLAB( :cite:`Fairchild2013x`, :cite:`Luo1996b`, :cite:`Luo1996c` """ + D: float + F_S: float + F_L: float + F_C: float + VIEWING_CONDITIONS_LLAB: CanonicalMapping = CanonicalMapping( { diff --git a/colour/appearance/zcam.py b/colour/appearance/zcam.py index 278c67a67..739679938 100644 --- a/colour/appearance/zcam.py +++ b/colour/appearance/zcam.py @@ -26,7 +26,6 @@ from __future__ import annotations -from collections import namedtuple from dataclasses import astuple, dataclass, field import numpy as np @@ -44,6 +43,7 @@ from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, + MixinDataclassIterable, as_float, as_float_array, as_int_array, @@ -74,9 +74,8 @@ ] -class InductionFactors_ZCAM( - namedtuple("InductionFactors_ZCAM", ("F_s", "F", "c", "N_c")) -): +@dataclass(frozen=True) +class InductionFactors_ZCAM(MixinDataclassIterable): """ *ZCAM* colour appearance model induction factors. @@ -101,12 +100,21 @@ class InductionFactors_ZCAM( :cite:`Safdar2021` """ + F_s: float + F: float + c: float + N_c: float + VIEWING_CONDITIONS_ZCAM: CanonicalMapping = CanonicalMapping( { - "Average": InductionFactors_ZCAM(0.69, *VIEWING_CONDITIONS_CIECAM02["Average"]), - "Dim": InductionFactors_ZCAM(0.59, *VIEWING_CONDITIONS_CIECAM02["Dim"]), - "Dark": InductionFactors_ZCAM(0.525, *VIEWING_CONDITIONS_CIECAM02["Dark"]), + "Average": InductionFactors_ZCAM( + 0.69, *VIEWING_CONDITIONS_CIECAM02["Average"].values + ), + "Dim": InductionFactors_ZCAM(0.59, *VIEWING_CONDITIONS_CIECAM02["Dim"].values), + "Dark": InductionFactors_ZCAM( + 0.525, *VIEWING_CONDITIONS_CIECAM02["Dark"].values + ), } ) VIEWING_CONDITIONS_ZCAM.__doc__ = """ @@ -424,7 +432,7 @@ def XYZ_to_ZCAM( L_A = as_float_array(L_A) Y_b = as_float_array(Y_b) - F_s, F, _c, _N_c = surround + F_s, F, _c, _N_c = surround.values # Step 0 (Forward) - Chromatic adaptation from reference illuminant to # "CIE Standard Illuminant D65" illuminant using "CAT02". @@ -641,7 +649,7 @@ def ZCAM_to_XYZ( L_A = as_float_array(L_A) Y_b = as_float_array(Y_b) - F_s, F, c, N_c = surround + F_s, F, c, N_c = surround.values # Step 0 (Forward) - Chromatic adaptation from reference illuminant to # "CIE Standard Illuminant D65" illuminant using "CAT02". diff --git a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py index 614940ecd..693e8198f 100644 --- a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py +++ b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py @@ -56,7 +56,7 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass import numpy as np @@ -114,9 +114,8 @@ ] -class ColourChecker( - namedtuple("ColourChecker", ("name", "data", "illuminant", "rows", "columns")) -): +@dataclass(frozen=True) +class ColourChecker: """ *Colour Checker* data. @@ -134,6 +133,12 @@ class ColourChecker( *Colour Checker* column count. """ + name: str + data: dict[str, NDArrayFloat] + illuminant: NDArrayFloat + rows: int + columns: int + SAMPLE_LABELS_COLORCHECKER_CLASSIC: tuple = ( "dark skin", diff --git a/colour/colorimetry/datasets/illuminants/hunterlab.py b/colour/colorimetry/datasets/illuminants/hunterlab.py index fde9e1359..a2e2d753f 100644 --- a/colour/colorimetry/datasets/illuminants/hunterlab.py +++ b/colour/colorimetry/datasets/illuminants/hunterlab.py @@ -22,10 +22,11 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass import numpy as np +from colour.hints import NDArrayFloat from colour.utilities import CanonicalMapping __author__ = "Colour Developers" @@ -44,9 +45,26 @@ "TVS_ILLUMINANTS_HUNTERLAB", ] -Illuminant_Specification_HunterLab = namedtuple( - "Illuminant_Specification_HunterLab", ("name", "XYZ_n", "K_ab") -) + +@dataclass(frozen=True) +class Illuminant_Specification_HunterLab: + """ + Define the specification for an *HunterLab* illuminant. + + Parameters + ---------- + name + Illuminant name + XYZ_n + Illuminant *CIE XYZ* tristimulus values + K_ab + Illuminant :math:`K_{a}` and :math:`K_{b}` chromaticity coefficients. + """ + + name: str + XYZ_n: NDArrayFloat + K_ab: NDArrayFloat + DATA_ILLUMINANTS_HUNTERLAB_STANDARD_OBSERVER_2_DEGREE_CIE1931: tuple = ( ("A", np.array([109.83, 100.00, 35.55]), np.array([185.20, 38.40])), diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 1e1acdb8d..5dbd446fc 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -426,7 +426,7 @@ def __len__(self) -> int: return len(self.wavelengths) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the spectral shape is equal to given other object. @@ -452,7 +452,7 @@ def __eq__(self, other: Any) -> bool: return np.array_equal(self.wavelengths, other.wavelengths) return False - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the spectral shape is not equal to given other object. diff --git a/colour/continuous/abstract.py b/colour/continuous/abstract.py index 962564bfe..451d3cef7 100644 --- a/colour/continuous/abstract.py +++ b/colour/continuous/abstract.py @@ -16,7 +16,6 @@ import numpy as np from colour.hints import ( - Any, ArrayLike, Callable, DTypeFloat, @@ -514,7 +513,7 @@ def __len__(self) -> int: return len(self.domain) @abstractmethod - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the abstract continuous function is equal to given other object, must be reimplemented by sub-classes. @@ -534,7 +533,7 @@ def __eq__(self, other: Any) -> bool: ... # pragma: no cover @abstractmethod - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the abstract continuous function is not equal to given other object, must be reimplemented by sub-classes. diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index bca659b4a..7f3bd3e5e 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -968,7 +968,7 @@ def __contains__(self, x: ArrayLike | slice) -> bool: return x in first_item(self._signals.values()) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the multi-continuous signals is equal to given other object. @@ -1018,7 +1018,7 @@ def __eq__(self, other: Any) -> bool: ) return False - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the multi-continuous signals is not equal to given other object. diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 24de4ad3d..f68e6cf02 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -849,7 +849,7 @@ def __contains__(self, x: ArrayLike | slice) -> bool: ) @ndarray_copy_enable(False) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the continuous signal is equal to given other object. @@ -897,7 +897,7 @@ def __eq__(self, other: Any) -> bool: ) return False - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the continuous signal is not equal to given other object. diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index 5bfa7fd2f..b1fb62429 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -15,11 +15,12 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass, field import numpy as np -from colour.hints import ArrayLike, Literal +from colour.hints import NDArrayFloat, Tuple +from colour.utilities import MixinDataclassIterable, as_float_array from colour.utilities.documentation import ( DocstringDict, is_documentation_building, @@ -52,12 +53,8 @@ ] -class BrenemanExperimentResult( - namedtuple( - "BrenemanExperimentResult", - ("name", "uv_t", "uv_m", "s_uv", "d_uv_i", "d_uv_g"), - ) -): +@dataclass(frozen=True) +class BrenemanExperimentResult(MixinDataclassIterable): """ Experiment result. @@ -79,38 +76,31 @@ class BrenemanExperimentResult( :math:`\\delta_uv_g^p`. """ - def __new__( - cls, - name: str, - uv_t: ArrayLike, - uv_m: ArrayLike, - s_uv: ArrayLike | None = None, - d_uv_i: ArrayLike | None = None, - d_uv_g: ArrayLike | None = None, - ) -> BrenemanExperimentResult: - """ - Return a new instance of the - :class:`colour.corresponding.datasets.corresponding_chromaticities.\ -BrenemanExperimentResult` class. - """ - - return super().__new__( - cls, - name, - np.array(uv_t), - np.array(uv_m), - np.array(s_uv), - np.array(d_uv_i), - np.array(d_uv_g), - ) - - -class PrimariesChromaticityCoordinates( - namedtuple( - "PrimariesChromaticityCoordinates", - ("experiment", "illuminants", "Y", "P_uvp", "D_uvp", "T_uvp"), - ) -): + name: str + uv_t: NDArrayFloat + uv_m: NDArrayFloat + s_uv: NDArrayFloat | None = field(default_factory=lambda: None) + d_uv_i: NDArrayFloat | None = field(default_factory=lambda: None) + d_uv_g: NDArrayFloat | None = field(default_factory=lambda: None) + + def __post_init__(self) -> None: + """Post-initialise the class.""" + + object.__setattr__(self, "uv_t", as_float_array(self.uv_t)) + object.__setattr__(self, "uv_m", as_float_array(self.uv_m)) + + if self.s_uv is not None: + object.__setattr__(self, "s_uv", as_float_array(self.s_uv)) + + if self.d_uv_i is not None: + object.__setattr__(self, "d_uv_i", as_float_array(self.d_uv_i)) + + if self.d_uv_g is not None: + object.__setattr__(self, "d_uv_g", as_float_array(self.d_uv_g)) + + +@dataclass(frozen=True) +class PrimariesChromaticityCoordinates(MixinDataclassIterable): """ Chromaticity coordinates of the primaries. @@ -130,69 +120,127 @@ class PrimariesChromaticityCoordinates( Chromaticity coordinates :math:`uv^p` of primary :math:`T`. """ - def __new__( - cls, - experiment: Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], - illuminants: ArrayLike, - Y: ArrayLike, - P_uvp: ArrayLike | None = None, - D_uvp: ArrayLike | None = None, - T_uvp: ArrayLike | None = None, - ) -> PrimariesChromaticityCoordinates: - """ - Return a new instance of the - :class:`colour.corresponding.datasets.corresponding_chromaticities.\ -PrimariesChromaticityCoordinates` class. - """ - - return super().__new__( - cls, - experiment, - np.array(illuminants), - np.array(Y), - np.array(P_uvp), - np.array(D_uvp), - np.array(T_uvp), - ) + experiment: int + illuminants: Tuple[str, str] + Y: float + P_uvp: NDArrayFloat | None = field(default_factory=lambda: None) + D_uvp: NDArrayFloat | None = field(default_factory=lambda: None) + T_uvp: NDArrayFloat | None = field(default_factory=lambda: None) + + def __post_init__(self) -> None: + """Post-initialise the class.""" + + object.__setattr__(self, "Y", as_float_array(self.Y)) + + if self.P_uvp is not None: + object.__setattr__(self, "P_uvp", as_float_array(self.P_uvp)) + + if self.D_uvp is not None: + object.__setattr__(self, "D_uvp", as_float_array(self.D_uvp)) + + if self.T_uvp is not None: + object.__setattr__(self, "T_uvp", as_float_array(self.T_uvp)) BRENEMAN_EXPERIMENT_1_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.259, 0.526), (0.200, 0.475)), BrenemanExperimentResult( - "Gray", (0.259, 0.524), (0.199, 0.487), (4, 4), (2, 3), (0, 0) + "Illuminant", np.array([0.259, 0.526]), np.array([0.200, 0.475]) + ), + BrenemanExperimentResult( + "Gray", + np.array([0.259, 0.524]), + np.array([0.199, 0.487]), + np.array([4, 4]), + np.array([2, 3]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Red", (0.459, 0.522), (0.420, 0.509), (19, 4), (-10, -7), (-19, -3) + "Red", + np.array([0.459, 0.522]), + np.array([0.420, 0.509]), + np.array([19, 4]), + np.array([-10, -7]), + np.array([-19, -3]), ), BrenemanExperimentResult( - "Skin", (0.307, 0.526), (0.249, 0.497), (7, 4), (-1, 1), (-6, -1) + "Skin", + np.array([0.307, 0.526]), + np.array([0.249, 0.497]), + np.array([7, 4]), + np.array([-1, 1]), + np.array([-6, -1]), ), BrenemanExperimentResult( - "Orange", (0.360, 0.544), (0.302, 0.548), (12, 1), (1, -2), (-7, -6) + "Orange", + np.array([0.360, 0.544]), + np.array([0.302, 0.548]), + np.array([12, 1]), + np.array([1, -2]), + np.array([-7, -6]), ), BrenemanExperimentResult( - "Brown", (0.350, 0.541), (0.290, 0.537), (11, 4), (3, 0), (-5, -3) + "Brown", + np.array([0.350, 0.541]), + np.array([0.290, 0.537]), + np.array([11, 4]), + np.array([3, 0]), + np.array([-5, -3]), ), BrenemanExperimentResult( - "Yellow", (0.318, 0.550), (0.257, 0.554), (8, 2), (0, 2), (-5, -5) + "Yellow", + np.array([0.318, 0.550]), + np.array([0.257, 0.554]), + np.array([8, 2]), + np.array([0, 2]), + np.array([-5, -5]), ), BrenemanExperimentResult( - "Foliage", (0.258, 0.542), (0.192, 0.529), (4, 6), (3, 2), (3, -6) + "Foliage", + np.array([0.258, 0.542]), + np.array([0.192, 0.529]), + np.array([4, 6]), + np.array([3, 2]), + np.array([3, -6]), ), BrenemanExperimentResult( - "Green", (0.193, 0.542), (0.129, 0.521), (7, 5), (3, 2), (9, -7) + "Green", + np.array([0.193, 0.542]), + np.array([0.129, 0.521]), + np.array([7, 5]), + np.array([3, 2]), + np.array([9, -7]), ), BrenemanExperimentResult( - "Blue-green", (0.180, 0.516), (0.133, 0.469), (4, 6), (-3, -2), (2, -5) + "Blue-green", + np.array([0.180, 0.516]), + np.array([0.133, 0.469]), + np.array([4, 6]), + np.array([-3, -2]), + np.array([2, -5]), ), BrenemanExperimentResult( - "Blue", (0.186, 0.445), (0.158, 0.340), (13, 33), (2, 7), (1, 13) + "Blue", + np.array([0.186, 0.445]), + np.array([0.158, 0.340]), + np.array([13, 33]), + np.array([2, 7]), + np.array([1, 13]), ), BrenemanExperimentResult( - "Sky", (0.226, 0.491), (0.178, 0.426), (3, 14), (1, -3), (0, -1) + "Sky", + np.array([0.226, 0.491]), + np.array([0.178, 0.426]), + np.array([3, 14]), + np.array([1, -3]), + np.array([0, -1]), ), BrenemanExperimentResult( - "Purple", (0.278, 0.456), (0.231, 0.365), (4, 25), (0, 2), (-5, 7) + "Purple", + np.array([0.278, 0.456]), + np.array([0.231, 0.365]), + np.array([4, 25]), + np.array([0, 2]), + np.array([-5, 7]), ), ) """ @@ -207,42 +255,104 @@ def __new__( BRENEMAN_EXPERIMENT_2_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.222, 0.521), (0.204, 0.479)), BrenemanExperimentResult( - "Gray", (0.227, 0.517), (0.207, 0.486), (2, 5), (-1, 0), (0, 0) + "Illuminant", np.array([0.222, 0.521]), np.array([0.204, 0.479]) + ), + BrenemanExperimentResult( + "Gray", + np.array([0.227, 0.517]), + np.array([0.207, 0.486]), + np.array([2, 5]), + np.array([-1, 0]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Red", (0.464, 0.520), (0.449, 0.511), (22, 3), (-8, -8), (-7, -2) + "Red", + np.array([0.464, 0.520]), + np.array([0.449, 0.511]), + np.array([22, 3]), + np.array([-8, -8]), + np.array([-7, -2]), ), BrenemanExperimentResult( - "Skin", (0.286, 0.526), (0.263, 0.505), (7, 2), (0, -1), (0, -1) + "Skin", + np.array([0.286, 0.526]), + np.array([0.263, 0.505]), + np.array([7, 2]), + np.array([0, -1]), + np.array([0, -1]), ), BrenemanExperimentResult( - "Orange", (0.348, 0.546), (0.322, 0.545), (13, 3), (3, -1), (3, -2) + "Orange", + np.array([0.348, 0.546]), + np.array([0.322, 0.545]), + np.array([13, 3]), + np.array([3, -1]), + np.array([3, -2]), ), BrenemanExperimentResult( - "Brown", (0.340, 0.543), (0.316, 0.537), (11, 3), (1, 1), (0, 0) + "Brown", + np.array([0.340, 0.543]), + np.array([0.316, 0.537]), + np.array([11, 3]), + np.array([1, 1]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Yellow", (0.288, 0.554), (0.265, 0.553), (5, 2), (-2, 2), (-1, -2) + "Yellow", + np.array([0.288, 0.554]), + np.array([0.265, 0.553]), + np.array([5, 2]), + np.array([-2, 2]), + np.array([-1, -2]), ), BrenemanExperimentResult( - "Foliage", (0.244, 0.547), (0.221, 0.538), (4, 3), (-2, 1), (0, -3) + "Foliage", + np.array([0.244, 0.547]), + np.array([0.221, 0.538]), + np.array([4, 3]), + np.array([-2, 1]), + np.array([0, -3]), ), BrenemanExperimentResult( - "Green", (0.156, 0.548), (0.135, 0.532), (4, 3), (-1, 3), (3, -4) + "Green", + np.array([0.156, 0.548]), + np.array([0.135, 0.532]), + np.array([4, 3]), + np.array([-1, 3]), + np.array([3, -4]), ), BrenemanExperimentResult( - "Blue-green", (0.159, 0.511), (0.145, 0.472), (9, 7), (-1, 2), (2, 1) + "Blue-green", + np.array([0.159, 0.511]), + np.array([0.145, 0.472]), + np.array([9, 7]), + np.array([-1, 2]), + np.array([2, 1]), ), BrenemanExperimentResult( - "Blue", (0.160, 0.406), (0.163, 0.331), (23, 31), (2, -3), (-1, 3) + "Blue", + np.array([0.160, 0.406]), + np.array([0.163, 0.331]), + np.array([23, 31]), + np.array([2, -3]), + np.array([-1, 3]), ), BrenemanExperimentResult( - "Sky", (0.190, 0.481), (0.176, 0.431), (5, 24), (2, -2), (2, 0) + "Sky", + np.array([0.190, 0.481]), + np.array([0.176, 0.431]), + np.array([5, 24]), + np.array([2, -2]), + np.array([2, 0]), ), BrenemanExperimentResult( - "Purple", (0.258, 0.431), (0.244, 0.349), (4, 19), (-3, 13), (-4, 19) + "Purple", + np.array([0.258, 0.431]), + np.array([0.244, 0.349]), + np.array([4, 19]), + np.array([-3, 13]), + np.array([-4, 19]), ), ) """ @@ -257,47 +367,104 @@ def __new__( BRENEMAN_EXPERIMENT_3_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.223, 0.521), (0.206, 0.478)), BrenemanExperimentResult( - "Gray", (0.228, 0.517), (0.211, 0.494), (1, 3), (0, 2), (0, 0) + "Illuminant", np.array([0.223, 0.521]), np.array([0.206, 0.478]) + ), + BrenemanExperimentResult( + "Gray", + np.array([0.228, 0.517]), + np.array([0.211, 0.494]), + np.array([1, 3]), + np.array([0, 2]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Red", (0.462, 0.519), (0.448, 0.505), (11, 4), (-3, 6), (-4, 6) + "Red", + np.array([0.462, 0.519]), + np.array([0.448, 0.505]), + np.array([11, 4]), + np.array([-3, 6]), + np.array([-4, 6]), ), BrenemanExperimentResult( - "Skin", (0.285, 0.524), (0.267, 0.507), (6, 3), (-1, 1), (-2, 1) + "Skin", + np.array([0.285, 0.524]), + np.array([0.267, 0.507]), + np.array([6, 3]), + np.array([-1, 1]), + np.array([-2, 1]), ), BrenemanExperimentResult( - "Orange", (0.346, 0.546), (0.325, 0.541), (11, 3), (1, -2), (2, 3) + "Orange", + np.array([0.346, 0.546]), + np.array([0.325, 0.541]), + np.array([11, 3]), + np.array([1, -2]), + np.array([2, 3]), ), BrenemanExperimentResult( - "Brown", (0.338, 0.543), (0.321, 0.532), (9, 6), (-3, 2), (-3, 7) + "Brown", + np.array([0.338, 0.543]), + np.array([0.321, 0.532]), + np.array([9, 6]), + np.array([-3, 2]), + np.array([-3, 7]), ), BrenemanExperimentResult( - "Yellow", (0.287, 0.554), (0.267, 0.548), (4, 5), (1, -2), (0, 5) + "Yellow", + np.array([0.287, 0.554]), + np.array([0.267, 0.548]), + np.array([4, 5]), + np.array([1, -2]), + np.array([0, 5]), ), BrenemanExperimentResult( - "Foliage", (0.244, 0.547), (0.226, 0.531), (3, 6), (-1, 3), (-2, 8) + "Foliage", + np.array([0.244, 0.547]), + np.array([0.226, 0.531]), + np.array([3, 6]), + np.array([-1, 3]), + np.array([-2, 8]), ), BrenemanExperimentResult( - "Green", (0.157, 0.548), (0.141, 0.528), (9, 6), (2, 2), (0, 6) + "Green", + np.array([0.157, 0.548]), + np.array([0.141, 0.528]), + np.array([9, 6]), + np.array([2, 2]), + np.array([0, 6]), ), BrenemanExperimentResult( "Blue-green", - (0.160, 0.510), - (0.151, 0.486), - (8, 5), - (-2, -1), - (-2, -5), + np.array([0.160, 0.510]), + np.array([0.151, 0.486]), + np.array([8, 5]), + np.array([-2, -1]), + np.array([-2, -5]), ), BrenemanExperimentResult( - "Blue", (0.162, 0.407), (0.158, 0.375), (6, 7), (1, -6), (4, -23) + "Blue", + np.array([0.162, 0.407]), + np.array([0.158, 0.375]), + np.array([6, 7]), + np.array([1, -6]), + np.array([4, -23]), ), BrenemanExperimentResult( - "Sky", (0.191, 0.482), (0.179, 0.452), (4, 5), (0, 1), (1, -7) + "Sky", + np.array([0.191, 0.482]), + np.array([0.179, 0.452]), + np.array([4, 5]), + np.array([0, 1]), + np.array([1, -7]), ), BrenemanExperimentResult( - "Purple", (0.258, 0.432), (0.238, 0.396), (4, 8), (5, 3), (4, -11) + "Purple", + np.array([0.258, 0.432]), + np.array([0.238, 0.396]), + np.array([4, 8]), + np.array([5, 3]), + np.array([4, -11]), ), ) """ @@ -312,47 +479,104 @@ def __new__( BRENEMAN_EXPERIMENT_4_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.258, 0.523), (0.199, 0.467)), BrenemanExperimentResult( - "Gray", (0.257, 0.524), (0.205, 0.495), (2, 2), (0, 4), (0, 0) + "Illuminant", np.array([0.258, 0.523]), np.array([0.199, 0.467]) ), BrenemanExperimentResult( - "Red", (0.460, 0.521), (0.416, 0.501), (11, 6), (-6, 4), (-6, 9) + "Gray", + np.array([0.257, 0.524]), + np.array([0.205, 0.495]), + np.array([2, 2]), + np.array([0, 4]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Skin", (0.308, 0.526), (0.253, 0.503), (7, 3), (-1, 1), (-1, 0) + "Red", + np.array([0.460, 0.521]), + np.array([0.416, 0.501]), + np.array([11, 6]), + np.array([-6, 4]), + np.array([-6, 9]), ), BrenemanExperimentResult( - "Orange", (0.360, 0.544), (0.303, 0.541), (14, 5), (1, -4), (1, 2) + "Skin", + np.array([0.308, 0.526]), + np.array([0.253, 0.503]), + np.array([7, 3]), + np.array([-1, 1]), + np.array([-1, 0]), ), BrenemanExperimentResult( - "Brown", (0.350, 0.541), (0.296, 0.527), (11, 7), (-2, 4), (-3, 9) + "Orange", + np.array([0.360, 0.544]), + np.array([0.303, 0.541]), + np.array([14, 5]), + np.array([1, -4]), + np.array([1, 2]), ), BrenemanExperimentResult( - "Yellow", (0.317, 0.550), (0.260, 0.547), (9, 5), (1, -3), (0, 3) + "Brown", + np.array([0.350, 0.541]), + np.array([0.296, 0.527]), + np.array([11, 7]), + np.array([-2, 4]), + np.array([-3, 9]), ), BrenemanExperimentResult( - "Foliage", (0.258, 0.543), (0.203, 0.520), (4, 6), (0, 8), (0, 9) + "Yellow", + np.array([0.317, 0.550]), + np.array([0.260, 0.547]), + np.array([9, 5]), + np.array([1, -3]), + np.array([0, 3]), ), BrenemanExperimentResult( - "Green", (0.193, 0.543), (0.142, 0.516), (6, 9), (3, 8), (2, 6) + "Foliage", + np.array([0.258, 0.543]), + np.array([0.203, 0.520]), + np.array([4, 6]), + np.array([0, 8]), + np.array([0, 9]), + ), + BrenemanExperimentResult( + "Green", + np.array([0.193, 0.543]), + np.array([0.142, 0.516]), + np.array([6, 9]), + np.array([3, 8]), + np.array([2, 6]), ), BrenemanExperimentResult( "Blue-green", - (0.180, 0.516), - (0.140, 0.484), - (9, 5), - (-2, -1), - (-1, -9), + np.array([0.180, 0.516]), + np.array([0.140, 0.484]), + np.array([9, 5]), + np.array([-2, -1]), + np.array([-1, -9]), ), BrenemanExperimentResult( - "Blue", (0.185, 0.445), (0.151, 0.394), (8, 10), (2, -8), (8, -24) + "Blue", + np.array([0.185, 0.445]), + np.array([0.151, 0.394]), + np.array([8, 10]), + np.array([2, -8]), + np.array([8, -24]), ), BrenemanExperimentResult( - "Sky", (0.225, 0.490), (0.180, 0.448), (4, 8), (1, -1), (3, -11) + "Sky", + np.array([0.225, 0.490]), + np.array([0.180, 0.448]), + np.array([4, 8]), + np.array([1, -1]), + np.array([3, -11]), ), BrenemanExperimentResult( - "Purple", (0.278, 0.455), (0.229, 0.388), (6, 14), (1, 12), (3, 0) + "Purple", + np.array([0.278, 0.455]), + np.array([0.229, 0.388]), + np.array([6, 14]), + np.array([1, 12]), + np.array([3, 0]), ), ) """ @@ -367,18 +591,45 @@ def __new__( BRENEMAN_EXPERIMENT_5_RESULTS = ( - BrenemanExperimentResult("Gray", (0.028, 0.480), (0.212, 0.491), (2, 2)), - BrenemanExperimentResult("Red", (0.449, 0.512), (0.408, 0.514), (11, 5)), - BrenemanExperimentResult("Skin", (0.269, 0.505), (0.262, 0.511), (4, 2)), - BrenemanExperimentResult("Orange", (0.331, 0.548), (0.303, 0.545), (4, 3)), - BrenemanExperimentResult("Brown", (0.322, 0.541), (0.303, 0.538), (4, 4)), - BrenemanExperimentResult("Yellow", (0.268, 0.555), (0.264, 0.550), (3, 2)), - BrenemanExperimentResult("Foliage", (0.224, 0.538), (0.227, 0.535), (3, 3)), - BrenemanExperimentResult("Green", (0.134, 0.531), (0.159, 0.530), (9, 3)), - BrenemanExperimentResult("Blue-green", (0.145, 0.474), (0.165, 0.490), (8, 3)), - BrenemanExperimentResult("Blue", (0.163, 0.329), (0.173, 0.378), (7, 12)), - BrenemanExperimentResult("Sky", (0.179, 0.438), (0.189, 0.462), (5, 4)), - BrenemanExperimentResult("Purple", (0.245, 0.364), (0.239, 0.401), (4, 16)), + BrenemanExperimentResult( + "Gray", np.array([0.028, 0.480]), np.array([0.212, 0.491]), np.array([2, 2]) + ), + BrenemanExperimentResult( + "Red", np.array([0.449, 0.512]), np.array([0.408, 0.514]), np.array([11, 5]) + ), + BrenemanExperimentResult( + "Skin", np.array([0.269, 0.505]), np.array([0.262, 0.511]), np.array([4, 2]) + ), + BrenemanExperimentResult( + "Orange", np.array([0.331, 0.548]), np.array([0.303, 0.545]), np.array([4, 3]) + ), + BrenemanExperimentResult( + "Brown", np.array([0.322, 0.541]), np.array([0.303, 0.538]), np.array([4, 4]) + ), + BrenemanExperimentResult( + "Yellow", np.array([0.268, 0.555]), np.array([0.264, 0.550]), np.array([3, 2]) + ), + BrenemanExperimentResult( + "Foliage", np.array([0.224, 0.538]), np.array([0.227, 0.535]), np.array([3, 3]) + ), + BrenemanExperimentResult( + "Green", np.array([0.134, 0.531]), np.array([0.159, 0.530]), np.array([9, 3]) + ), + BrenemanExperimentResult( + "Blue-green", + np.array([0.145, 0.474]), + np.array([0.165, 0.490]), + np.array([8, 3]), + ), + BrenemanExperimentResult( + "Blue", np.array([0.163, 0.329]), np.array([0.173, 0.378]), np.array([7, 12]) + ), + BrenemanExperimentResult( + "Sky", np.array([0.179, 0.438]), np.array([0.189, 0.462]), np.array([5, 4]) + ), + BrenemanExperimentResult( + "Purple", np.array([0.245, 0.364]), np.array([0.239, 0.401]), np.array([4, 16]) + ), ) """ *Breneman (1987)* experiment 5 results. @@ -391,42 +642,104 @@ def __new__( BRENEMAN_EXPERIMENT_6_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.257, 0.525), (0.201, 0.482)), BrenemanExperimentResult( - "Gray", (0.267, 0.521), (0.207, 0.485), (5, 3), (-1, 0), (0, 0) + "Illuminant", np.array([0.257, 0.525]), np.array([0.201, 0.482]) ), BrenemanExperimentResult( - "Red", (0.457, 0.521), (0.398, 0.516), (9, 4), (-2, -5), (1, -9) + "Gray", + np.array([0.267, 0.521]), + np.array([0.207, 0.485]), + np.array([5, 3]), + np.array([-1, 0]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Skin", (0.316, 0.526), (0.253, 0.503), (5, 3), (-3, -2), (-1, -3) + "Red", + np.array([0.457, 0.521]), + np.array([0.398, 0.516]), + np.array([9, 4]), + np.array([-2, -5]), + np.array([1, -9]), ), BrenemanExperimentResult( - "Orange", (0.358, 0.545), (0.287, 0.550), (7, 3), (3, 0), (7, -6) + "Skin", + np.array([0.316, 0.526]), + np.array([0.253, 0.503]), + np.array([5, 3]), + np.array([-3, -2]), + np.array([-1, -3]), ), BrenemanExperimentResult( - "Brown", (0.350, 0.541), (0.282, 0.540), (6, 3), (-1, 0), (2, -5) + "Orange", + np.array([0.358, 0.545]), + np.array([0.287, 0.550]), + np.array([7, 3]), + np.array([3, 0]), + np.array([7, -6]), ), BrenemanExperimentResult( - "Yellow", (0.318, 0.551), (0.249, 0.556), (7, 2), (-1, 1), (2, -5) + "Brown", + np.array([0.350, 0.541]), + np.array([0.282, 0.540]), + np.array([6, 3]), + np.array([-1, 0]), + np.array([2, -5]), ), BrenemanExperimentResult( - "Foliage", (0.256, 0.547), (0.188, 0.537), (5, 4), (3, 1), (4, -2) + "Yellow", + np.array([0.318, 0.551]), + np.array([0.249, 0.556]), + np.array([7, 2]), + np.array([-1, 1]), + np.array([2, -5]), ), BrenemanExperimentResult( - "Green", (0.193, 0.542), (0.133, 0.520), (13, 3), (5, -2), (5, -4) + "Foliage", + np.array([0.256, 0.547]), + np.array([0.188, 0.537]), + np.array([5, 4]), + np.array([3, 1]), + np.array([4, -2]), ), BrenemanExperimentResult( - "Blue-green", (0.180, 0.516), (0.137, 0.466), (12, 10), (0, 0), (-2, 2) + "Green", + np.array([0.193, 0.542]), + np.array([0.133, 0.520]), + np.array([13, 3]), + np.array([5, -2]), + np.array([5, -4]), + ), + BrenemanExperimentResult( + "Blue-green", + np.array([0.180, 0.516]), + np.array([0.137, 0.466]), + np.array([12, 10]), + np.array([0, 0]), + np.array([-2, 2]), ), BrenemanExperimentResult( - "Blue", (0.186, 0.445), (0.156, 0.353), (12, 45), (6, 1), (2, 6) + "Blue", + np.array([0.186, 0.445]), + np.array([0.156, 0.353]), + np.array([12, 45]), + np.array([6, 1]), + np.array([2, 6]), ), BrenemanExperimentResult( - "Sky", (0.225, 0.492), (0.178, 0.428), (6, 14), (1, -1), (-1, 3) + "Sky", + np.array([0.225, 0.492]), + np.array([0.178, 0.428]), + np.array([6, 14]), + np.array([1, -1]), + np.array([-1, 3]), ), BrenemanExperimentResult( - "Purple", (0.276, 0.456), (0.227, 0.369), (6, 27), (-2, 4), (-3, 9) + "Purple", + np.array([0.276, 0.456]), + np.array([0.227, 0.369]), + np.array([6, 27]), + np.array([-2, 4]), + np.array([-3, 9]), ), ) """ @@ -441,18 +754,45 @@ def __new__( BRENEMAN_EXPERIMENT_7_RESULTS = ( - BrenemanExperimentResult("Gray", (0.208, 0.481), (0.211, 0.486), (2, 3)), - BrenemanExperimentResult("Red", (0.448, 0.512), (0.409, 0.516), (9, 2)), - BrenemanExperimentResult("Skin", (0.269, 0.505), (0.256, 0.506), (4, 3)), - BrenemanExperimentResult("Orange", (0.331, 0.549), (0.305, 0.547), (5, 4)), - BrenemanExperimentResult("Brown", (0.322, 0.541), (0.301, 0.539), (5, 2)), - BrenemanExperimentResult("Yellow", (0.268, 0.555), (0.257, 0.552), (3, 4)), - BrenemanExperimentResult("Foliage", (0.225, 0.538), (0.222, 0.536), (3, 2)), - BrenemanExperimentResult("Green", (0.135, 0.531), (0.153, 0.529), (8, 2)), - BrenemanExperimentResult("Blue-green", (0.145, 0.475), (0.160, 0.484), (3, 5)), - BrenemanExperimentResult("Blue", (0.163, 0.331), (0.171, 0.379), (4, 11)), - BrenemanExperimentResult("Sky", (0.179, 0.438), (0.187, 0.452), (4, 7)), - BrenemanExperimentResult("Purple", (0.245, 0.365), (0.240, 0.398), (4, 10)), + BrenemanExperimentResult( + "Gray", np.array([0.208, 0.481]), np.array([0.211, 0.486]), np.array([2, 3]) + ), + BrenemanExperimentResult( + "Red", np.array([0.448, 0.512]), np.array([0.409, 0.516]), np.array([9, 2]) + ), + BrenemanExperimentResult( + "Skin", np.array([0.269, 0.505]), np.array([0.256, 0.506]), np.array([4, 3]) + ), + BrenemanExperimentResult( + "Orange", np.array([0.331, 0.549]), np.array([0.305, 0.547]), np.array([5, 4]) + ), + BrenemanExperimentResult( + "Brown", np.array([0.322, 0.541]), np.array([0.301, 0.539]), np.array([5, 2]) + ), + BrenemanExperimentResult( + "Yellow", np.array([0.268, 0.555]), np.array([0.257, 0.552]), np.array([3, 4]) + ), + BrenemanExperimentResult( + "Foliage", np.array([0.225, 0.538]), np.array([0.222, 0.536]), np.array([3, 2]) + ), + BrenemanExperimentResult( + "Green", np.array([0.135, 0.531]), np.array([0.153, 0.529]), np.array([8, 2]) + ), + BrenemanExperimentResult( + "Blue-green", + np.array([0.145, 0.475]), + np.array([0.160, 0.484]), + np.array([3, 5]), + ), + BrenemanExperimentResult( + "Blue", np.array([0.163, 0.331]), np.array([0.171, 0.379]), np.array([4, 11]) + ), + BrenemanExperimentResult( + "Sky", np.array([0.179, 0.438]), np.array([0.187, 0.452]), np.array([4, 7]) + ), + BrenemanExperimentResult( + "Purple", np.array([0.245, 0.365]), np.array([0.240, 0.398]), np.array([4, 10]) + ), ) """ *Breneman (1987)* experiment 7 results. @@ -465,42 +805,104 @@ def __new__( BRENEMAN_EXPERIMENT_8_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.258, 0.524), (0.195, 0.469)), BrenemanExperimentResult( - "Gray", (0.257, 0.525), (0.200, 0.494), (2, 3), (1, 2), (0, 0) + "Illuminant", np.array([0.258, 0.524]), np.array([0.195, 0.469]) + ), + BrenemanExperimentResult( + "Gray", + np.array([0.257, 0.525]), + np.array([0.200, 0.494]), + np.array([2, 3]), + np.array([1, 2]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Red", (0.458, 0.522), (0.410, 0.508), (12, 4), (-3, 5), (-7, 2) + "Red", + np.array([0.458, 0.522]), + np.array([0.410, 0.508]), + np.array([12, 4]), + np.array([-3, 5]), + np.array([-7, 2]), ), BrenemanExperimentResult( - "Skin", (0.308, 0.526), (0.249, 0.502), (6, 2), (-1, 1), (-3, -1) + "Skin", + np.array([0.308, 0.526]), + np.array([0.249, 0.502]), + np.array([6, 2]), + np.array([-1, 1]), + np.array([-3, -1]), ), BrenemanExperimentResult( - "Orange", (0.359, 0.545), (0.299, 0.545), (12, 4), (0, -2), (-3, 0) + "Orange", + np.array([0.359, 0.545]), + np.array([0.299, 0.545]), + np.array([12, 4]), + np.array([0, -2]), + np.array([-3, 0]), ), BrenemanExperimentResult( - "Brown", (0.349, 0.540), (0.289, 0.532), (10, 4), (0, 1), (-2, 2) + "Brown", + np.array([0.349, 0.540]), + np.array([0.289, 0.532]), + np.array([10, 4]), + np.array([0, 1]), + np.array([-2, 2]), ), BrenemanExperimentResult( - "Yellow", (0.317, 0.550), (0.256, 0.549), (9, 5), (0, -3), (-3, 1) + "Yellow", + np.array([0.317, 0.550]), + np.array([0.256, 0.549]), + np.array([9, 5]), + np.array([0, -3]), + np.array([-3, 1]), ), BrenemanExperimentResult( - "Foliage", (0.260, 0.545), (0.198, 0.529), (5, 5), (3, 1), (0, 3) + "Foliage", + np.array([0.260, 0.545]), + np.array([0.198, 0.529]), + np.array([5, 5]), + np.array([3, 1]), + np.array([0, 3]), ), BrenemanExperimentResult( - "Green", (0.193, 0.543), (0.137, 0.520), (9, 5), (3, 0), (2, 1) + "Green", + np.array([0.193, 0.543]), + np.array([0.137, 0.520]), + np.array([9, 5]), + np.array([3, 0]), + np.array([2, 1]), ), BrenemanExperimentResult( - "Blue-green", (0.182, 0.516), (0.139, 0.477), (9, 4), (-3, 0), (-2, -4) + "Blue-green", + np.array([0.182, 0.516]), + np.array([0.139, 0.477]), + np.array([9, 4]), + np.array([-3, 0]), + np.array([-2, -4]), ), BrenemanExperimentResult( - "Blue", (0.184, 0.444), (0.150, 0.387), (5, 11), (3, -10), (6, -22) + "Blue", + np.array([0.184, 0.444]), + np.array([0.150, 0.387]), + np.array([5, 11]), + np.array([3, -10]), + np.array([6, -22]), ), BrenemanExperimentResult( - "Sky", (0.224, 0.489), (0.177, 0.439), (5, 6), (1, 1), (1, -7) + "Sky", + np.array([0.224, 0.489]), + np.array([0.177, 0.439]), + np.array([5, 6]), + np.array([1, 1]), + np.array([1, -7]), ), BrenemanExperimentResult( - "Purple", (0.277, 0.454), (0.226, 0.389), (4, 10), (1, 4), (1, -8) + "Purple", + np.array([0.277, 0.454]), + np.array([0.226, 0.389]), + np.array([4, 10]), + np.array([1, 4]), + np.array([1, -8]), ), ) """ @@ -515,61 +917,155 @@ def __new__( BRENEMAN_EXPERIMENT_9_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.254, 0.525), (0.195, 0.465)), BrenemanExperimentResult( - "Gray", (0.256, 0.524), (0.207, 0.496), (4, 6), (3, 2), (0, 0) + "Illuminant", np.array([0.254, 0.525]), np.array([0.195, 0.465]) ), BrenemanExperimentResult( - "Red", (0.459, 0.521), (0.415, 0.489), (20, 14), (2, 12), (-2, 21) + "Gray", + np.array([0.256, 0.524]), + np.array([0.207, 0.496]), + np.array([4, 6]), + np.array([3, 2]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Skin", (0.307, 0.525), (0.261, 0.500), (7, 7), (0, 1), (-5, 2) + "Red", + np.array([0.459, 0.521]), + np.array([0.415, 0.489]), + np.array([20, 14]), + np.array([2, 12]), + np.array([-2, 21]), ), BrenemanExperimentResult( - "Orange", (0.359, 0.545), (0.313, 0.532), (7, 5), (-2, -3), (-6, 13) + "Skin", + np.array([0.307, 0.525]), + np.array([0.261, 0.500]), + np.array([7, 7]), + np.array([0, 1]), + np.array([-5, 2]), ), BrenemanExperimentResult( - "Brown", (0.349, 0.540), (0.302, 0.510), (11, 15), (0, 12), (-5, 24) + "Orange", + np.array([0.359, 0.545]), + np.array([0.313, 0.532]), + np.array([7, 5]), + np.array([-2, -3]), + np.array([-6, 13]), ), BrenemanExperimentResult( - "Yellow", (0.317, 0.550), (0.268, 0.538), (7, 10), (1, -4), (-4, 12) + "Brown", + np.array([0.349, 0.540]), + np.array([0.302, 0.510]), + np.array([11, 15]), + np.array([0, 12]), + np.array([-5, 24]), ), BrenemanExperimentResult( - "Foliage", (0.259, 0.544), (0.212, 0.510), (10, 11), (0, 14), (-4, 22) + "Yellow", + np.array([0.317, 0.550]), + np.array([0.268, 0.538]), + np.array([7, 10]), + np.array([1, -4]), + np.array([-4, 12]), ), BrenemanExperimentResult( - "Green", (0.193, 0.542), (0.150, 0.506), (6, 10), (-1, 13), (-2, 15) + "Foliage", + np.array([0.259, 0.544]), + np.array([0.212, 0.510]), + np.array([10, 11]), + np.array([0, 14]), + np.array([-4, 22]), ), BrenemanExperimentResult( - "Blue-green", (0.181, 0.517), (0.144, 0.487), (9, 6), (-3, 0), (-1, -9) + "Green", + np.array([0.193, 0.542]), + np.array([0.150, 0.506]), + np.array([6, 10]), + np.array([-1, 13]), + np.array([-2, 15]), ), BrenemanExperimentResult( - "Blue", (0.184, 0.444), (0.155, 0.407), (4, 11), (-2, -6), (6, -36) + "Blue-green", + np.array([0.181, 0.517]), + np.array([0.144, 0.487]), + np.array([9, 6]), + np.array([-3, 0]), + np.array([-1, -9]), ), BrenemanExperimentResult( - "Sky", (0.225, 0.490), (0.183, 0.458), (5, 8), (1, -3), (2, -19) + "Blue", + np.array([0.184, 0.444]), + np.array([0.155, 0.407]), + np.array([4, 11]), + np.array([-2, -6]), + np.array([6, -36]), ), BrenemanExperimentResult( - "Purple", (0.276, 0.454), (0.233, 0.404), (7, 12), (2, 9), (0, -16) + "Sky", + np.array([0.225, 0.490]), + np.array([0.183, 0.458]), + np.array([5, 8]), + np.array([1, -3]), + np.array([2, -19]), ), - BrenemanExperimentResult("(Gray)h", (0.256, 0.525), (0.208, 0.498)), BrenemanExperimentResult( - "(Red)h", (0.456, 0.521), (0.416, 0.501), (15, 7), None, (-6, -9) + "Purple", + np.array([0.276, 0.454]), + np.array([0.233, 0.404]), + np.array([7, 12]), + np.array([2, 9]), + np.array([0, -16]), ), BrenemanExperimentResult( - "(Brown)h", (0.349, 0.539), (0.306, 0.526), (11, 8), None, (-8, 7) + "(Gray)h", np.array([0.256, 0.525]), np.array([0.208, 0.498]) ), BrenemanExperimentResult( - "(Foliage)h", (0.260, 0.545), (0.213, 0.528), (7, 9), None, (-4, 5) + "(Red)h", + np.array([0.456, 0.521]), + np.array([0.416, 0.501]), + np.array([15, 7]), + None, + np.array([-6, -9]), ), BrenemanExperimentResult( - "(Green)h", (0.193, 0.543), (0.149, 0.525), (10, 8), None, (-1, -1) + "(Brown)h", + np.array([0.349, 0.539]), + np.array([0.306, 0.526]), + np.array([11, 8]), + None, + np.array([-8, 7]), ), BrenemanExperimentResult( - "(Blue)h", (0.184, 0.444), (0.156, 0.419), (7, 8), None, (4, -45) + "(Foliage)h", + np.array([0.260, 0.545]), + np.array([0.213, 0.528]), + np.array([7, 9]), + None, + np.array([-4, 5]), ), BrenemanExperimentResult( - "(Purple)h", (0.277, 0.456), (0.236, 0.422), (6, 11), None, (-2, -29) + "(Green)h", + np.array([0.193, 0.543]), + np.array([0.149, 0.525]), + np.array([10, 8]), + None, + np.array([-1, -1]), + ), + BrenemanExperimentResult( + "(Blue)h", + np.array([0.184, 0.444]), + np.array([0.156, 0.419]), + np.array([7, 8]), + None, + np.array([4, -45]), + ), + BrenemanExperimentResult( + "(Purple)h", + np.array([0.277, 0.456]), + np.array([0.236, 0.422]), + np.array([6, 11]), + None, + np.array([-2, -29]), ), ) """ @@ -586,18 +1082,45 @@ def __new__( BRENEMAN_EXPERIMENT_10_RESULTS = ( - BrenemanExperimentResult("Gray", (0.208, 0.482), (0.213, 0.494), (3, 3)), - BrenemanExperimentResult("Red", (0.447, 0.512), (0.411, 0.506), (15, 7)), - BrenemanExperimentResult("Skin", (0.269, 0.505), (0.269, 0.511), (4, 3)), - BrenemanExperimentResult("Orange", (0.331, 0.549), (0.315, 0.536), (7, 8)), - BrenemanExperimentResult("Brown", (0.323, 0.542), (0.310, 0.526), (6, 8)), - BrenemanExperimentResult("Yellow", (0.268, 0.556), (0.268, 0.541), (3, 6)), - BrenemanExperimentResult("Foliage", (0.226, 0.538), (0.230, 0.525), (4, 8)), - BrenemanExperimentResult("Green", (0.135, 0.531), (0.158, 0.524), (6, 3)), - BrenemanExperimentResult("Blue-green", (0.145, 0.476), (0.161, 0.491), (4, 4)), - BrenemanExperimentResult("Blue", (0.163, 0.330), (0.171, 0.377), (6, 19)), - BrenemanExperimentResult("Sky", (0.179, 0.439), (0.187, 0.465), (5, 5)), - BrenemanExperimentResult("Purple", (0.245, 0.366), (0.240, 0.402), (3, 12)), + BrenemanExperimentResult( + "Gray", np.array([0.208, 0.482]), np.array([0.213, 0.494]), np.array([3, 3]) + ), + BrenemanExperimentResult( + "Red", np.array([0.447, 0.512]), np.array([0.411, 0.506]), np.array([15, 7]) + ), + BrenemanExperimentResult( + "Skin", np.array([0.269, 0.505]), np.array([0.269, 0.511]), np.array([4, 3]) + ), + BrenemanExperimentResult( + "Orange", np.array([0.331, 0.549]), np.array([0.315, 0.536]), np.array([7, 8]) + ), + BrenemanExperimentResult( + "Brown", np.array([0.323, 0.542]), np.array([0.310, 0.526]), np.array([6, 8]) + ), + BrenemanExperimentResult( + "Yellow", np.array([0.268, 0.556]), np.array([0.268, 0.541]), np.array([3, 6]) + ), + BrenemanExperimentResult( + "Foliage", np.array([0.226, 0.538]), np.array([0.230, 0.525]), np.array([4, 8]) + ), + BrenemanExperimentResult( + "Green", np.array([0.135, 0.531]), np.array([0.158, 0.524]), np.array([6, 3]) + ), + BrenemanExperimentResult( + "Blue-green", + np.array([0.145, 0.476]), + np.array([0.161, 0.491]), + np.array([4, 4]), + ), + BrenemanExperimentResult( + "Blue", np.array([0.163, 0.330]), np.array([0.171, 0.377]), np.array([6, 19]) + ), + BrenemanExperimentResult( + "Sky", np.array([0.179, 0.439]), np.array([0.187, 0.465]), np.array([5, 5]) + ), + BrenemanExperimentResult( + "Purple", np.array([0.245, 0.366]), np.array([0.240, 0.402]), np.array([3, 12]) + ), ) """ *Breneman (1987)* experiment 10 results. @@ -610,42 +1133,104 @@ def __new__( BRENEMAN_EXPERIMENT_11_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.208, 0.482), (0.174, 0.520)), BrenemanExperimentResult( - "Gray", (0.209, 0.483), (0.176, 0.513), (3, 4), (2, 2), (0, 0) + "Illuminant", np.array([0.208, 0.482]), np.array([0.174, 0.520]) + ), + BrenemanExperimentResult( + "Gray", + np.array([0.209, 0.483]), + np.array([0.176, 0.513]), + np.array([3, 4]), + np.array([2, 2]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Red", (0.450, 0.512), (0.419, 0.524), (10, 2), (3, 2), (8, -1) + "Red", + np.array([0.450, 0.512]), + np.array([0.419, 0.524]), + np.array([10, 2]), + np.array([3, 2]), + np.array([8, -1]), ), BrenemanExperimentResult( - "Skin", (0.268, 0.506), (0.240, 0.528), (6, 2), (-4, 0), (-3, 0) + "Skin", + np.array([0.268, 0.506]), + np.array([0.240, 0.528]), + np.array([6, 2]), + np.array([-4, 0]), + np.array([-3, 0]), ), BrenemanExperimentResult( - "Orange", (0.331, 0.547), (0.293, 0.553), (6, 2), (3, -1), (5, 1) + "Orange", + np.array([0.331, 0.547]), + np.array([0.293, 0.553]), + np.array([6, 2]), + np.array([3, -1]), + np.array([5, 1]), ), BrenemanExperimentResult( - "Brown", (0.323, 0.542), (0.290, 0.552), (5, 2), (-1, -3), (0, -1) + "Brown", + np.array([0.323, 0.542]), + np.array([0.290, 0.552]), + np.array([5, 2]), + np.array([-1, -3]), + np.array([0, -1]), ), BrenemanExperimentResult( - "Yellow", (0.266, 0.549), (0.236, 0.557), (4, 2), (-3, -2), (-4, 2) + "Yellow", + np.array([0.266, 0.549]), + np.array([0.236, 0.557]), + np.array([4, 2]), + np.array([-3, -2]), + np.array([-4, 2]), ), BrenemanExperimentResult( - "Foliage", (0.227, 0.538), (0.194, 0.552), (4, 2), (2, -3), (-1, 1) + "Foliage", + np.array([0.227, 0.538]), + np.array([0.194, 0.552]), + np.array([4, 2]), + np.array([2, -3]), + np.array([-1, 1]), ), BrenemanExperimentResult( - "Green", (0.146, 0.534), (0.118, 0.551), (8, 3), (4, -2), (-6, 3) + "Green", + np.array([0.146, 0.534]), + np.array([0.118, 0.551]), + np.array([8, 3]), + np.array([4, -2]), + np.array([-6, 3]), ), BrenemanExperimentResult( - "Blue-green", (0.160, 0.475), (0.130, 0.513), (9, 4), (1, -1), (-4, -3) + "Blue-green", + np.array([0.160, 0.475]), + np.array([0.130, 0.513]), + np.array([9, 4]), + np.array([1, -1]), + np.array([-4, -3]), ), BrenemanExperimentResult( - "Blue", (0.177, 0.340), (0.133, 0.427), (6, 14), (4, -17), (11, -29) + "Blue", + np.array([0.177, 0.340]), + np.array([0.133, 0.427]), + np.array([6, 14]), + np.array([4, -17]), + np.array([11, -29]), ), BrenemanExperimentResult( - "Sky", (0.179, 0.438), (0.146, 0.482), (6, 10), (1, 4), (0, -1) + "Sky", + np.array([0.179, 0.438]), + np.array([0.146, 0.482]), + np.array([6, 10]), + np.array([1, 4]), + np.array([0, -1]), ), BrenemanExperimentResult( - "Purple", (0.245, 0.366), (0.216, 0.419), (4, 13), (-3, 8), (4, -2) + "Purple", + np.array([0.245, 0.366]), + np.array([0.216, 0.419]), + np.array([4, 13]), + np.array([-3, 8]), + np.array([4, -2]), ), ) """ @@ -660,42 +1245,104 @@ def __new__( BRENEMAN_EXPERIMENT_12_RESULTS = ( - BrenemanExperimentResult("Illuminant", (0.205, 0.482), (0.174, 0.519)), BrenemanExperimentResult( - "Gray", (0.208, 0.482), (0.181, 0.507), (4, 3), (0, 1), (0, 0) + "Illuminant", np.array([0.205, 0.482]), np.array([0.174, 0.519]) ), BrenemanExperimentResult( - "Red", (0.451, 0.512), (0.422, 0.526), (20, 3), (0, -5), (10, -5) + "Gray", + np.array([0.208, 0.482]), + np.array([0.181, 0.507]), + np.array([4, 3]), + np.array([0, 1]), + np.array([0, 0]), ), BrenemanExperimentResult( - "Skin", (0.268, 0.506), (0.244, 0.525), (5, 2), (-6, 0), (-2, -1) + "Red", + np.array([0.451, 0.512]), + np.array([0.422, 0.526]), + np.array([20, 3]), + np.array([0, -5]), + np.array([10, -5]), ), BrenemanExperimentResult( - "Orange", (0.331, 0.548), (0.292, 0.553), (10, 2), (5, 2), (11, 1) + "Skin", + np.array([0.268, 0.506]), + np.array([0.244, 0.525]), + np.array([5, 2]), + np.array([-6, 0]), + np.array([-2, -1]), ), BrenemanExperimentResult( - "Brown", (0.324, 0.542), (0.286, 0.554), (8, 1), (5, -3), (10, -4) + "Orange", + np.array([0.331, 0.548]), + np.array([0.292, 0.553]), + np.array([10, 2]), + np.array([5, 2]), + np.array([11, 1]), ), BrenemanExperimentResult( - "Yellow", (0.266, 0.548), (0.238, 0.558), (6, 2), (-3, -1), (-1, -2) + "Brown", + np.array([0.324, 0.542]), + np.array([0.286, 0.554]), + np.array([8, 1]), + np.array([5, -3]), + np.array([10, -4]), ), BrenemanExperimentResult( - "Foliage", (0.227, 0.538), (0.196, 0.555), (6, 3), (3, -4), (2, -5) + "Yellow", + np.array([0.266, 0.548]), + np.array([0.238, 0.558]), + np.array([6, 2]), + np.array([-3, -1]), + np.array([-1, -2]), ), BrenemanExperimentResult( - "Green", (0.145, 0.534), (0.124, 0.551), (8, 6), (1, -1), (-8, -1) + "Foliage", + np.array([0.227, 0.538]), + np.array([0.196, 0.555]), + np.array([6, 3]), + np.array([3, -4]), + np.array([2, -5]), ), BrenemanExperimentResult( - "Blue-green", (0.160, 0.474), (0.135, 0.505), (5, 2), (1, -1), (-4, -3) + "Green", + np.array([0.145, 0.534]), + np.array([0.124, 0.551]), + np.array([8, 6]), + np.array([1, -1]), + np.array([-8, -1]), ), BrenemanExperimentResult( - "Blue", (0.178, 0.339), (0.149, 0.392), (4, 20), (-1, -5), (3, -7) + "Blue-green", + np.array([0.160, 0.474]), + np.array([0.135, 0.505]), + np.array([5, 2]), + np.array([1, -1]), + np.array([-4, -3]), ), BrenemanExperimentResult( - "Sky", (0.179, 0.440), (0.150, 0.473), (4, 8), (3, 2), (2, 0) + "Blue", + np.array([0.178, 0.339]), + np.array([0.149, 0.392]), + np.array([4, 20]), + np.array([-1, -5]), + np.array([3, -7]), ), BrenemanExperimentResult( - "Purple", (0.246, 0.366), (0.222, 0.404), (5, 15), (-4, 2), (4, 2) + "Sky", + np.array([0.179, 0.440]), + np.array([0.150, 0.473]), + np.array([4, 8]), + np.array([3, 2]), + np.array([2, 0]), + ), + BrenemanExperimentResult( + "Purple", + np.array([0.246, 0.366]), + np.array([0.222, 0.404]), + np.array([5, 15]), + np.array([-4, 2]), + np.array([4, 2]), ), ) """ @@ -711,51 +1358,76 @@ def __new__( BRENEMAN_EXPERIMENT_PRIMARIES_CHROMATICITIES = { 1: PrimariesChromaticityCoordinates( - 1, ("A", "D65"), 1500, (0.671, 0.519), (-0.586, 0.627), (0.253, 0.016) + 1, + ("A", "D65"), + 1500, + np.array([0.671, 0.519]), + np.array([-0.586, 0.627]), + np.array([0.253, 0.016]), ), 2: PrimariesChromaticityCoordinates( 2, ("Projector", "D55"), 1500, - (0.675, 0.523), - (-0.466, 0.617), - (0.255, 0.018), + np.array([0.675, 0.523]), + np.array([-0.466, 0.617]), + np.array([0.255, 0.018]), ), 3: PrimariesChromaticityCoordinates( 3, ("Projector", "D55"), 75, - (0.664, 0.510), - (-0.256, 0.729), - (0.244, 0.003), + np.array([0.664, 0.510]), + np.array([-0.256, 0.729]), + np.array([0.244, 0.003]), ), 4: PrimariesChromaticityCoordinates( - 4, ("A", "D65"), 75, (0.674, 0.524), (-0.172, 0.628), (0.218, -0.026) + 4, + ("A", "D65"), + 75, + np.array([0.674, 0.524]), + np.array([-0.172, 0.628]), + np.array([0.218, -0.026]), ), 6: PrimariesChromaticityCoordinates( - 6, ("A", "D55"), 11100, (0.659, 0.506), (-0.141, 0.615), (0.249, 0.009) + 6, + ("A", "D55"), + 11100, + np.array([0.659, 0.506]), + np.array([-0.141, 0.615]), + np.array([0.249, 0.009]), ), 8: PrimariesChromaticityCoordinates( - 8, ("A", "D65"), 350, (0.659, 0.505), (-0.246, 0.672), (0.235, -0.006) + 8, + ("A", "D65"), + 350, + np.array([0.659, 0.505]), + np.array([-0.246, 0.672]), + np.array([0.235, -0.006]), ), 9: PrimariesChromaticityCoordinates( - 9, ("A", "D65"), 15, (0.693, 0.546), (-0.446, 0.773), (0.221, -0.023) + 9, + ("A", "D65"), + 15, + np.array([0.693, 0.546]), + np.array([-0.446, 0.773]), + np.array([0.221, -0.023]), ), 11: PrimariesChromaticityCoordinates( 11, ("D55", "green"), 1560, - (0.680, 0.529), - (0.018, 0.576), - (0.307, 0.080), + np.array([0.680, 0.529]), + np.array([0.018, 0.576]), + np.array([0.307, 0.080]), ), 12: PrimariesChromaticityCoordinates( 12, ("D55", "green"), 75, - (0.661, 0.505), - (0.039, 0.598), - (0.345, 0.127), + np.array([0.661, 0.505]), + np.array([0.039, 0.598]), + np.array([0.345, 0.127]), ), } if is_documentation_building(): # pragma: no cover diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index 95613adc4..c21722846 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -38,7 +38,7 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass import numpy as np @@ -58,6 +58,7 @@ ArrayLike, Literal, LiteralChromaticAdaptationTransform, + NDArrayFloat, Tuple, ) from colour.models import ( @@ -70,6 +71,8 @@ ) from colour.utilities import ( CanonicalMapping, + MixinDataclassIterable, + as_float_array, as_float_scalar, attest, domain_range_scale, @@ -98,23 +101,8 @@ ] -class CorrespondingColourDataset( - namedtuple( - "CorrespondingColourDataset", - ( - "name", - "XYZ_r", - "XYZ_t", - "XYZ_cr", - "XYZ_ct", - "Y_r", - "Y_t", - "B_r", - "B_t", - "metadata", - ), - ) -): +@dataclass(frozen=True) +class CorrespondingColourDataset(MixinDataclassIterable): """ Define a corresponding colour dataset. @@ -154,13 +142,28 @@ class CorrespondingColourDataset( :cite:`Luo1999` """ + name: int + XYZ_r: NDArrayFloat + XYZ_t: NDArrayFloat + XYZ_cr: NDArrayFloat + XYZ_ct: NDArrayFloat + Y_r: float + Y_t: float + B_r: float + B_t: float + metadata: dict -class CorrespondingChromaticitiesPrediction( - namedtuple( - "CorrespondingChromaticitiesPrediction", - ("name", "uv_t", "uv_m", "uv_p"), - ) -): + def __post_init__(self) -> None: + """Post-initialise the class.""" + + object.__setattr__(self, "XYZ_r", as_float_array(self.XYZ_r)) + object.__setattr__(self, "XYZ_t", as_float_array(self.XYZ_t)) + object.__setattr__(self, "XYZ_cr", as_float_array(self.XYZ_cr)) + object.__setattr__(self, "XYZ_ct", as_float_array(self.XYZ_ct)) + + +@dataclass(frozen=True) +class CorrespondingChromaticitiesPrediction(MixinDataclassIterable): """ Define a chromatic adaptation model prediction. @@ -176,6 +179,18 @@ class CorrespondingChromaticitiesPrediction( Chromaticity coordinates :math:`uv_p^p` of predicted colour. """ + name: int + uv_t: NDArrayFloat + uv_m: NDArrayFloat + uv_p: NDArrayFloat + + def __post_init__(self) -> None: + """Post-initialise the class.""" + + object.__setattr__(self, "uv_t", as_float_array(self.uv_t)) + object.__setattr__(self, "uv_m", as_float_array(self.uv_m)) + object.__setattr__(self, "uv_p", as_float_array(self.uv_p)) + def convert_experiment_results_Breneman1987( experiment: Literal[1, 2, 3, 4, 6, 8, 9, 11, 12], @@ -197,7 +212,7 @@ def convert_experiment_results_Breneman1987( Examples -------- >>> from pprint import pprint - >>> pprint(tuple(convert_experiment_results_Breneman1987(2))) + >>> pprint(tuple(convert_experiment_results_Breneman1987(2).values)) ... # doctest: +ELLIPSIS (2, array([ 0.9582463..., 1. , 0.9436325...]), @@ -266,7 +281,7 @@ def convert_experiment_results_Breneman1987( xy_to_XYZ( np.hstack( [ - Luv_uv_to_xy(illuminant_chromaticities[1:3]), + Luv_uv_to_xy(illuminant_chromaticities.values[1:3]), full((2, 1), Y_r), ] ) @@ -279,7 +294,7 @@ def convert_experiment_results_Breneman1987( xyY_cr.append( np.hstack( [ - Luv_uv_to_xy(experiment_result[2]), + Luv_uv_to_xy(experiment_result.values[2]), samples_luminance[i] * Y_r, ] ) @@ -287,7 +302,7 @@ def convert_experiment_results_Breneman1987( xyY_ct.append( np.hstack( [ - Luv_uv_to_xy(experiment_result[1]), + Luv_uv_to_xy(experiment_result.values[1]), samples_luminance[i] * Y_t, ] ) diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index d8dc12141..50d654684 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -123,8 +123,8 @@ ], ] ), - Y_r=np.array(1500), - Y_t=np.array(1500), + Y_r=1500, + Y_t=1500, B_r=0.3, B_t=0.3, metadata={}, diff --git a/colour/difference/cam02_ucs.py b/colour/difference/cam02_ucs.py index 2e88deaf1..f91063766 100644 --- a/colour/difference/cam02_ucs.py +++ b/colour/difference/cam02_ucs.py @@ -21,7 +21,7 @@ import numpy as np from colour.hints import ArrayLike, NDArrayFloat -from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006 +from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006, Coefficients_UCS_Luo2006 from colour.utilities import as_float, tsplit __author__ = "Colour Developers" @@ -40,7 +40,7 @@ def delta_E_Luo2006( - Jpapbp_1: ArrayLike, Jpapbp_2: ArrayLike, coefficients: ArrayLike + Jpapbp_1: ArrayLike, Jpapbp_2: ArrayLike, coefficients: Coefficients_UCS_Luo2006 ) -> NDArrayFloat: """ Return the difference :math:`\\Delta E'` between two given @@ -99,7 +99,7 @@ def delta_E_Luo2006( J_p_1, a_p_1, b_p_1 = tsplit(Jpapbp_1) J_p_2, a_p_2, b_p_2 = tsplit(Jpapbp_2) - K_L, _c_1, _c_2 = tsplit(coefficients) + K_L, _c_1, _c_2 = coefficients.values d_E = np.sqrt( ((J_p_1 - J_p_2) / K_L) ** 2 + (a_p_1 - a_p_2) ** 2 + (b_p_1 - b_p_2) ** 2 diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index b791f14cb..34b03609b 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -15,8 +15,8 @@ import re import sys import textwrap -from collections import namedtuple from copy import copy +from dataclasses import dataclass from functools import partial from pprint import pformat @@ -226,9 +226,8 @@ ] -class Conversion_Specification( - namedtuple("Conversion_Specification", ("source", "target", "conversion_function")) -): +@dataclass(frozen=True) +class Conversion_Specification: """ Conversion specification for *Colour* graph for automatic colour conversion describing two nodes and the edge in the graph. @@ -243,15 +242,15 @@ class Conversion_Specification( Callable converting from the ``source`` node to the ``target`` node. """ - def __new__( - cls, source: str, target: str, conversion_function: Callable - ) -> Conversion_Specification: - """ - Return a new instance of the - :class:`colour.graph.conversion.Conversion_Specification` class. - """ + source: str + target: str + conversion_function: Callable - return super().__new__(cls, source.lower(), target.lower(), conversion_function) + def __post_init__(self) -> None: + """Post-initialise the class.""" + + object.__setattr__(self, "source", self.source.lower()) + object.__setattr__(self, "target", self.target.lower()) def CIECAM02_to_JMh_CIECAM02( diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index bd6359249..30c5c7216 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -42,6 +42,7 @@ List, Literal, NDArrayFloat, + Self, Sequence, Type, cast, @@ -357,7 +358,7 @@ def __repr__(self) -> str: return multiline_repr(self, attributes) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the *LUT* is equal to given other object. @@ -379,7 +380,7 @@ def __eq__(self, other: Any) -> bool: ] ) - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the *LUT* is not equal to given other object. @@ -413,7 +414,7 @@ def __add__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "+") - def __iadd__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __iadd__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for in-place addition. @@ -430,7 +431,7 @@ def __iadd__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "+", True) - def __sub__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __sub__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for subtraction. @@ -447,7 +448,7 @@ def __sub__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "-") - def __isub__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __isub__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for in-place subtraction. @@ -464,7 +465,7 @@ def __isub__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "-", True) - def __mul__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __mul__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for multiplication. @@ -481,7 +482,7 @@ def __mul__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "*") - def __imul__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __imul__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for in-place multiplication. @@ -498,7 +499,7 @@ def __imul__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "*", True) - def __div__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __div__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for division. @@ -515,7 +516,7 @@ def __div__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "/") - def __idiv__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __idiv__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for in-place division. @@ -535,7 +536,7 @@ def __idiv__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: __itruediv__ = __idiv__ __truediv__ = __div__ - def __pow__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __pow__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for exponentiation. @@ -552,7 +553,7 @@ def __pow__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: return self.arithmetical_operation(a, "**") - def __ipow__(self, a: ArrayLike | AbstractLUT) -> AbstractLUT: + def __ipow__(self, a: ArrayLike | AbstractLUT) -> Self: """ Implement support for in-place exponentiation. @@ -574,7 +575,7 @@ def arithmetical_operation( a: ArrayLike | AbstractLUT, operation: Literal["+", "-", "*", "/", "**"], in_place: bool = False, - ) -> AbstractLUT: + ) -> Self: """ Perform given arithmetical operation with :math:`a` operand, the operation can be either performed on a copy or in-place, must be diff --git a/colour/io/luts/operator.py b/colour/io/luts/operator.py index 3db8f4884..d8a72717b 100644 --- a/colour/io/luts/operator.py +++ b/colour/io/luts/operator.py @@ -411,7 +411,7 @@ def __repr__(self) -> str: ] ) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the *LUT* operator is equal to given other object. @@ -438,7 +438,7 @@ def __eq__(self, other: Any) -> bool: ] ) - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the *LUT* operator is not equal to given other object. diff --git a/colour/io/luts/sequence.py b/colour/io/luts/sequence.py index 9e6a576db..9b1bc510a 100644 --- a/colour/io/luts/sequence.py +++ b/colour/io/luts/sequence.py @@ -261,7 +261,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(\n{operations}\n)" - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the *LUT* sequence is equal to given other object. @@ -284,7 +284,7 @@ def __eq__(self, other: Any) -> bool: return all(self[i] == other[i] for i in range(len(self))) - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the *LUT* sequence is not equal to given other object. diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index de2457a17..2c3f066d0 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -687,7 +687,7 @@ def __hash__(self) -> int: ) ) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the header is equal to given other object. @@ -727,7 +727,7 @@ def __eq__(self, other: Any) -> bool: ) return False - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the header is not equal to given other object. diff --git a/colour/models/cam02_ucs.py b/colour/models/cam02_ucs.py index aae251777..9c9110a57 100644 --- a/colour/models/cam02_ucs.py +++ b/colour/models/cam02_ucs.py @@ -27,7 +27,7 @@ from __future__ import annotations -from collections import namedtuple +from dataclasses import dataclass import numpy as np @@ -35,6 +35,7 @@ from colour.hints import Any, ArrayLike, NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, + MixinDataclassIterable, as_float_array, from_range_100, from_range_degrees, @@ -74,14 +75,17 @@ ] -class Coefficients_UCS_Luo2006( - namedtuple("Coefficients_UCS_Luo2006", ("K_L", "c_1", "c_2")) -): +@dataclass(frozen=True) +class Coefficients_UCS_Luo2006(MixinDataclassIterable): """ Define the class storing *Luo et al. (2006)* fitting coefficients for the *CAM02-LCD*, *CAM02-SCD*, and *CAM02-UCS* colourspaces. """ + K_L: float + c_1: float + c_2: float + COEFFICIENTS_UCS_LUO2006: CanonicalMapping = CanonicalMapping( { @@ -97,7 +101,7 @@ class Coefficients_UCS_Luo2006( def JMh_CIECAM02_to_UCS_Luo2006( - JMh: ArrayLike, coefficients: ArrayLike + JMh: ArrayLike, coefficients: Coefficients_UCS_Luo2006 ) -> NDArrayFloat: """ Convert from *CIECAM02* :math:`JMh` correlates array to one of the @@ -168,7 +172,7 @@ def JMh_CIECAM02_to_UCS_Luo2006( M = to_domain_100(M) h = to_domain_degrees(h) - _K_L, c_1, c_2 = tsplit(coefficients) + _K_L, c_1, c_2 = coefficients.values J_p = ((1 + 100 * c_1) * J) / (1 + c_1 * J) M_p = (1 / c_2) * np.log1p(c_2 * M) @@ -181,7 +185,7 @@ def JMh_CIECAM02_to_UCS_Luo2006( def UCS_Luo2006_to_JMh_CIECAM02( - Jpapbp: ArrayLike, coefficients: ArrayLike + Jpapbp: ArrayLike, coefficients: Coefficients_UCS_Luo2006 ) -> NDArrayFloat: """ Convert from one of the *Luo et al. (2006)* *CAM02-LCD*, *CAM02-SCD*, or @@ -233,7 +237,7 @@ def UCS_Luo2006_to_JMh_CIECAM02( """ J_p, a_p, b_p = tsplit(to_domain_100(Jpapbp)) - _K_L, c_1, c_2 = tsplit(coefficients) + _K_L, c_1, c_2 = coefficients.values J = -J_p / (c_1 * J_p - 1 - 100 * c_1) @@ -611,7 +615,7 @@ def CAM02UCS_to_JMh_CIECAM02(Jpapbp: ArrayLike) -> NDArrayFloat: def XYZ_to_UCS_Luo2006( - XYZ: ArrayLike, coefficients: ArrayLike, **kwargs: Any + XYZ: ArrayLike, coefficients: Coefficients_UCS_Luo2006, **kwargs: Any ) -> NDArrayFloat: """ Convert from *CIE XYZ* tristimulus values to one of the @@ -698,7 +702,7 @@ def XYZ_to_UCS_Luo2006( def UCS_Luo2006_to_XYZ( - Jpapbp: ArrayLike, coefficients: ArrayLike, **kwargs: Any + Jpapbp: ArrayLike, coefficients: Coefficients_UCS_Luo2006, **kwargs: Any ) -> NDArrayFloat: """ Convert from one of the *Luo et al. (2006)* *CAM02-LCD*, *CAM02-SCD*, or diff --git a/colour/plotting/corresponding.py b/colour/plotting/corresponding.py index 2cf8675df..23445ecea 100644 --- a/colour/plotting/corresponding.py +++ b/colour/plotting/corresponding.py @@ -123,7 +123,7 @@ def plot_corresponding_chromaticities_prediction( ) for result in results: - _name, uv_t, uv_m, uv_p = result + _name, uv_t, uv_m, uv_p = result.values axes.arrow( uv_t[0], uv_t[1], diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 523929e24..57ddb8e41 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -44,6 +44,7 @@ NDArrayFloat, NDArrayInt, Real, + Self, Sequence, Type, cast, @@ -311,7 +312,7 @@ class MixinDataclassArithmetic(MixinDataclassArray): - :class:`colour.utilities.MixinDataclassFields` """ - def __add__(self, a: Any) -> Dataclass: + def __add__(self, a: Any) -> Self: """ Implement support for addition. @@ -328,7 +329,7 @@ def __add__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "+") - def __iadd__(self, a: Any) -> Dataclass: + def __iadd__(self, a: Any) -> Self: """ Implement support for in-place addition. @@ -345,7 +346,7 @@ def __iadd__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "+", True) - def __sub__(self, a: Any) -> Dataclass: + def __sub__(self, a: Any) -> Self: """ Implement support for subtraction. @@ -362,7 +363,7 @@ def __sub__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "-") - def __isub__(self, a: Any) -> Dataclass: + def __isub__(self, a: Any) -> Self: """ Implement support for in-place subtraction. @@ -379,7 +380,7 @@ def __isub__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "-", True) - def __mul__(self, a: Any) -> Dataclass: + def __mul__(self, a: Any) -> Self: """ Implement support for multiplication. @@ -396,7 +397,7 @@ def __mul__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "*") - def __imul__(self, a: Any) -> Dataclass: + def __imul__(self, a: Any) -> Self: """ Implement support for in-place multiplication. @@ -413,7 +414,7 @@ def __imul__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "*", True) - def __div__(self, a: Any) -> Dataclass: + def __div__(self, a: Any) -> Self: """ Implement support for division. @@ -430,7 +431,7 @@ def __div__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "/") - def __idiv__(self, a: Any) -> Dataclass: + def __idiv__(self, a: Any) -> Self: """ Implement support for in-place division. @@ -450,7 +451,7 @@ def __idiv__(self, a: Any) -> Dataclass: __itruediv__ = __idiv__ __truediv__ = __div__ - def __pow__(self, a: Any) -> Dataclass: + def __pow__(self, a: Any) -> Self: """ Implement support for exponentiation. @@ -467,7 +468,7 @@ def __pow__(self, a: Any) -> Dataclass: return self.arithmetical_operation(a, "**") - def __ipow__(self, a: Any) -> Dataclass: + def __ipow__(self, a: Any) -> Self: """ Implement support for in-place exponentiation. @@ -1052,7 +1053,7 @@ def __init__( self._scale = scale self._previous_scale = get_domain_range_scale() - def __enter__(self) -> domain_range_scale: + def __enter__(self) -> Self: """Set the new domain-range scale upon entering the context manager.""" set_domain_range_scale(self._scale) @@ -1825,7 +1826,7 @@ def __init__(self, enable: bool) -> None: self._enable = enable self._previous_state = is_ndarray_copy_enabled() - def __enter__(self) -> ndarray_copy_enable: + def __enter__(self) -> Self: """ Set the *Colour* :class:`numpy.ndarray` copy enabled state upon entering the context manager. diff --git a/colour/utilities/common.py b/colour/utilities/common.py index a2af44db0..5a5054b40 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -40,6 +40,7 @@ Iterable, Literal, Mapping, + Self, Sequence, TypeVar, ) @@ -149,7 +150,7 @@ def __init__(self, enable: bool) -> None: self._enable = enable self._previous_state = is_caching_enabled() - def __enter__(self) -> caching_enable: + def __enter__(self) -> Self: """ Set the *Colour* caching enabled state upon entering the context manager. @@ -500,7 +501,7 @@ class disable_multiprocessing: multiprocessing state. """ - def __enter__(self) -> disable_multiprocessing: + def __enter__(self) -> Self: """ Disable *Colour* multiprocessing state upon entering the context manager. diff --git a/colour/utilities/deprecation.py b/colour/utilities/deprecation.py index c1670831d..4fd243267 100644 --- a/colour/utilities/deprecation.py +++ b/colour/utilities/deprecation.py @@ -8,12 +8,12 @@ from __future__ import annotations import sys -from collections import namedtuple +from dataclasses import dataclass from importlib import import_module from operator import attrgetter from colour.hints import Any, ModuleType -from colour.utilities import attest, optional, usage_warning +from colour.utilities import MixinDataclassIterable, attest, optional, usage_warning __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" @@ -40,7 +40,8 @@ ] -class ObjectRenamed(namedtuple("ObjectRenamed", ("name", "new_name"))): +@dataclass(frozen=True) +class ObjectRenamed(MixinDataclassIterable): """ A class used for an object that has been renamed. @@ -52,6 +53,9 @@ class ObjectRenamed(namedtuple("ObjectRenamed", ("name", "new_name"))): Object new name. """ + name: str + new_name: str + def __str__(self) -> str: """ Return a formatted string representation of the class. @@ -65,7 +69,8 @@ def __str__(self) -> str: return f'"{self.name}" object has been renamed to "{self.new_name}".' -class ObjectRemoved(namedtuple("ObjectRemoved", ("name",))): +@dataclass(frozen=True) +class ObjectRemoved(MixinDataclassIterable): """ A class used for an object that has been removed. @@ -75,6 +80,8 @@ class ObjectRemoved(namedtuple("ObjectRemoved", ("name",))): Object name that has been removed. """ + name: str + def __str__(self) -> str: """ Return a formatted string representation of the class. @@ -88,7 +95,8 @@ def __str__(self) -> str: return f'"{self.name}" object has been removed from the API.' -class ObjectFutureRename(namedtuple("ObjectFutureRename", ("name", "new_name"))): +@dataclass(frozen=True) +class ObjectFutureRename(MixinDataclassIterable): """ A class used for future object name deprecation, i.e., object name will change in a future release. @@ -101,6 +109,9 @@ class ObjectFutureRename(namedtuple("ObjectFutureRename", ("name", "new_name"))) Object future release name. """ + name: str + new_name: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -117,7 +128,8 @@ def __str__(self) -> str: ) -class ObjectFutureRemove(namedtuple("ObjectFutureRemove", ("name",))): +@dataclass(frozen=True) +class ObjectFutureRemove(MixinDataclassIterable): """ A class used for future object removal. @@ -127,6 +139,8 @@ class ObjectFutureRemove(namedtuple("ObjectFutureRemove", ("name",))): Object name that will be removed in a future release. """ + name: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -143,9 +157,8 @@ def __str__(self) -> str: ) -class ObjectFutureAccessChange( - namedtuple("ObjectFutureAccessChange", ("access", "new_access")) -): +@dataclass(frozen=True) +class ObjectFutureAccessChange(MixinDataclassIterable): """ A class used for future object access deprecation, i.e., object access will change in a future release. @@ -158,6 +171,9 @@ class ObjectFutureAccessChange( Object future release access. """ + access: str + new_access: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -174,7 +190,8 @@ def __str__(self) -> str: ) -class ObjectFutureAccessRemove(namedtuple("ObjectFutureAccessRemove", ("name",))): +@dataclass(frozen=True) +class ObjectFutureAccessRemove(MixinDataclassIterable): """ A class used for future object access removal, i.e., object access will be removed in a future release. @@ -185,6 +202,8 @@ class ObjectFutureAccessRemove(namedtuple("ObjectFutureAccessRemove", ("name",)) Object name whose access will removed in a future release. """ + name: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -198,7 +217,8 @@ def __str__(self) -> str: return f'"{self.name}" object access will be removed in a future release.' -class ArgumentRenamed(namedtuple("ArgumentRenamed", ("name", "new_name"))): +@dataclass(frozen=True) +class ArgumentRenamed(MixinDataclassIterable): """ A class used for an argument that has been renamed. @@ -210,6 +230,9 @@ class ArgumentRenamed(namedtuple("ArgumentRenamed", ("name", "new_name"))): Argument new name. """ + name: str + new_name: str + def __str__(self) -> str: """ Return a formatted string representation of the class. @@ -223,7 +246,8 @@ def __str__(self) -> str: return f'"{self.name}" argument has been renamed to "{self.new_name}".' -class ArgumentRemoved(namedtuple("ArgumentRemoved", ("name",))): +@dataclass(frozen=True) +class ArgumentRemoved(MixinDataclassIterable): """ A class used for an argument that has been removed. @@ -233,6 +257,8 @@ class ArgumentRemoved(namedtuple("ArgumentRemoved", ("name",))): Argument name that has been removed. """ + name: str + def __str__(self) -> str: """ Return a formatted string representation of the class. @@ -246,7 +272,8 @@ def __str__(self) -> str: return f'"{self.name}" argument has been removed from the API.' -class ArgumentFutureRename(namedtuple("ArgumentFutureRename", ("name", "new_name"))): +@dataclass(frozen=True) +class ArgumentFutureRename(MixinDataclassIterable): """ A class used for future argument name deprecation, i.e., argument name will change in a future release. @@ -259,6 +286,9 @@ class ArgumentFutureRename(namedtuple("ArgumentFutureRename", ("name", "new_name Argument future release name. """ + name: str + new_name: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -275,7 +305,8 @@ def __str__(self) -> str: ) -class ArgumentFutureRemove(namedtuple("ArgumentFutureRemove", ("name",))): +@dataclass(frozen=True) +class ArgumentFutureRemove(MixinDataclassIterable): """ A class used for future argument removal. @@ -285,6 +316,8 @@ class ArgumentFutureRemove(namedtuple("ArgumentFutureRemove", ("name",))): Argument name that will be removed in a future release. """ + name: str + def __str__(self) -> str: """ Return a formatted string representation of the deprecation type. @@ -357,8 +390,9 @@ def __getattr__(self, attribute: str) -> Any: return ( getattr(self._module, attribute) if isinstance(change, ObjectFutureRemove) - else get_attribute(change[1]) + else get_attribute(change.values[1]) ) + raise AttributeError(str(change)) return getattr(self._module, attribute) @@ -554,7 +588,7 @@ def handle_arguments_deprecation(changes: dict, **kwargs: Any) -> dict: if isinstance(change, ArgumentFutureRemove): continue - kwargs[change[1]] = kwargs.pop(kwarg) + kwargs[change.values[1]] = kwargs.pop(kwarg) else: kwargs.pop(kwarg) usage_warning(str(change)) diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index a2226b6ad..278c4f210 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -508,7 +508,7 @@ def __len__(self) -> int: return len(self._data) - def __eq__(self, other: Any) -> bool: + def __eq__(self, other: object) -> bool: """ Return whether the delimiter and case-insensitive :class:`dict`-like object is equal to given other object. @@ -538,7 +538,7 @@ def __eq__(self, other: Any) -> bool: return self._data == other_mapping.data - def __ne__(self, other: Any) -> bool: + def __ne__(self, other: object) -> bool: """ Return whether the delimiter and case-insensitive :class:`dict`-like object is not equal to given other object. diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index 2fb8c5c49..480fe7a73 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -31,6 +31,7 @@ Literal, LiteralWarning, Mapping, + Self, TextIO, Type, cast, @@ -587,7 +588,7 @@ class suppress_stdout: Hello World! """ - def __enter__(self) -> suppress_stdout: + def __enter__(self) -> Self: """Redirect the standard output upon entering the context manager.""" self._stdout = sys.stdout diff --git a/pyproject.toml b/pyproject.toml index 8a2b13ecf..e426fce44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,6 +181,7 @@ select = [ "PL", # pylint # "PT", # flake8-pytest-style # "PTH", # flake8-use-pathlib [Enable] + "PYI", # flake8-pyi "Q", # flake8-quotes "RET", # flake8-return "RUF", # Ruff @@ -215,6 +216,9 @@ ignore = [ "PLR0913", # Too many arguments in function definition "PLR0915", # Too many statements "PLR2004", # Magic value used in comparison, consider replacing `.*` with a constant variable + "PYI036", # Star-args in `.*` should be annotated with `object` + "PYI051", # `Literal[".*"]` is redundant in a union with `str` + "PYI056", # Calling `.append()` on `__all__` may not be supported by all type checkers (use `+=` instead) "RUF022", # [*] `__all__` is not sorted "TRY003", # Avoid specifying long messages outside the exception class "UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)` From 027d3334b723cb1ce76c4049311a86d281ec6796 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 14:11:19 +1300 Subject: [PATCH 28/42] Enable `RSE` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index e426fce44..15da2dace 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -184,6 +184,7 @@ select = [ "PYI", # flake8-pyi "Q", # flake8-quotes "RET", # flake8-return + "RSE", # flake8-raise "RUF", # Ruff "S", # flake8-bandit "SIM", # flake8-simplify From 82c1bf1bbe1a174308910b26591388de161b9aee Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 14:20:04 +1300 Subject: [PATCH 29/42] Enable `SLF` checks. --- colour/colorimetry/spectrum.py | 2 +- colour/continuous/tests/test_signal.py | 2 +- colour/models/rgb/rgb_colourspace.py | 6 +++--- colour/recovery/otsu2018.py | 12 ++++++------ colour/utilities/common.py | 6 +++--- colour/utilities/network.py | 12 ++++++------ pyproject.toml | 1 + 7 files changed, 21 insertions(+), 20 deletions(-) diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 5dbd446fc..93a0527e5 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -713,7 +713,7 @@ def _on_domain_changed( """Invalidate *sd._shape* when *sd._domain* is changed.""" if name == "_domain": - sd._shape = None + sd._shape = None # noqa: SLF001 return value diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index f660260d0..7043d3429 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -658,7 +658,7 @@ def test_arithmetical_operation(self) -> None: np.testing.assert_allclose( signal.arithmetical_operation(signal, "+", False).range, - signal.range + signal._range, + signal.range + signal.range, atol=TOLERANCE_ABSOLUTE_TESTS, ) diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 38c54f21f..0b0763550 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -898,9 +898,9 @@ def chromatically_adapt( colourspace.whitepoint = whitepoint colourspace.whitepoint_name = whitepoint_name - colourspace._matrix_RGB_to_XYZ = None - colourspace._matrix_XYZ_to_RGB = None - colourspace._derive_transformation_matrices() + colourspace._matrix_RGB_to_XYZ = None # noqa: SLF001 + colourspace._matrix_XYZ_to_RGB = None # noqa: SLF001 + colourspace._derive_transformation_matrices() # noqa: SLF001 colourspace.use_derived_transformation_matrices() colourspace.name = ( diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index dac5f8235..fe5f49aed 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -853,14 +853,14 @@ def partition(self, axis: PartitionAxis) -> Tuple[Data_Otsu2018, Data_Otsu2018]: ): mask = self._xy[:, axis.direction] <= axis.origin - lesser._reflectances = self._reflectances[mask, :] - greater._reflectances = self._reflectances[~mask, :] + lesser._reflectances = self._reflectances[mask, :] # noqa: SLF001 + greater._reflectances = self._reflectances[~mask, :] # noqa: SLF001 - lesser._XYZ = self._XYZ[mask, :] - greater._XYZ = self._XYZ[~mask, :] + lesser._XYZ = self._XYZ[mask, :] # noqa: SLF001 + greater._XYZ = self._XYZ[~mask, :] # noqa: SLF001 - lesser._xy = self._xy[mask, :] - greater._xy = self._xy[~mask, :] + lesser._xy = self._xy[mask, :] # noqa: SLF001 + greater._xy = self._xy[~mask, :] # noqa: SLF001 return lesser, greater diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 5a5054b40..307e748dc 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -554,16 +554,16 @@ def _initializer(kwargs: Any) -> None: import colour.utilities.array # pragma: no cover - colour.utilities.array._DOMAIN_RANGE_SCALE = kwargs.get( + colour.utilities.array._DOMAIN_RANGE_SCALE = kwargs.get( # noqa: SLF001 "scale", "reference" ) # pragma: no cover import colour.algebra.common # pragma: no cover - colour.algebra.common._SDIV_MODE = kwargs.get( + colour.algebra.common._SDIV_MODE = kwargs.get( # noqa: SLF001 "sdiv_mode", "Ignore Zero Conversion" ) # pragma: no cover - colour.algebra.common._SPOW_ENABLED = kwargs.get( + colour.algebra.common._SPOW_ENABLED = kwargs.get( # noqa: SLF001 "spow_enabled", True ) # pragma: no cover diff --git a/colour/utilities/network.py b/colour/utilities/network.py index b00f1789b..c6a42d2dc 100644 --- a/colour/utilities/network.py +++ b/colour/utilities/network.py @@ -143,7 +143,7 @@ def __new__(cls, *args: Any, **kwargs: Any) -> Self: # noqa: ARG003 instance = super().__new__(cls) - instance._id = TreeNode._INSTANCE_ID # pyright: ignore + instance._id = TreeNode._INSTANCE_ID # pyright: ignore # noqa: SLF001 TreeNode._INSTANCE_ID += 1 return instance @@ -644,7 +644,7 @@ def value(self) -> Any: # port is valid as they should all carry the same value, thus the first # connected port is returned. for connection in self._connections: - return connection._value + return connection._value # noqa: SLF001 return self._value @@ -662,7 +662,7 @@ def value(self, value: Any) -> None: # should be also set to the same given value. for direct_connection in self._connections: self.log(f'Setting "{direct_connection.node}" value to {value}.', "debug") - direct_connection._value = value + direct_connection._value = value # noqa: SLF001 if direct_connection.node is not None: self.log(f'Dirtying "{direct_connection.node}".', "debug") @@ -675,7 +675,7 @@ def value(self, value: Any) -> None: self.log( f'Setting "{indirect_connection.node}" value to {value}.', "debug" ) - indirect_connection._value = value + indirect_connection._value = value # noqa: SLF001 if indirect_connection.node is not None: self.log(f'Dirtying "{indirect_connection.node}".', "debug") @@ -1680,7 +1680,7 @@ def add_node(self, node: PortNode) -> None: self._nodes[node.name] = node self._children.append(node) # pyright: ignore - node._parent = self + node._parent = self # noqa: SLF001 def remove_node(self, node: PortNode) -> None: """ @@ -1734,7 +1734,7 @@ def remove_node(self, node: PortNode) -> None: self._nodes.pop(node.name) self._children.remove(node) # pyright: ignore - node._parent = None + node._parent = None # noqa: SLF001 @required("NetworkX") def walk_ports(self) -> Generator: diff --git a/pyproject.toml b/pyproject.toml index 15da2dace..d10fa6344 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -187,6 +187,7 @@ select = [ "RSE", # flake8-raise "RUF", # Ruff "S", # flake8-bandit + "SLF", # flake8-self "SIM", # flake8-simplify "T10", # flake8-debugger "T20", # flake8-print From c023a2c64bbf0de99b8ae4f03dce4a384a2ec53e Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 14:21:54 +1300 Subject: [PATCH 30/42] Enable `SLOT` checks. --- colour/utilities/documentation.py | 4 ++-- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/colour/utilities/documentation.py b/colour/utilities/documentation.py index 3ded90fa4..d5a9b01f9 100644 --- a/colour/utilities/documentation.py +++ b/colour/utilities/documentation.py @@ -47,14 +47,14 @@ class DocstringInt(int): """ -class DocstringText(str): +class DocstringText(str): # noqa: SLOT000 """ A :class:`str` sub-class that allows settings a docstring to :class:`str` instances. """ -class DocstringTuple(tuple): +class DocstringTuple(tuple): # noqa: SLOT001 """ A :class:`tuple` sub-class that allows settings a docstring to :class:`tuple` instances. diff --git a/pyproject.toml b/pyproject.toml index d10fa6344..4f893f1cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -188,6 +188,7 @@ select = [ "RUF", # Ruff "S", # flake8-bandit "SLF", # flake8-self + "SLOT", # flake8-slots "SIM", # flake8-simplify "T10", # flake8-debugger "T20", # flake8-print From 6966df6a5906a99cf291498892b3423fb7aabac6 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:22:58 +1300 Subject: [PATCH 31/42] Enable `TC` checks. --- .coveragerc | 1 + colour/adaptation/__init__.py | 6 ++- colour/adaptation/cie1994.py | 7 ++- colour/adaptation/cmccat2000.py | 6 ++- colour/adaptation/datasets/cat.py | 6 ++- colour/adaptation/fairchild1990.py | 7 ++- colour/adaptation/fairchild2020.py | 6 ++- colour/adaptation/vonkries.py | 15 ++++--- colour/adaptation/zhai2018.py | 7 ++- colour/algebra/__init__.py | 7 ++- colour/algebra/common.py | 22 +++++----- colour/algebra/coordinates/transformations.py | 7 ++- colour/algebra/extrapolation.py | 25 ++++++----- colour/algebra/interpolation.py | 25 ++++++----- colour/algebra/prng.py | 6 ++- colour/algebra/regression.py | 5 ++- colour/algebra/tests/test_prng.py | 6 ++- colour/appearance/atd95.py | 6 ++- colour/appearance/cam16.py | 6 ++- colour/appearance/ciecam02.py | 7 ++- colour/appearance/ciecam16.py | 6 ++- colour/appearance/hellwig2022.py | 6 ++- colour/appearance/hke.py | 7 ++- colour/appearance/hunt.py | 7 ++- colour/appearance/kim2009.py | 6 ++- colour/appearance/llab.py | 6 ++- colour/appearance/nayatani95.py | 7 ++- colour/appearance/rlab.py | 6 ++- colour/appearance/zcam.py | 6 ++- colour/biochemistry/michaelis_menten.py | 6 ++- colour/blindness/machado2009.py | 12 +++++- colour/characterisation/aces_it.py | 24 ++++++----- colour/characterisation/cameras.py | 21 +++++---- colour/characterisation/correction.py | 7 ++- .../chromaticity_coordinates.py | 6 ++- colour/characterisation/displays.py | 21 +++++---- .../characterisation/tests/test_correction.py | 6 ++- colour/colorimetry/blackbody.py | 7 ++- colour/colorimetry/cmfs.py | 21 +++++---- colour/colorimetry/correction.py | 8 +++- .../datasets/illuminants/hunterlab.py | 5 ++- colour/colorimetry/dominant.py | 7 ++- colour/colorimetry/generation.py | 19 +++++--- colour/colorimetry/illuminants.py | 7 ++- colour/colorimetry/lefs.py | 7 ++- colour/colorimetry/lightness.py | 7 ++- colour/colorimetry/luminance.py | 7 ++- colour/colorimetry/spectrum.py | 40 +++++++++-------- colour/colorimetry/tests/test_blackbody.py | 6 ++- colour/colorimetry/tests/test_illuminants.py | 7 ++- .../tests/test_tristimulus_values.py | 7 ++- colour/colorimetry/tests/test_uniformity.py | 6 ++- colour/colorimetry/transformations.py | 7 ++- colour/colorimetry/tristimulus_values.py | 22 ++++++---- colour/colorimetry/uniformity.py | 9 +++- colour/colorimetry/whiteness.py | 5 ++- colour/colorimetry/yellowness.py | 7 ++- colour/continuous/abstract.py | 29 +++++++------ colour/continuous/multi_signals.py | 39 +++++++++-------- colour/continuous/signal.py | 33 +++++++------- colour/contrast/__init__.py | 6 ++- colour/contrast/barten1999.py | 6 ++- colour/corresponding/datasets/breneman1987.py | 5 ++- colour/corresponding/prediction.py | 20 +++++---- colour/corresponding/tests/test_prediction.py | 6 ++- colour/difference/__init__.py | 6 ++- colour/difference/cam02_ucs.py | 6 ++- colour/difference/delta_e.py | 6 ++- colour/difference/din99.py | 7 ++- colour/difference/huang2015.py | 6 ++- colour/difference/stress.py | 7 ++- colour/geometry/ellipse.py | 7 ++- colour/geometry/intersection.py | 6 ++- colour/geometry/primitives.py | 21 ++++++--- colour/geometry/section.py | 10 ++++- colour/geometry/vertices.py | 7 ++- colour/graph/conversion.py | 16 ++++--- colour/hints/__init__.py | 5 +-- colour/io/__init__.py | 1 + colour/io/ctl.py | 15 ++++--- colour/io/fichet2021.py | 14 ++++-- colour/io/image.py | 28 ++++++------ colour/io/luts/__init__.py | 10 ++++- colour/io/luts/cinespace_csp.py | 9 +++- colour/io/luts/common.py | 5 ++- colour/io/luts/iridas_cube.py | 5 ++- colour/io/luts/lut.py | 20 ++++++--- colour/io/luts/operator.py | 18 +++++--- colour/io/luts/resolve_cube.py | 5 ++- colour/io/luts/sequence.py | 15 ++++--- colour/io/luts/sony_spi1d.py | 5 ++- colour/io/luts/sony_spi3d.py | 5 ++- colour/io/luts/sony_spimtx.py | 5 ++- colour/io/luts/tests/test_lut.py | 18 +++++--- colour/io/luts/tests/test_sequence.py | 6 ++- colour/io/ocio.py | 6 ++- colour/io/tabular.py | 9 +++- colour/io/tests/test_tm2714.py | 7 ++- colour/io/tests/test_uprtek_sekonic.py | 6 ++- colour/io/tm2714.py | 6 ++- colour/io/uprtek_sekonic.py | 10 ++++- colour/io/xrite.py | 9 +++- colour/models/cam02_ucs.py | 7 ++- colour/models/cam16_ucs.py | 6 ++- colour/models/cie_lab.py | 7 ++- colour/models/cie_luv.py | 7 ++- colour/models/cie_ucs.py | 7 ++- colour/models/cie_uvw.py | 7 ++- colour/models/cie_xyy.py | 7 ++- colour/models/common.py | 7 ++- colour/models/datasets/macadam_ellipses.py | 5 ++- colour/models/datasets/pointer_gamut.py | 6 ++- colour/models/din99.py | 7 ++- colour/models/hdr_cie_lab.py | 7 ++- colour/models/hdr_ipt.py | 7 ++- colour/models/hunter_lab.py | 7 ++- colour/models/hunter_rdab.py | 7 ++- colour/models/icacb.py | 6 ++- colour/models/igpgtg.py | 8 +++- colour/models/ipt.py | 6 ++- colour/models/jzazbz.py | 7 ++- colour/models/oklab.py | 6 ++- colour/models/osa_ucs.py | 7 ++- colour/models/prolab.py | 7 ++- colour/models/ragoo2021.py | 6 ++- colour/models/rgb/cmyk.py | 6 ++- colour/models/rgb/common.py | 15 ++++--- colour/models/rgb/cylindrical.py | 8 +++- colour/models/rgb/datasets/aces.py | 7 ++- colour/models/rgb/datasets/adobe_rgb_1998.py | 6 ++- .../rgb/datasets/adobe_wide_gamut_rgb.py | 6 ++- colour/models/rgb/datasets/apple_rgb.py | 6 ++- colour/models/rgb/datasets/arri.py | 7 ++- colour/models/rgb/datasets/best_rgb.py | 6 ++- colour/models/rgb/datasets/beta_rgb.py | 6 ++- .../models/rgb/datasets/blackmagic_design.py | 7 ++- .../models/rgb/datasets/canon_cinema_gamut.py | 7 ++- colour/models/rgb/datasets/cie_rgb.py | 6 ++- colour/models/rgb/datasets/color_match_rgb.py | 6 ++- .../models/rgb/datasets/davinci_wide_gamut.py | 7 ++- colour/models/rgb/datasets/dcdm_xyz.py | 7 ++- colour/models/rgb/datasets/dci_p3.py | 6 ++- colour/models/rgb/datasets/display_p3.py | 7 ++- colour/models/rgb/datasets/dji_d_gamut.py | 7 ++- colour/models/rgb/datasets/don_rgb_4.py | 6 ++- colour/models/rgb/datasets/ebu_3213_e.py | 6 ++- colour/models/rgb/datasets/eci_rgb_v2.py | 14 +++--- colour/models/rgb/datasets/ekta_space_ps5.py | 6 ++- .../models/rgb/datasets/filmlight_e_gamut.py | 7 ++- colour/models/rgb/datasets/fujifilm.py | 7 ++- colour/models/rgb/datasets/gopro.py | 7 ++- colour/models/rgb/datasets/itur_bt_2020.py | 7 ++- colour/models/rgb/datasets/itur_bt_470.py | 6 ++- colour/models/rgb/datasets/itur_bt_709.py | 7 ++- colour/models/rgb/datasets/itut_h_273.py | 6 ++- colour/models/rgb/datasets/max_rgb.py | 6 ++- colour/models/rgb/datasets/nikon_n_gamut.py | 6 ++- colour/models/rgb/datasets/ntsc.py | 6 ++- colour/models/rgb/datasets/p3_d65.py | 6 ++- colour/models/rgb/datasets/pal_secam.py | 6 ++- .../models/rgb/datasets/panasonic_v_gamut.py | 7 ++- colour/models/rgb/datasets/plasa_ansi_e154.py | 7 ++- colour/models/rgb/datasets/red.py | 7 ++- colour/models/rgb/datasets/rimm_romm_rgb.py | 7 ++- colour/models/rgb/datasets/russell_rgb.py | 6 ++- colour/models/rgb/datasets/sharp.py | 7 ++- colour/models/rgb/datasets/smpte_240m.py | 7 ++- colour/models/rgb/datasets/smpte_c.py | 6 ++- colour/models/rgb/datasets/sony.py | 7 ++- colour/models/rgb/datasets/srgb.py | 7 ++- colour/models/rgb/datasets/xtreme_rgb.py | 6 ++- colour/models/rgb/derivation.py | 17 +++++--- colour/models/rgb/hanbury2003.py | 7 ++- colour/models/rgb/ictcp.py | 17 +++++--- colour/models/rgb/itut_h_273.py | 7 ++- colour/models/rgb/prismatic.py | 7 ++- colour/models/rgb/rgb_colourspace.py | 18 +++++--- .../models/rgb/transfer_functions/__init__.py | 36 +++++++++------- colour/models/rgb/transfer_functions/aces.py | 6 ++- .../transfer_functions/apple_log_profile.py | 6 ++- .../rgb/transfer_functions/arib_std_b67.py | 6 ++- colour/models/rgb/transfer_functions/arri.py | 6 ++- .../transfer_functions/blackmagic_design.py | 6 ++- colour/models/rgb/transfer_functions/canon.py | 6 ++- .../models/rgb/transfer_functions/cineon.py | 6 ++- .../models/rgb/transfer_functions/common.py | 6 ++- .../davinci_intermediate.py | 6 ++- colour/models/rgb/transfer_functions/dcdm.py | 7 ++- .../rgb/transfer_functions/dicom_gsdf.py | 6 ++- .../rgb/transfer_functions/dji_d_log.py | 6 ++- .../models/rgb/transfer_functions/exponent.py | 7 ++- .../rgb/transfer_functions/filmic_pro.py | 7 ++- .../rgb/transfer_functions/filmlight_t_log.py | 6 ++- .../rgb/transfer_functions/fujifilm_f_log.py | 6 ++- colour/models/rgb/transfer_functions/gamma.py | 7 ++- colour/models/rgb/transfer_functions/gopro.py | 6 ++- .../rgb/transfer_functions/itur_bt_1361.py | 7 ++- .../rgb/transfer_functions/itur_bt_1886.py | 7 ++- .../rgb/transfer_functions/itur_bt_2020.py | 7 ++- .../rgb/transfer_functions/itur_bt_2100.py | 7 ++- .../rgb/transfer_functions/itur_bt_601.py | 7 ++- .../rgb/transfer_functions/itur_bt_709.py | 6 ++- .../rgb/transfer_functions/itut_h_273.py | 7 ++- .../rgb/transfer_functions/leica_l_log.py | 7 ++- .../models/rgb/transfer_functions/linear.py | 6 ++- colour/models/rgb/transfer_functions/log.py | 13 ++++-- .../rgb/transfer_functions/nikon_n_log.py | 7 ++- .../models/rgb/transfer_functions/panalog.py | 6 ++- .../rgb/transfer_functions/panasonic_v_log.py | 6 ++- .../rgb/transfer_functions/pivoted_log.py | 6 ++- colour/models/rgb/transfer_functions/red.py | 6 ++- .../rgb/transfer_functions/rimm_romm_rgb.py | 7 ++- .../rgb/transfer_functions/smpte_240m.py | 7 ++- colour/models/rgb/transfer_functions/sony.py | 12 ++++-- colour/models/rgb/transfer_functions/srgb.py | 7 ++- .../models/rgb/transfer_functions/st_2084.py | 7 ++- .../rgb/transfer_functions/viper_log.py | 6 ++- colour/models/rgb/ycbcr.py | 7 ++- colour/models/rgb/ycocg.py | 6 ++- colour/models/yrg.py | 7 ++- colour/notation/css_color_3.py | 6 ++- colour/notation/hexadecimal.py | 7 ++- colour/notation/munsell.py | 16 ++++--- colour/notation/tests/test_munsell.py | 6 ++- colour/phenomena/rayleigh.py | 7 ++- colour/plotting/blindness.py | 24 +++++++---- colour/plotting/characterisation.py | 14 ++++-- colour/plotting/colorimetry.py | 27 ++++++++---- colour/plotting/common.py | 41 +++++++++++------- colour/plotting/corresponding.py | 13 ++++-- colour/plotting/diagrams.py | 36 +++++++++++----- colour/plotting/graph.py | 7 ++- colour/plotting/models.py | 33 ++++++++------ colour/plotting/notation.py | 12 ++++-- colour/plotting/phenomena.py | 14 ++++-- colour/plotting/quality.py | 27 ++++++++---- colour/plotting/section.py | 33 +++++++++----- colour/plotting/temperature.py | 36 ++++++++++------ colour/plotting/tm3018/components.py | 15 +++++-- colour/plotting/tm3018/report.py | 14 ++++-- colour/plotting/volume.py | 19 +++++--- colour/quality/__init__.py | 7 ++- colour/quality/cfi2017.py | 7 ++- colour/quality/cqs.py | 16 ++++--- colour/quality/cri.py | 7 ++- colour/quality/ssi.py | 7 ++- colour/quality/tm3018.py | 8 +++- colour/recovery/__init__.py | 8 +++- colour/recovery/datasets/dyer2017.py | 6 ++- colour/recovery/datasets/mallett2019.py | 6 ++- colour/recovery/datasets/otsu2018.py | 6 ++- colour/recovery/jakob2019.py | 21 ++++++--- colour/recovery/jiang2013.py | 15 +++++-- colour/recovery/mallett2019.py | 9 +++- colour/recovery/meng2015.py | 8 +++- colour/recovery/otsu2018.py | 29 +++++++------ colour/recovery/smits1999.py | 7 ++- colour/recovery/tests/test_jakob2019.py | 6 ++- colour/temperature/__init__.py | 6 ++- colour/temperature/cie_d.py | 7 ++- colour/temperature/hernandez1999.py | 7 ++- colour/temperature/kang2002.py | 6 ++- colour/temperature/krystek1985.py | 6 ++- colour/temperature/mccamy1992.py | 7 ++- colour/temperature/ohno2013.py | 7 ++- colour/temperature/planck1900.py | 7 ++- colour/temperature/robertson1968.py | 6 ++- colour/utilities/__init__.py | 5 ++- colour/utilities/array.py | 43 ++++++++++--------- colour/utilities/callback.py | 8 ++-- colour/utilities/common.py | 31 +++++++------ colour/utilities/deprecation.py | 5 ++- colour/utilities/metrics.py | 17 +++++--- colour/utilities/network.py | 23 +++++----- colour/utilities/requirements.py | 13 +++--- colour/utilities/structures.py | 14 +++--- colour/utilities/tests/test_array.py | 6 ++- colour/utilities/tests/test_common.py | 5 ++- colour/utilities/tests/test_deprecated.py | 5 ++- colour/utilities/tests/test_network.py | 5 ++- colour/utilities/verbose.py | 32 +++++++------- .../volume/datasets/optimal_colour_stimuli.py | 6 ++- colour/volume/macadam_limits.py | 7 ++- colour/volume/mesh.py | 6 ++- colour/volume/pointer_gamut.py | 7 ++- colour/volume/rgb.py | 16 ++++--- colour/volume/spectrum.py | 17 +++++--- docs/colour.hints.rst | 1 - pyproject.toml | 2 +- tasks.py | 5 ++- 290 files changed, 2072 insertions(+), 753 deletions(-) diff --git a/.coveragerc b/.coveragerc index 6ca076643..4c1cdb61d 100644 --- a/.coveragerc +++ b/.coveragerc @@ -6,4 +6,5 @@ sigterm = True exclude_lines = pragma: no cover if __name__ == .__main__.: + if TYPE_CHECKING: pass diff --git a/colour/adaptation/__init__.py b/colour/adaptation/__init__.py index 2947d9ce0..f56fab191 100644 --- a/colour/adaptation/__init__.py +++ b/colour/adaptation/__init__.py @@ -31,7 +31,11 @@ from __future__ import annotations -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/adaptation/cie1994.py b/colour/adaptation/cie1994.py index 3129efe15..0cfcbe769 100644 --- a/colour/adaptation/cie1994.py +++ b/colour/adaptation/cie1994.py @@ -16,11 +16,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.adaptation import CAT_VON_KRIES from colour.algebra import sdiv, sdiv_mode, spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float_array, from_range_100, diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index 6fa4e8859..3831a3028 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -22,13 +22,17 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.adaptation import CAT_CMCCAT2000 from colour.algebra import vecmul -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassIterable, diff --git a/colour/adaptation/datasets/cat.py b/colour/adaptation/datasets/cat.py index ad7f4306b..223a638b0 100644 --- a/colour/adaptation/datasets/cat.py +++ b/colour/adaptation/datasets/cat.py @@ -73,9 +73,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import CanonicalMapping __author__ = "Colour Developers" diff --git a/colour/adaptation/fairchild1990.py b/colour/adaptation/fairchild1990.py index 249a10708..ff7b9717b 100644 --- a/colour/adaptation/fairchild1990.py +++ b/colour/adaptation/fairchild1990.py @@ -17,11 +17,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.adaptation import CAT_VON_KRIES from colour.algebra import sdiv, sdiv_mode, spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float_array, from_range_100, diff --git a/colour/adaptation/fairchild2020.py b/colour/adaptation/fairchild2020.py index b1d2c978c..0106382f1 100644 --- a/colour/adaptation/fairchild2020.py +++ b/colour/adaptation/fairchild2020.py @@ -17,13 +17,17 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS from colour.algebra import sdiv, sdiv_mode, vecmul -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassIterable, diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index 6e02c7dea..9564e40e1 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -16,15 +16,20 @@ from __future__ import annotations +import typing + import numpy as np from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS from colour.algebra import sdiv, sdiv_mode, vecmul -from colour.hints import ( - ArrayLike, - LiteralChromaticAdaptationTransform, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + ) + from colour.utilities import ( as_float_array, from_range_1, diff --git a/colour/adaptation/zhai2018.py b/colour/adaptation/zhai2018.py index 05d767465..fac8393f0 100644 --- a/colour/adaptation/zhai2018.py +++ b/colour/adaptation/zhai2018.py @@ -15,11 +15,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS from colour.algebra import vecmul -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( as_float_array, from_range_100, diff --git a/colour/algebra/__init__.py b/colour/algebra/__init__.py index 06b9b3408..054110909 100644 --- a/colour/algebra/__init__.py +++ b/colour/algebra/__init__.py @@ -1,11 +1,16 @@ # isort: skip_file +from __future__ import annotations + import sys from colour.utilities.deprecation import ModuleAPI, build_API_changes from colour.utilities.documentation import is_documentation_building -from colour.hints import Any +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any from .common import ( get_sdiv_mode, diff --git a/colour/algebra/common.py b/colour/algebra/common.py index fa80d4204..b98120b9b 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -9,19 +9,21 @@ from __future__ import annotations import functools +import typing import numpy as np -from colour.hints import ( - Any, - ArrayLike, - Callable, - Literal, - NDArrayFloat, - Self, - Tuple, - cast, -) +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + NDArrayFloat, + Self, + Tuple, + ) + +from colour.hints import Literal, cast from colour.utilities import ( as_float, as_float_array, diff --git a/colour/algebra/coordinates/transformations.py b/colour/algebra/coordinates/transformations.py index 946a03809..a0bdb38c1 100644 --- a/colour/algebra/coordinates/transformations.py +++ b/colour/algebra/coordinates/transformations.py @@ -30,10 +30,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float_array, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/algebra/extrapolation.py b/colour/algebra/extrapolation.py index 074d72e88..03f7e6432 100644 --- a/colour/algebra/extrapolation.py +++ b/colour/algebra/extrapolation.py @@ -18,20 +18,25 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import NullInterpolator, sdiv, sdiv_mode from colour.constants import DTYPE_FLOAT_DEFAULT -from colour.hints import ( - Any, - ArrayLike, - DTypeReal, - Literal, - NDArrayFloat, - ProtocolInterpolator, - Real, - Type, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + DTypeReal, + Literal, + NDArrayFloat, + ProtocolInterpolator, + Real, + Type, + ) + from colour.utilities import ( as_float, as_float_array, diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index d9408e0d3..40338eaea 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -60,6 +60,7 @@ from __future__ import annotations import itertools +import typing from collections.abc import Mapping from functools import reduce @@ -72,17 +73,19 @@ TOLERANCE_ABSOLUTE_DEFAULT, TOLERANCE_RELATIVE_DEFAULT, ) -from colour.hints import ( - Any, - ArrayLike, - Callable, - DTypeReal, - Literal, - NDArrayFloat, - Tuple, - Type, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + DTypeReal, + Literal, + Tuple, + Type, + ) + +from colour.hints import NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, as_array, diff --git a/colour/algebra/prng.py b/colour/algebra/prng.py index bbbc23eac..950bb933e 100644 --- a/colour/algebra/prng.py +++ b/colour/algebra/prng.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float_array, tstack __author__ = "Colour Developers" diff --git a/colour/algebra/regression.py b/colour/algebra/regression.py index 206482865..30c08ac12 100644 --- a/colour/algebra/regression.py +++ b/colour/algebra/regression.py @@ -17,9 +17,12 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/algebra/tests/test_prng.py b/colour/algebra/tests/test_prng.py index 86e98dbec..103c44f1c 100644 --- a/colour/algebra/tests/test_prng.py +++ b/colour/algebra/tests/test_prng.py @@ -12,11 +12,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import random_triplet_generator from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/atd95.py b/colour/appearance/atd95.py index d3a5b79cc..2d1d32cda 100644 --- a/colour/appearance/atd95.py +++ b/colour/appearance/atd95.py @@ -26,12 +26,16 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np from colour.algebra import spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( MixinDataclassArithmetic, as_float, diff --git a/colour/appearance/cam16.py b/colour/appearance/cam16.py index 31fb8901c..331c6ab13 100644 --- a/colour/appearance/cam16.py +++ b/colour/appearance/cam16.py @@ -20,6 +20,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -49,7 +50,10 @@ temporary_magnitude_quantity_inverse, viewing_conditions_dependent_parameters, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 60e1bf3b2..65877cdee 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -32,6 +32,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -45,7 +46,11 @@ ) from colour.colorimetry import CCS_ILLUMINANTS from colour.constants import EPSILON -from colour.hints import ArrayLike, NDArrayFloat, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Tuple + +from colour.hints import NDArrayFloat, cast from colour.models import xy_to_XYZ from colour.utilities import ( CanonicalMapping, diff --git a/colour/appearance/ciecam16.py b/colour/appearance/ciecam16.py index 4e7ae3035..b3ab2e190 100644 --- a/colour/appearance/ciecam16.py +++ b/colour/appearance/ciecam16.py @@ -20,6 +20,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -48,7 +49,10 @@ temporary_magnitude_quantity_inverse, viewing_conditions_dependent_parameters, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/hellwig2022.py b/colour/appearance/hellwig2022.py index 519162a1b..c8f46c234 100644 --- a/colour/appearance/hellwig2022.py +++ b/colour/appearance/hellwig2022.py @@ -24,6 +24,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -48,7 +49,10 @@ post_adaptation_non_linear_response_compression_inverse, ) from colour.appearance.hunt import luminance_level_adaptation_factor -from colour.hints import ArrayLike, NDArrayFloat, Tuple + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, Tuple + from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/hke.py b/colour/appearance/hke.py index c811d7a51..20e0db884 100644 --- a/colour/appearance/hke.py +++ b/colour/appearance/hke.py @@ -25,10 +25,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float_array, diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index 336d9a0cb..fe6f52797 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -19,12 +19,17 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np from colour.algebra import spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike + +from colour.hints import NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/kim2009.py b/colour/appearance/kim2009.py index ca5ab4341..1b7e1cc71 100644 --- a/colour/appearance/kim2009.py +++ b/colour/appearance/kim2009.py @@ -21,6 +21,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -37,7 +38,10 @@ hue_quadrature, rgb_to_RGB, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index c70aa8a2f..6a8d26822 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -27,6 +27,7 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np @@ -38,7 +39,10 @@ spow, vecmul, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassArithmetic, diff --git a/colour/appearance/nayatani95.py b/colour/appearance/nayatani95.py index ef9e3fa5f..d7da4e321 100644 --- a/colour/appearance/nayatani95.py +++ b/colour/appearance/nayatani95.py @@ -20,6 +20,7 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np @@ -31,7 +32,11 @@ intermediate_values, ) from colour.algebra import spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike + +from colour.hints import NDArrayFloat, cast from colour.models import XYZ_to_xy from colour.utilities import ( MixinDataclassArithmetic, diff --git a/colour/appearance/rlab.py b/colour/appearance/rlab.py index 9708f2a13..2b145ac65 100644 --- a/colour/appearance/rlab.py +++ b/colour/appearance/rlab.py @@ -20,13 +20,17 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np from colour.algebra import sdiv, sdiv_mode, spow, vecmul from colour.appearance.hunt import MATRIX_XYZ_TO_HPE, XYZ_to_rgb -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( CanonicalMapping, MixinDataclassArray, diff --git a/colour/appearance/zcam.py b/colour/appearance/zcam.py index 739679938..93e3d7ab0 100644 --- a/colour/appearance/zcam.py +++ b/colour/appearance/zcam.py @@ -26,6 +26,7 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np @@ -38,7 +39,10 @@ hue_angle, ) from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Izazbz_to_XYZ, XYZ_to_Izazbz, xy_to_XYZ from colour.utilities import ( CanonicalMapping, diff --git a/colour/biochemistry/michaelis_menten.py b/colour/biochemistry/michaelis_menten.py index def5af287..5caf40a19 100644 --- a/colour/biochemistry/michaelis_menten.py +++ b/colour/biochemistry/michaelis_menten.py @@ -27,7 +27,11 @@ from __future__ import annotations -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index 53cc158fb..3cee070e1 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -28,17 +28,25 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul from colour.blindness import CVD_MATRICES_MACHADO2010 -from colour.characterisation import RGB_DisplayPrimaries + +if typing.TYPE_CHECKING: + from colour.characterisation import RGB_DisplayPrimaries + from colour.colorimetry import ( LMS_ConeFundamentals, SpectralShape, reshape_msds, ) -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( as_float_array, as_int_scalar, diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 298f5ab7b..dfae9928f 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -56,6 +56,7 @@ from __future__ import annotations import os +import typing import numpy as np from scipy.optimize import minimize @@ -83,16 +84,19 @@ sd_to_XYZ, sds_and_msds_to_msds, ) -from colour.hints import ( - Any, - ArrayLike, - Callable, - LiteralChromaticAdaptationTransform, - Mapping, - NDArrayFloat, - Tuple, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + LiteralChromaticAdaptationTransform, + Mapping, + NDArrayFloat, + Tuple, + ) + +from colour.hints import cast from colour.io import read_sds_from_csv_file from colour.models import ( XYZ_to_Jzazbz, diff --git a/colour/characterisation/cameras.py b/colour/characterisation/cameras.py index caca3d008..675d3ce9d 100644 --- a/colour/characterisation/cameras.py +++ b/colour/characterisation/cameras.py @@ -11,23 +11,26 @@ from __future__ import annotations -from collections.abc import KeysView, ValuesView +import typing from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, SpectralShape, ) -from colour.continuous import MultiSignals, Signal -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - Sequence, -) + +if typing.TYPE_CHECKING: + from collections.abc import KeysView, ValuesView + from colour.continuous import MultiSignals, Signal + from colour.hints import ( + Any, + ArrayLike, + Sequence, + ) + from colour.utilities import is_pandas_installed -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import DataFrame, Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/characterisation/correction.py b/colour/characterisation/correction.py index 6745b2ce9..f9f1b2c71 100644 --- a/colour/characterisation/correction.py +++ b/colour/characterisation/correction.py @@ -68,10 +68,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import least_square_mapping_MoorePenrose, spow -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py index 693e8198f..3377f710e 100644 --- a/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py +++ b/colour/characterisation/datasets/colour_checkers/chromaticity_coordinates.py @@ -56,12 +56,16 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models import Lab_to_XYZ, XYZ_to_xyY from colour.utilities import CanonicalMapping diff --git a/colour/characterisation/displays.py b/colour/characterisation/displays.py index 6d6079728..3b31a5e0b 100644 --- a/colour/characterisation/displays.py +++ b/colour/characterisation/displays.py @@ -12,23 +12,26 @@ from __future__ import annotations -from collections.abc import KeysView, ValuesView +import typing from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, SpectralShape, ) -from colour.continuous import MultiSignals, Signal -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - Sequence, -) + +if typing.TYPE_CHECKING: + from collections.abc import KeysView, ValuesView + from colour.continuous import MultiSignals, Signal + from colour.hints import ( + Any, + ArrayLike, + Sequence, + ) + from colour.utilities import is_pandas_installed -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import DataFrame, Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/characterisation/tests/test_correction.py b/colour/characterisation/tests/test_correction.py index 2927658b0..15a817295 100644 --- a/colour/characterisation/tests/test_correction.py +++ b/colour/characterisation/tests/test_correction.py @@ -7,6 +7,7 @@ import contextlib import platform +import typing from itertools import product import numpy as np @@ -28,7 +29,10 @@ polynomial_expansion_Vandermonde, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/colorimetry/blackbody.py b/colour/colorimetry/blackbody.py index 83a6382d9..9e0d34a84 100644 --- a/colour/colorimetry/blackbody.py +++ b/colour/colorimetry/blackbody.py @@ -16,6 +16,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import ( @@ -24,7 +26,10 @@ SpectralShape, ) from colour.constants import CONSTANT_BOLTZMANN, CONSTANT_LIGHT_SPEED -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array from colour.utilities.common import attest diff --git a/colour/colorimetry/cmfs.py b/colour/colorimetry/cmfs.py index dc3ba3471..f1afbbd01 100644 --- a/colour/colorimetry/cmfs.py +++ b/colour/colorimetry/cmfs.py @@ -16,23 +16,26 @@ from __future__ import annotations -from collections.abc import KeysView, ValuesView +import typing from colour.colorimetry import ( MultiSpectralDistributions, SpectralDistribution, SpectralShape, ) -from colour.continuous import MultiSignals, Signal -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - Sequence, -) + +if typing.TYPE_CHECKING: + from collections.abc import KeysView, ValuesView + from colour.continuous import MultiSignals, Signal + from colour.hints import ( + Any, + ArrayLike, + Sequence, + ) + from colour.utilities import is_pandas_installed -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import DataFrame, Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/colorimetry/correction.py b/colour/colorimetry/correction.py index e7272424c..a1b04c053 100644 --- a/colour/colorimetry/correction.py +++ b/colour/colorimetry/correction.py @@ -26,8 +26,12 @@ from __future__ import annotations -from colour.colorimetry import SpectralDistribution -from colour.hints import Literal +import typing + +if typing.TYPE_CHECKING: + from colour.colorimetry import SpectralDistribution + from colour.hints import Literal + from colour.utilities import CanonicalMapping, validate_method __author__ = "Colour Developers" diff --git a/colour/colorimetry/datasets/illuminants/hunterlab.py b/colour/colorimetry/datasets/illuminants/hunterlab.py index a2e2d753f..5c4d6d366 100644 --- a/colour/colorimetry/datasets/illuminants/hunterlab.py +++ b/colour/colorimetry/datasets/illuminants/hunterlab.py @@ -22,11 +22,14 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import CanonicalMapping __author__ = "Colour Developers" diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index 63be60d91..32f982a57 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -23,6 +23,8 @@ from __future__ import annotations +import typing + import numpy as np import scipy.spatial.distance @@ -39,7 +41,10 @@ extend_line_segment, intersect_line_segments, ) -from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple + from colour.models import XYZ_to_xy from colour.utilities import as_float_array diff --git a/colour/colorimetry/generation.py b/colour/colorimetry/generation.py index 027baf505..17f43c952 100644 --- a/colour/colorimetry/generation.py +++ b/colour/colorimetry/generation.py @@ -34,6 +34,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra.interpolation import LinearInterpolator @@ -43,13 +45,16 @@ SpectralDistribution, SpectralShape, ) -from colour.hints import ( - Any, - ArrayLike, - Literal, - NDArrayFloat, - Sequence, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + NDArrayFloat, + Sequence, + ) + from colour.utilities import ( CanonicalMapping, as_float_array, diff --git a/colour/colorimetry/illuminants.py b/colour/colorimetry/illuminants.py index 3c1090977..9a5b382b9 100644 --- a/colour/colorimetry/illuminants.py +++ b/colour/colorimetry/illuminants.py @@ -26,6 +26,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import LinearInterpolator @@ -36,7 +38,10 @@ SpectralShape, reshape_sd, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tsplit __author__ = "Colour Developers" diff --git a/colour/colorimetry/lefs.py b/colour/colorimetry/lefs.py index 9316f4b91..0d9ac229a 100644 --- a/colour/colorimetry/lefs.py +++ b/colour/colorimetry/lefs.py @@ -13,6 +13,8 @@ from __future__ import annotations +import typing + from colour.colorimetry import ( SDS_LEFS_PHOTOPIC, SDS_LEFS_SCOTOPIC, @@ -20,7 +22,10 @@ SpectralShape, ) from colour.colorimetry.datasets.lefs import DATA_MESOPIC_X -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import closest, optional, validate_method __author__ = "Colour Developers" diff --git a/colour/colorimetry/lightness.py b/colour/colorimetry/lightness.py index b5cc523a0..4abfd5258 100644 --- a/colour/colorimetry/lightness.py +++ b/colour/colorimetry/lightness.py @@ -62,6 +62,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow @@ -69,7 +71,10 @@ reaction_rate_MichaelisMenten_Abebe2017, reaction_rate_MichaelisMenten_Michaelis1913, ) -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/colorimetry/luminance.py b/colour/colorimetry/luminance.py index 87f8fb91e..4cbe684ec 100644 --- a/colour/colorimetry/luminance.py +++ b/colour/colorimetry/luminance.py @@ -63,6 +63,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow @@ -70,7 +72,10 @@ substrate_concentration_MichaelisMenten_Abebe2017, substrate_concentration_MichaelisMenten_Michaelis1913, ) -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 93a0527e5..3c0faf390 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -27,6 +27,7 @@ from __future__ import annotations +import typing from collections.abc import KeysView, Mapping, ValuesView import numpy as np @@ -40,24 +41,25 @@ ) from colour.constants import DTYPE_FLOAT_DEFAULT from colour.continuous import MultiSignals, Signal -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - DTypeFloat, - Generator, - List, - Literal, - NDArrayFloat, - ProtocolExtrapolator, - ProtocolInterpolator, - Real, - Self, - Sequence, - Type, - TypeVar, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + DTypeFloat, + Generator, + List, + Literal, + NDArrayFloat, + ProtocolExtrapolator, + ProtocolInterpolator, + Real, + Self, + Sequence, + Type, + TypeVar, + ) + +from colour.hints import Any, TypeVar, cast from colour.utilities import ( CACHE_REGISTRY, as_float_array, @@ -77,7 +79,7 @@ validate_method, ) -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import DataFrame, Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/colorimetry/tests/test_blackbody.py b/colour/colorimetry/tests/test_blackbody.py index c0928f44e..b287518fc 100644 --- a/colour/colorimetry/tests/test_blackbody.py +++ b/colour/colorimetry/tests/test_blackbody.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing from itertools import product import numpy as np @@ -15,7 +16,10 @@ sd_rayleigh_jeans, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/colorimetry/tests/test_illuminants.py b/colour/colorimetry/tests/test_illuminants.py index a0e41735c..1124cd44b 100644 --- a/colour/colorimetry/tests/test_illuminants.py +++ b/colour/colorimetry/tests/test_illuminants.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import ( @@ -12,7 +14,10 @@ sd_CIE_standard_illuminant_A, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.temperature import CCT_to_xy_CIE_D from colour.utilities import ignore_numpy_errors diff --git a/colour/colorimetry/tests/test_tristimulus_values.py b/colour/colorimetry/tests/test_tristimulus_values.py index 7dda05dca..e49265103 100644 --- a/colour/colorimetry/tests/test_tristimulus_values.py +++ b/colour/colorimetry/tests/test_tristimulus_values.py @@ -11,6 +11,8 @@ from __future__ import annotations +import typing + import numpy as np import pytest @@ -42,7 +44,10 @@ wavelength_to_XYZ, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import domain_range_scale __author__ = "Colour Developers" diff --git a/colour/colorimetry/tests/test_uniformity.py b/colour/colorimetry/tests/test_uniformity.py index 7384d35af..3ca97df9f 100644 --- a/colour/colorimetry/tests/test_uniformity.py +++ b/colour/colorimetry/tests/test_uniformity.py @@ -2,11 +2,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import spectral_uniformity from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/colorimetry/transformations.py b/colour/colorimetry/transformations.py index 668471727..e61516669 100644 --- a/colour/colorimetry/transformations.py +++ b/colour/colorimetry/transformations.py @@ -32,6 +32,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul @@ -41,7 +43,10 @@ SDS_LEFS_PHOTOPIC, reshape_sd, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import tstack __author__ = "Colour Developers" diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index d20be106f..fa82e23ad 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -36,6 +36,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import lagrange_coefficients, sdiv, sdiv_mode @@ -47,15 +49,17 @@ reshape_msds, reshape_sd, ) -from colour.hints import ( - Any, - ArrayLike, - Literal, - NDArrayFloat, - Real, - Tuple, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + NDArrayFloat, + Tuple, + ) + +from colour.hints import Real, cast from colour.utilities import ( CACHE_REGISTRY, CanonicalMapping, diff --git a/colour/colorimetry/uniformity.py b/colour/colorimetry/uniformity.py index b6b959881..e8132d246 100644 --- a/colour/colorimetry/uniformity.py +++ b/colour/colorimetry/uniformity.py @@ -15,7 +15,10 @@ from __future__ import annotations -from collections.abc import ValuesView +import typing + +if typing.TYPE_CHECKING: + from collections.abc import ValuesView import numpy as np @@ -24,7 +27,9 @@ SpectralDistribution, sds_and_msds_to_msds, ) -from colour.hints import NDArrayFloat, Sequence + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat, Sequence __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index bbe1d8056..069fc9e68 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -44,7 +44,10 @@ from __future__ import annotations -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/colorimetry/yellowness.py b/colour/colorimetry/yellowness.py index 82c0380f8..9fee6d942 100644 --- a/colour/colorimetry/yellowness.py +++ b/colour/colorimetry/yellowness.py @@ -31,10 +31,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/continuous/abstract.py b/colour/continuous/abstract.py index 451d3cef7..365ae71f1 100644 --- a/colour/continuous/abstract.py +++ b/colour/continuous/abstract.py @@ -10,24 +10,27 @@ from __future__ import annotations +import typing from abc import ABC, abstractmethod from copy import deepcopy import numpy as np -from colour.hints import ( - ArrayLike, - Callable, - DTypeFloat, - Generator, - Literal, - NDArrayFloat, - ProtocolExtrapolator, - ProtocolInterpolator, - Real, - Self, - Type, -) +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Callable, + DTypeFloat, + Generator, + Literal, + NDArrayFloat, + ProtocolExtrapolator, + ProtocolInterpolator, + Real, + Self, + Type, + ) + from colour.utilities import ( MixinCallback, as_float, diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 7f3bd3e5e..484178d88 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -9,30 +9,31 @@ from __future__ import annotations +import typing from collections.abc import Iterator, KeysView, Mapping, ValuesView import numpy as np from colour.constants import DTYPE_FLOAT_DEFAULT from colour.continuous import AbstractContinuousFunction, Signal -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - Callable, - Dict, - DTypeFloat, - List, - Literal, - NDArrayFloat, - ProtocolExtrapolator, - ProtocolInterpolator, - Real, - Self, - Sequence, - Type, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Dict, + DTypeFloat, + List, + Literal, + NDArrayFloat, + ProtocolExtrapolator, + ProtocolInterpolator, + Real, + Self, + Sequence, + Type, + ) + +from colour.hints import ArrayLike, Callable, Sequence, cast from colour.utilities import ( as_float_array, attest, @@ -49,7 +50,7 @@ ) from colour.utilities.documentation import is_documentation_building -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import DataFrame, Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index f68e6cf02..596512d39 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -9,6 +9,7 @@ from __future__ import annotations +import typing from collections.abc import Iterator, KeysView, Mapping, Sequence, ValuesView from operator import pow # noqa: A004 from operator import ( @@ -28,21 +29,21 @@ from colour.algebra import Extrapolator, KernelInterpolator from colour.constants import DTYPE_FLOAT_DEFAULT from colour.continuous import AbstractContinuousFunction -from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - Callable, - DTypeFloat, - Literal, - NDArrayFloat, - ProtocolExtrapolator, - ProtocolInterpolator, - Real, - Self, - Type, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + NDArrayFloat, + ProtocolExtrapolator, + ProtocolInterpolator, + Real, + Self, + Type, + ) + +from colour.hints import Callable, DTypeFloat, cast from colour.utilities import ( as_float_array, attest, @@ -62,7 +63,7 @@ from colour.utilities.common import int_digest from colour.utilities.documentation import is_documentation_building -if TYPE_CHECKING or is_pandas_installed(): +if typing.TYPE_CHECKING or is_pandas_installed(): from pandas import Series # pragma: no cover else: # pragma: no cover from unittest import mock diff --git a/colour/contrast/__init__.py b/colour/contrast/__init__.py index 86d6387bb..b392d4bd0 100644 --- a/colour/contrast/__init__.py +++ b/colour/contrast/__init__.py @@ -20,7 +20,11 @@ from __future__ import annotations -from colour.hints import Any, NDArrayFloat, Literal +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, NDArrayFloat, Literal + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/contrast/barten1999.py b/colour/contrast/barten1999.py index a096bfd35..131eda24b 100644 --- a/colour/contrast/barten1999.py +++ b/colour/contrast/barten1999.py @@ -28,9 +28,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array __author__ = "Colour Developers" diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index b1fb62429..84fc6fa92 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -15,11 +15,14 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field import numpy as np -from colour.hints import NDArrayFloat, Tuple +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat, Tuple + from colour.utilities import MixinDataclassIterable, as_float_array from colour.utilities.documentation import ( DocstringDict, diff --git a/colour/corresponding/prediction.py b/colour/corresponding/prediction.py index c21722846..d68439fe8 100644 --- a/colour/corresponding/prediction.py +++ b/colour/corresponding/prediction.py @@ -38,6 +38,7 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np @@ -53,14 +54,17 @@ BRENEMAN_EXPERIMENT_PRIMARIES_CHROMATICITIES, BRENEMAN_EXPERIMENTS, ) -from colour.hints import ( - Any, - ArrayLike, - Literal, - LiteralChromaticAdaptationTransform, - NDArrayFloat, - Tuple, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + Tuple, + ) + from colour.models import ( Luv_to_uv, Luv_uv_to_xy, diff --git a/colour/corresponding/tests/test_prediction.py b/colour/corresponding/tests/test_prediction.py index 50d654684..46427dea3 100644 --- a/colour/corresponding/tests/test_prediction.py +++ b/colour/corresponding/tests/test_prediction.py @@ -2,6 +2,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS @@ -16,7 +18,9 @@ CorrespondingColourDataset, convert_experiment_results_Breneman1987, ) -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/difference/__init__.py b/colour/difference/__init__.py index 4f51f4a1c..93d824085 100644 --- a/colour/difference/__init__.py +++ b/colour/difference/__init__.py @@ -39,7 +39,11 @@ from __future__ import annotations -from colour.hints import Any, ArrayLike, NDArrayFloat, LiteralDeltaEMethod +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, NDArrayFloat, LiteralDeltaEMethod + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/difference/cam02_ucs.py b/colour/difference/cam02_ucs.py index f91063766..e54a9af6b 100644 --- a/colour/difference/cam02_ucs.py +++ b/colour/difference/cam02_ucs.py @@ -18,9 +18,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006, Coefficients_UCS_Luo2006 from colour.utilities import as_float, tsplit diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index 61bfd9263..f00a68e44 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -46,12 +46,16 @@ from __future__ import annotations +import typing from dataclasses import astuple, dataclass, field import numpy as np from colour.algebra import euclidean_distance -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( MixinDataclassArithmetic, as_float, diff --git a/colour/difference/din99.py b/colour/difference/din99.py index 49e4e6960..a50205cca 100644 --- a/colour/difference/din99.py +++ b/colour/difference/din99.py @@ -16,8 +16,13 @@ from __future__ import annotations +import typing + from colour.algebra import euclidean_distance -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Lab_to_DIN99 from colour.utilities import get_domain_range_scale diff --git a/colour/difference/huang2015.py b/colour/difference/huang2015.py index 18fe0b67e..4341d671b 100644 --- a/colour/difference/huang2015.py +++ b/colour/difference/huang2015.py @@ -21,9 +21,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import CanonicalMapping, tsplit, validate_method __author__ = "Colour Developers" diff --git a/colour/difference/stress.py b/colour/difference/stress.py index 2d0e54e3a..384a29a7f 100644 --- a/colour/difference/stress.py +++ b/colour/difference/stress.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/geometry/ellipse.py b/colour/geometry/ellipse.py index c0ac70dfa..48d752ca7 100644 --- a/colour/geometry/ellipse.py +++ b/colour/geometry/ellipse.py @@ -21,9 +21,14 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat, cast +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal + +from colour.hints import NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, ones, diff --git a/colour/geometry/intersection.py b/colour/geometry/intersection.py index 5a7756576..af4eb6fac 100644 --- a/colour/geometry/intersection.py +++ b/colour/geometry/intersection.py @@ -21,12 +21,16 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.algebra import euclidean_distance, sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float_array, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index e66a353fd..0308ab282 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -19,18 +19,25 @@ from __future__ import annotations +import typing + import numpy as np from colour.constants import DTYPE_FLOAT_DEFAULT, DTYPE_INT_DEFAULT + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + DTypeFloat, + DTypeInt, + Literal, + NDArray, + Tuple, + Type, + ) + from colour.hints import ( - Any, - DTypeFloat, - DTypeInt, - Literal, - NDArray, NDArrayFloat, - Tuple, - Type, cast, ) from colour.utilities import ( diff --git a/colour/geometry/section.py b/colour/geometry/section.py index ca1c55b9a..c62419f69 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -9,11 +9,17 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import linear_conversion from colour.constants import DTYPE_FLOAT_DEFAULT -from colour.hints import Any, ArrayLike, List, Literal, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + +from colour.hints import List, cast from colour.utilities import ( as_float_array, as_float_scalar, @@ -135,7 +141,7 @@ def close_chord(vertices: ArrayLike) -> NDArrayFloat: def unique_vertices( vertices: ArrayLike, - decimals: int = np.finfo(cast(Any, DTYPE_FLOAT_DEFAULT)).precision - 1, + decimals: int = np.finfo(DTYPE_FLOAT_DEFAULT).precision - 1, # pyright: ignore ) -> NDArrayFloat: """ Return the unique vertices from given vertices. diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 404056ecc..632d35e31 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -14,11 +14,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spherical_to_cartesian from colour.geometry import MAPPING_PLANE_TO_AXIS -from colour.hints import Any, ArrayLike, Literal, NDArrayFloat, Sequence + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Literal, NDArrayFloat, Sequence + from colour.utilities import ( CanonicalMapping, as_float_array, diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index 34b03609b..bfed2d44a 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -15,6 +15,7 @@ import re import sys import textwrap +import typing from copy import copy from dataclasses import dataclass from functools import partial @@ -65,12 +66,17 @@ whiteness, yellowness, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + List, + Literal, + ) + from colour.hints import ( - Any, - ArrayLike, - Callable, - List, - Literal, NDArrayFloat, cast, ) diff --git a/colour/hints/__init__.py b/colour/hints/__init__.py index 1e271d07d..976632f90 100644 --- a/colour/hints/__init__.py +++ b/colour/hints/__init__.py @@ -10,10 +10,10 @@ from __future__ import annotations import re +import typing from collections.abc import Generator, Iterable, Iterator, Mapping, Sequence from types import ModuleType from typing import ( # noqa: UP035 - TYPE_CHECKING, Any, Callable, ClassVar, @@ -66,7 +66,6 @@ "Sequence", "Set", "SupportsIndex", - "TYPE_CHECKING", "TextIO", "Tuple", "Type", @@ -668,7 +667,7 @@ def number_or_arraylike(a: ArrayLike) -> NDArray: ... # ----------------------------------------------------------------------------# # --- API Changes and Deprecation Management ---# # ----------------------------------------------------------------------------# -if not TYPE_CHECKING: +if not typing.TYPE_CHECKING: DTypeFloating = DTypeFloat DTypeInteger = DTypeInt DTypeNumber = DTypeReal diff --git a/colour/io/__init__.py b/colour/io/__init__.py index 42a8a4713..c1a8b14a7 100644 --- a/colour/io/__init__.py +++ b/colour/io/__init__.py @@ -5,6 +5,7 @@ from colour.utilities.deprecation import ModuleAPI, build_API_changes from colour.utilities.documentation import is_documentation_building + from colour.hints import Any from .luts import * # noqa: F403 diff --git a/colour/io/ctl.py b/colour/io/ctl.py index 10fc18226..d472a0b17 100644 --- a/colour/io/ctl.py +++ b/colour/io/ctl.py @@ -16,15 +16,20 @@ import subprocess import tempfile import textwrap -from pathlib import Path +import typing import numpy as np +if typing.TYPE_CHECKING: + from pathlib import Path + from colour.hints import ( + Any, + ArrayLike, + Dict, + NDArrayFloat, + ) + from colour.hints import ( - Any, - ArrayLike, - Dict, - NDArrayFloat, Sequence, ) from colour.io import as_3_channels_image, read_image, write_image diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index dcfaedf86..91c67153f 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -14,10 +14,10 @@ from __future__ import annotations import re +import typing from collections import defaultdict from collections.abc import ValuesView from dataclasses import dataclass, field -from pathlib import Path import numpy as np @@ -31,11 +31,17 @@ sds_and_msds_to_msds, ) from colour.constants import CONSTANT_LIGHT_SPEED + +if typing.TYPE_CHECKING: + from pathlib import Path + from colour.hints import ( + Any, + Callable, + Literal, + ) + from colour.hints import ( - Any, - Callable, Dict, - Literal, NDArrayFloat, Sequence, Tuple, diff --git a/colour/io/image.py b/colour/io/image.py index b27730b24..dc5f1675b 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -7,22 +7,26 @@ from __future__ import annotations +import typing from dataclasses import dataclass, field -from pathlib import Path import numpy as np +if typing.TYPE_CHECKING: + from pathlib import Path + from colour.hints import ( + Any, + ArrayLike, + DTypeReal, + Literal, + NDArrayFloat, + Sequence, + Tuple, + Type, + ) + from colour.hints import ( - TYPE_CHECKING, - Any, - ArrayLike, - DTypeReal, - Literal, - NDArrayFloat, NDArrayReal, - Sequence, - Tuple, - Type, cast, ) from colour.utilities import ( @@ -121,7 +125,7 @@ class Image_Specification_Attribute: "float64": Image_Specification_BitDepth("float64", np.float64, DOUBLE), } ) - if not TYPE_CHECKING and hasattr(np, "float128"): # pragma: no cover + if not typing.TYPE_CHECKING and hasattr(np, "float128"): # pragma: no cover MAPPING_BIT_DEPTH["float128"] = Image_Specification_BitDepth( "float128", np.float128, DOUBLE ) @@ -139,7 +143,7 @@ class ImageSpec: "float64": Image_Specification_BitDepth("float64", np.float64, None), } ) - if not TYPE_CHECKING and hasattr(np, "float128"): # pragma: no cover + if not typing.TYPE_CHECKING and hasattr(np, "float128"): # pragma: no cover MAPPING_BIT_DEPTH["float128"] = Image_Specification_BitDepth( "float128", np.float128, None ) diff --git a/colour/io/luts/__init__.py b/colour/io/luts/__init__.py index 8287271b1..72962d1f7 100644 --- a/colour/io/luts/__init__.py +++ b/colour/io/luts/__init__.py @@ -16,9 +16,15 @@ from __future__ import annotations import os -from pathlib import Path -from colour.hints import Any, LiteralLUTReadMethod, LiteralLUTWriteMethod +import typing + +if typing.TYPE_CHECKING: + from pathlib import Path + +if typing.TYPE_CHECKING: + from colour.hints import Any, LiteralLUTReadMethod, LiteralLUTWriteMethod + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/io/luts/cinespace_csp.py b/colour/io/luts/cinespace_csp.py index 42d6b9c76..37cb18bd0 100644 --- a/colour/io/luts/cinespace_csp.py +++ b/colour/io/luts/cinespace_csp.py @@ -17,11 +17,16 @@ from __future__ import annotations -from pathlib import Path +import typing + +if typing.TYPE_CHECKING: + from pathlib import Path import numpy as np -from colour.hints import ArrayLike, List, NDArrayFloat, NDArrayInt +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, List, NDArrayFloat, NDArrayInt + from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUTSequence from colour.utilities import ( as_float_array, diff --git a/colour/io/luts/common.py b/colour/io/luts/common.py index 8832f4562..828f04aee 100644 --- a/colour/io/luts/common.py +++ b/colour/io/luts/common.py @@ -10,7 +10,10 @@ import os import re -from pathlib import Path +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from pathlib import Path __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/io/luts/iridas_cube.py b/colour/io/luts/iridas_cube.py index 1a2910bd3..c092be826 100644 --- a/colour/io/luts/iridas_cube.py +++ b/colour/io/luts/iridas_cube.py @@ -16,7 +16,7 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import numpy as np @@ -30,6 +30,9 @@ usage_warning, ) +if TYPE_CHECKING: + from pathlib import Path + __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index 30c5c7216..a92197df2 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -12,6 +12,7 @@ from __future__ import annotations +import typing from abc import ABC, abstractmethod from copy import deepcopy from operator import pow # noqa: A004 @@ -36,15 +37,20 @@ linear_conversion, table_interpolation_trilinear, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + NDArrayFloat, + Self, + Sequence, + Type, + ) + from colour.hints import ( - Any, - ArrayLike, List, - Literal, - NDArrayFloat, - Self, - Sequence, - Type, cast, ) from colour.utilities import ( diff --git a/colour/io/luts/operator.py b/colour/io/luts/operator.py index d8a72717b..eb0e51784 100644 --- a/colour/io/luts/operator.py +++ b/colour/io/luts/operator.py @@ -10,18 +10,22 @@ from __future__ import annotations +import typing from abc import ABC, abstractmethod import numpy as np from colour.algebra import vecmul -from colour.hints import ( - Any, - ArrayLike, - List, - NDArrayFloat, - Sequence, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + List, + NDArrayFloat, + Sequence, + ) + from colour.utilities import ( as_float_array, attest, diff --git a/colour/io/luts/resolve_cube.py b/colour/io/luts/resolve_cube.py index b06f7743d..089070776 100644 --- a/colour/io/luts/resolve_cube.py +++ b/colour/io/luts/resolve_cube.py @@ -17,7 +17,7 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import numpy as np @@ -31,6 +31,9 @@ tstack, ) +if TYPE_CHECKING: + from pathlib import Path + __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" diff --git a/colour/io/luts/sequence.py b/colour/io/luts/sequence.py index 9b1bc510a..853d77260 100644 --- a/colour/io/luts/sequence.py +++ b/colour/io/luts/sequence.py @@ -10,16 +10,21 @@ from __future__ import annotations import re +import typing from collections.abc import MutableSequence from copy import deepcopy +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + List, + NDArrayFloat, + Sequence, + ) + from colour.hints import ( - Any, - ArrayLike, - List, - NDArrayFloat, ProtocolLUTSequenceItem, - Sequence, ) from colour.utilities import as_float_array, attest, is_iterable diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index 1c4bcc67b..4d4411d91 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -11,7 +11,7 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import numpy as np @@ -25,6 +25,9 @@ usage_warning, ) +if TYPE_CHECKING: + from pathlib import Path + __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 9d2a8e7b3..08fac7327 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -11,7 +11,7 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import numpy as np @@ -26,6 +26,9 @@ usage_warning, ) +if TYPE_CHECKING: + from pathlib import Path + __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" diff --git a/colour/io/luts/sony_spimtx.py b/colour/io/luts/sony_spimtx.py index f19d630cd..6dc4a609b 100644 --- a/colour/io/luts/sony_spimtx.py +++ b/colour/io/luts/sony_spimtx.py @@ -10,7 +10,7 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import numpy as np @@ -18,6 +18,9 @@ from colour.io.luts import LUTOperatorMatrix from colour.io.luts.common import path_to_title +if TYPE_CHECKING: + from pathlib import Path + __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" diff --git a/colour/io/luts/tests/test_lut.py b/colour/io/luts/tests/test_lut.py index 6f2121856..e92689731 100644 --- a/colour/io/luts/tests/test_lut.py +++ b/colour/io/luts/tests/test_lut.py @@ -4,6 +4,7 @@ import os import textwrap +import typing import numpy as np import pytest @@ -17,13 +18,16 @@ table_interpolation_trilinear, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import ( - Any, - Callable, - NDArrayFloat, - ProtocolInterpolator, - Type, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + NDArrayFloat, + ProtocolInterpolator, + Type, + ) + from colour.io.luts import LUT1D, LUT3D, LUT3x1D, LUT_to_LUT from colour.io.luts.lut import AbstractLUT from colour.utilities import as_float_array, tsplit, tstack diff --git a/colour/io/luts/tests/test_sequence.py b/colour/io/luts/tests/test_sequence.py index 806335de3..309d7d6ff 100644 --- a/colour/io/luts/tests/test_sequence.py +++ b/colour/io/luts/tests/test_sequence.py @@ -3,11 +3,15 @@ from __future__ import annotations import textwrap +import typing import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import Any, ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, NDArrayFloat + from colour.io.luts import ( LUT1D, LUT3D, diff --git a/colour/io/ocio.py b/colour/io/ocio.py index a4070e51b..0f9fbb2a0 100644 --- a/colour/io/ocio.py +++ b/colour/io/ocio.py @@ -9,9 +9,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import Any, ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, NDArrayFloat + from colour.io import as_3_channels_image from colour.utilities import as_float, as_float_array, required diff --git a/colour/io/tabular.py b/colour/io/tabular.py index e015d1173..6949cf85e 100644 --- a/colour/io/tabular.py +++ b/colour/io/tabular.py @@ -14,13 +14,18 @@ import csv import os import tempfile -from pathlib import Path +import typing import numpy as np from colour.colorimetry import SpectralDistribution from colour.constants import DTYPE_FLOAT_DEFAULT -from colour.hints import Any, Dict, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from pathlib import Path + from colour.hints import Any, Dict, NDArrayFloat + +from colour.hints import cast from colour.utilities import filter_kwargs __author__ = "Colour Developers" diff --git a/colour/io/tests/test_tm2714.py b/colour/io/tests/test_tm2714.py index be17e5917..9e102f42a 100644 --- a/colour/io/tests/test_tm2714.py +++ b/colour/io/tests/test_tm2714.py @@ -7,6 +7,7 @@ import shutil import tempfile import textwrap +import typing from copy import deepcopy import numpy as np @@ -14,7 +15,11 @@ from colour.colorimetry import SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import List, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import List, Tuple + +from colour.hints import cast from colour.io.tm2714 import Header_IESTM2714, SpectralDistribution_IESTM2714 from colour.utilities import optional diff --git a/colour/io/tests/test_uprtek_sekonic.py b/colour/io/tests/test_uprtek_sekonic.py index 7d0265e53..27abd551a 100644 --- a/colour/io/tests/test_uprtek_sekonic.py +++ b/colour/io/tests/test_uprtek_sekonic.py @@ -4,13 +4,17 @@ import json import os +import typing import numpy as np import pytest from colour.colorimetry import SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import Any + +if typing.TYPE_CHECKING: + from colour.hints import Any + from colour.io import ( SpectralDistribution_Sekonic, SpectralDistribution_UPRTek, diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 2c3f066d0..8d4def14d 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -17,13 +17,17 @@ import os import re +import typing from dataclasses import dataclass, field from pathlib import Path from xml.dom import minidom from xml.etree import ElementTree as ET from colour.colorimetry import SpectralDistribution -from colour.hints import Any, Callable, Literal + +if typing.TYPE_CHECKING: + from colour.hints import Any, Callable, Literal + from colour.utilities import ( Structure, as_float_array, diff --git a/colour/io/uprtek_sekonic.py b/colour/io/uprtek_sekonic.py index fb95e37b4..5b26b4ae8 100644 --- a/colour/io/uprtek_sekonic.py +++ b/colour/io/uprtek_sekonic.py @@ -15,10 +15,16 @@ import json import os import re +import typing from collections import defaultdict -from pathlib import Path -from colour.hints import Any, cast +if typing.TYPE_CHECKING: + from pathlib import Path + +if typing.TYPE_CHECKING: + from colour.hints import Any + +from colour.hints import cast from colour.io import SpectralDistribution_IESTM2714 from colour.utilities import as_float_array, as_float_scalar diff --git a/colour/io/xrite.py b/colour/io/xrite.py index ebd4ed625..b41a72793 100644 --- a/colour/io/xrite.py +++ b/colour/io/xrite.py @@ -11,10 +11,15 @@ import codecs import re -from pathlib import Path +import typing + +if typing.TYPE_CHECKING: + from pathlib import Path from colour.colorimetry import SpectralDistribution -from colour.hints import Dict + +if typing.TYPE_CHECKING: + from colour.hints import Dict __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/cam02_ucs.py b/colour/models/cam02_ucs.py index 9c9110a57..115b426bd 100644 --- a/colour/models/cam02_ucs.py +++ b/colour/models/cam02_ucs.py @@ -27,12 +27,17 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.algebra import cartesian_to_polar, polar_to_cartesian -from colour.hints import Any, ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike + +from colour.hints import NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, MixinDataclassIterable, diff --git a/colour/models/cam16_ucs.py b/colour/models/cam16_ucs.py index f3bab46cf..da56a9896 100644 --- a/colour/models/cam16_ucs.py +++ b/colour/models/cam16_ucs.py @@ -29,9 +29,13 @@ from __future__ import annotations import re +import typing from functools import partial -from colour.hints import Any, ArrayLike, Callable, NDArrayFloat, cast +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Callable + +from colour.hints import NDArrayFloat, cast from colour.models.cam02_ucs import ( COEFFICIENTS_UCS_LUO2006, CAM02LCD_to_JMh_CIECAM02, diff --git a/colour/models/cie_lab.py b/colour/models/cie_lab.py index 7603fb2d0..978b3a617 100644 --- a/colour/models/cie_lab.py +++ b/colour/models/cie_lab.py @@ -16,12 +16,17 @@ from __future__ import annotations +import typing + from colour.colorimetry import ( CCS_ILLUMINANTS, intermediate_lightness_function_CIE1976, intermediate_luminance_function_CIE1976, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import xy_to_xyY, xyY_to_XYZ from colour.utilities import ( from_range_1, diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index 15cb7b653..062ca723a 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -30,6 +30,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode @@ -38,7 +40,10 @@ lightness_CIE1976, luminance_CIE1976, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import xy_to_xyY, xyY_to_XYZ from colour.utilities import ( domain_range_scale, diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index 9fba4ec3d..87dedb086 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -24,10 +24,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( from_range_1, to_domain_1, diff --git a/colour/models/cie_uvw.py b/colour/models/cie_uvw.py index 2564b5b85..c830c0016 100644 --- a/colour/models/cie_uvw.py +++ b/colour/models/cie_uvw.py @@ -16,9 +16,14 @@ from __future__ import annotations +import typing + from colour.algebra import sdiv, sdiv_mode, spow from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import ( UCS_uv_to_xy, XYZ_to_xy, diff --git a/colour/models/cie_xyy.py b/colour/models/cie_xyy.py index 3c6be32c1..1e17c0b62 100644 --- a/colour/models/cie_xyy.py +++ b/colour/models/cie_xyy.py @@ -22,10 +22,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float_array, from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/models/common.py b/colour/models/common.py index 6e35237df..ff30174f0 100644 --- a/colour/models/common.py +++ b/colour/models/common.py @@ -19,10 +19,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import cartesian_to_polar, polar_to_cartesian, vecmul -from colour.hints import ArrayLike, Callable, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Callable, NDArrayFloat + from colour.utilities import ( CanonicalMapping, attest, diff --git a/colour/models/datasets/macadam_ellipses.py b/colour/models/datasets/macadam_ellipses.py index c94af6ad0..0f1e1bcbf 100644 --- a/colour/models/datasets/macadam_ellipses.py +++ b/colour/models/datasets/macadam_ellipses.py @@ -18,9 +18,12 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/datasets/pointer_gamut.py b/colour/models/datasets/pointer_gamut.py index da6bed7af..42ae83648 100644 --- a/colour/models/datasets/pointer_gamut.py +++ b/colour/models/datasets/pointer_gamut.py @@ -12,10 +12,14 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_LIGHT_SOURCES -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/din99.py b/colour/models/din99.py index bd2315af2..a6ab6c48f 100644 --- a/colour/models/din99.py +++ b/colour/models/din99.py @@ -23,11 +23,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models import Lab_to_XYZ, XYZ_to_Lab from colour.utilities import ( CanonicalMapping, diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 86a876fbb..979b46ec3 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -23,6 +23,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import ( @@ -32,7 +34,10 @@ luminance_Fairchild2010, luminance_Fairchild2011, ) -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models import xy_to_xyY, xyY_to_XYZ from colour.utilities import ( as_float_array, diff --git a/colour/models/hdr_ipt.py b/colour/models/hdr_ipt.py index f186b3ffe..12565c32b 100644 --- a/colour/models/hdr_ipt.py +++ b/colour/models/hdr_ipt.py @@ -23,6 +23,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul @@ -32,7 +34,10 @@ luminance_Fairchild2010, luminance_Fairchild2011, ) -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models.ipt import ( MATRIX_IPT_IPT_TO_LMS_P, MATRIX_IPT_LMS_P_TO_IPT, diff --git a/colour/models/hunter_lab.py b/colour/models/hunter_lab.py index 33e5fe385..b40ae7958 100644 --- a/colour/models/hunter_lab.py +++ b/colour/models/hunter_lab.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import TVS_ILLUMINANTS_HUNTERLAB -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import from_range_100, to_domain_100, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/models/hunter_rdab.py b/colour/models/hunter_rdab.py index c818da467..55f9a5e34 100644 --- a/colour/models/hunter_rdab.py +++ b/colour/models/hunter_rdab.py @@ -17,8 +17,13 @@ from __future__ import annotations +import typing + from colour.colorimetry import TVS_ILLUMINANTS_HUNTERLAB -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import XYZ_to_K_ab_HunterLab1966 from colour.utilities import from_range_100, to_domain_100, tsplit, tstack diff --git a/colour/models/icacb.py b/colour/models/icacb.py index 2636cc075..2de78d6ea 100644 --- a/colour/models/icacb.py +++ b/colour/models/icacb.py @@ -15,9 +15,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Iab_to_XYZ, XYZ_to_Iab from colour.models.rgb.transfer_functions import ( eotf_inverse_ST2084, diff --git a/colour/models/igpgtg.py b/colour/models/igpgtg.py index 6df496f6d..73ebc9b5c 100644 --- a/colour/models/igpgtg.py +++ b/colour/models/igpgtg.py @@ -16,10 +16,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike + +from colour.hints import NDArrayFloat, cast from colour.models import Iab_to_XYZ, XYZ_to_Iab __author__ = "Colour Developers" diff --git a/colour/models/ipt.py b/colour/models/ipt.py index 18ee651e4..efad0f5ef 100644 --- a/colour/models/ipt.py +++ b/colour/models/ipt.py @@ -19,12 +19,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Iab_to_XYZ, XYZ_to_Iab from colour.utilities import as_float, from_range_degrees, to_domain_1, tsplit diff --git a/colour/models/jzazbz.py b/colour/models/jzazbz.py index e0b12e79f..aaf6e3a7d 100644 --- a/colour/models/jzazbz.py +++ b/colour/models/jzazbz.py @@ -23,10 +23,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models.rgb.transfer_functions import ( eotf_inverse_ST2084, eotf_ST2084, diff --git a/colour/models/oklab.py b/colour/models/oklab.py index d56d8563c..e80c84a85 100644 --- a/colour/models/oklab.py +++ b/colour/models/oklab.py @@ -16,12 +16,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Iab_to_XYZ, XYZ_to_Iab __author__ = "Colour Developers" diff --git a/colour/models/osa_ucs.py b/colour/models/osa_ucs.py index c64bf341e..bde72c5b9 100644 --- a/colour/models/osa_ucs.py +++ b/colour/models/osa_ucs.py @@ -20,11 +20,16 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import fmin from colour.algebra import sdiv, sdiv_mode, spow, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import XYZ_to_xyY from colour.utilities import ( as_float, diff --git a/colour/models/prolab.py b/colour/models/prolab.py index 68a2f4155..24a14adf9 100644 --- a/colour/models/prolab.py +++ b/colour/models/prolab.py @@ -16,10 +16,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import xy_to_xyY, xyY_to_XYZ from colour.utilities import as_float_array, from_range_1, ones, to_domain_1 diff --git a/colour/models/ragoo2021.py b/colour/models/ragoo2021.py index 104367cb1..4247e431f 100644 --- a/colour/models/ragoo2021.py +++ b/colour/models/ragoo2021.py @@ -18,12 +18,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import Iab_to_XYZ, XYZ_to_Iab __author__ = "Colour Developers" diff --git a/colour/models/rgb/cmyk.py b/colour/models/rgb/cmyk.py index babf47ef0..057b1e696 100644 --- a/colour/models/rgb/cmyk.py +++ b/colour/models/rgb/cmyk.py @@ -23,9 +23,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float_array, from_range_1, diff --git a/colour/models/rgb/common.py b/colour/models/rgb/common.py index c92c6fad7..9d02cb07a 100644 --- a/colour/models/rgb/common.py +++ b/colour/models/rgb/common.py @@ -7,12 +7,17 @@ from __future__ import annotations +import typing + from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ( - ArrayLike, - LiteralChromaticAdaptationTransform, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + ) + from colour.models.rgb import RGB_COLOURSPACES, RGB_to_XYZ, XYZ_to_RGB __author__ = "Colour Developers" diff --git a/colour/models/rgb/cylindrical.py b/colour/models/rgb/cylindrical.py index 6e1b838f2..2c6a08f7e 100644 --- a/colour/models/rgb/cylindrical.py +++ b/colour/models/rgb/cylindrical.py @@ -47,10 +47,16 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + +from colour.hints import ArrayLike, cast from colour.utilities import ( as_float_array, from_range_1, diff --git a/colour/models/rgb/datasets/aces.py b/colour/models/rgb/datasets/aces.py index 0653fb869..b41fc9f4e 100644 --- a/colour/models/rgb/datasets/aces.py +++ b/colour/models/rgb/datasets/aces.py @@ -56,10 +56,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/adobe_rgb_1998.py b/colour/models/rgb/datasets/adobe_rgb_1998.py index 476148f09..9cc0eb976 100644 --- a/colour/models/rgb/datasets/adobe_rgb_1998.py +++ b/colour/models/rgb/datasets/adobe_rgb_1998.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import RGB_Colourspace, gamma_function __author__ = "Colour Developers" diff --git a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py index 601c6ebda..8f79116a2 100644 --- a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py +++ b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py @@ -15,12 +15,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/apple_rgb.py b/colour/models/rgb/datasets/apple_rgb.py index f18ee6487..e724953e6 100644 --- a/colour/models/rgb/datasets/apple_rgb.py +++ b/colour/models/rgb/datasets/apple_rgb.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/arri.py b/colour/models/rgb/datasets/arri.py index 874604eb4..b63f3bd6b 100644 --- a/colour/models/rgb/datasets/arri.py +++ b/colour/models/rgb/datasets/arri.py @@ -19,10 +19,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_ARRILogC3, diff --git a/colour/models/rgb/datasets/best_rgb.py b/colour/models/rgb/datasets/best_rgb.py index 89e31484a..4153cf9c3 100644 --- a/colour/models/rgb/datasets/best_rgb.py +++ b/colour/models/rgb/datasets/best_rgb.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/beta_rgb.py b/colour/models/rgb/datasets/beta_rgb.py index 555742512..1c4b03e14 100644 --- a/colour/models/rgb/datasets/beta_rgb.py +++ b/colour/models/rgb/datasets/beta_rgb.py @@ -15,12 +15,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/blackmagic_design.py b/colour/models/rgb/datasets/blackmagic_design.py index 0e5233477..3da85d2a3 100644 --- a/colour/models/rgb/datasets/blackmagic_design.py +++ b/colour/models/rgb/datasets/blackmagic_design.py @@ -15,10 +15,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, oetf_BlackmagicFilmGeneration5, diff --git a/colour/models/rgb/datasets/canon_cinema_gamut.py b/colour/models/rgb/datasets/canon_cinema_gamut.py index d5d4c1921..cc023d7e3 100644 --- a/colour/models/rgb/datasets/canon_cinema_gamut.py +++ b/colour/models/rgb/datasets/canon_cinema_gamut.py @@ -16,10 +16,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/cie_rgb.py b/colour/models/rgb/datasets/cie_rgb.py index 3f61fc91d..926c5f619 100644 --- a/colour/models/rgb/datasets/cie_rgb.py +++ b/colour/models/rgb/datasets/cie_rgb.py @@ -16,12 +16,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import RGB_Colourspace, gamma_function __author__ = "Colour Developers" diff --git a/colour/models/rgb/datasets/color_match_rgb.py b/colour/models/rgb/datasets/color_match_rgb.py index 9ff0f0042..6376ac821 100644 --- a/colour/models/rgb/datasets/color_match_rgb.py +++ b/colour/models/rgb/datasets/color_match_rgb.py @@ -15,12 +15,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/davinci_wide_gamut.py b/colour/models/rgb/datasets/davinci_wide_gamut.py index fdd18b476..66d2b4667 100644 --- a/colour/models/rgb/datasets/davinci_wide_gamut.py +++ b/colour/models/rgb/datasets/davinci_wide_gamut.py @@ -18,10 +18,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, oetf_DaVinciIntermediate, diff --git a/colour/models/rgb/datasets/dcdm_xyz.py b/colour/models/rgb/datasets/dcdm_xyz.py index d1ddb3b0c..0c9cd3806 100644 --- a/colour/models/rgb/datasets/dcdm_xyz.py +++ b/colour/models/rgb/datasets/dcdm_xyz.py @@ -16,10 +16,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, eotf_DCDM, diff --git a/colour/models/rgb/datasets/dci_p3.py b/colour/models/rgb/datasets/dci_p3.py index 9ae2b7fb8..65f34c86e 100644 --- a/colour/models/rgb/datasets/dci_p3.py +++ b/colour/models/rgb/datasets/dci_p3.py @@ -26,12 +26,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/display_p3.py b/colour/models/rgb/datasets/display_p3.py index 004a34815..49dd27ae7 100644 --- a/colour/models/rgb/datasets/display_p3.py +++ b/colour/models/rgb/datasets/display_p3.py @@ -15,10 +15,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, eotf_inverse_sRGB, diff --git a/colour/models/rgb/datasets/dji_d_gamut.py b/colour/models/rgb/datasets/dji_d_gamut.py index d7b45165d..c6e66d3df 100644 --- a/colour/models/rgb/datasets/dji_d_gamut.py +++ b/colour/models/rgb/datasets/dji_d_gamut.py @@ -16,10 +16,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_DJIDLog, diff --git a/colour/models/rgb/datasets/don_rgb_4.py b/colour/models/rgb/datasets/don_rgb_4.py index 25638df6b..a794335f6 100644 --- a/colour/models/rgb/datasets/don_rgb_4.py +++ b/colour/models/rgb/datasets/don_rgb_4.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/ebu_3213_e.py b/colour/models/rgb/datasets/ebu_3213_e.py index b23fa883a..fe410f487 100644 --- a/colour/models/rgb/datasets/ebu_3213_e.py +++ b/colour/models/rgb/datasets/ebu_3213_e.py @@ -15,9 +15,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/eci_rgb_v2.py b/colour/models/rgb/datasets/eci_rgb_v2.py index 9db5d78f9..97112489f 100644 --- a/colour/models/rgb/datasets/eci_rgb_v2.py +++ b/colour/models/rgb/datasets/eci_rgb_v2.py @@ -15,6 +15,7 @@ from __future__ import annotations +import typing from functools import partial import numpy as np @@ -24,11 +25,14 @@ lightness_CIE1976, luminance_CIE1976, ) -from colour.hints import ( - ArrayLike, - Callable, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Callable, + NDArrayFloat, + ) + from colour.models.rgb import RGB_Colourspace, normalised_primary_matrix from colour.utilities import as_float_array diff --git a/colour/models/rgb/datasets/ekta_space_ps5.py b/colour/models/rgb/datasets/ekta_space_ps5.py index c0f6de3dd..78c6fe6b4 100644 --- a/colour/models/rgb/datasets/ekta_space_ps5.py +++ b/colour/models/rgb/datasets/ekta_space_ps5.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/filmlight_e_gamut.py b/colour/models/rgb/datasets/filmlight_e_gamut.py index 70bf0b7a2..24437a48c 100644 --- a/colour/models/rgb/datasets/filmlight_e_gamut.py +++ b/colour/models/rgb/datasets/filmlight_e_gamut.py @@ -14,10 +14,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_FilmLightTLog, diff --git a/colour/models/rgb/datasets/fujifilm.py b/colour/models/rgb/datasets/fujifilm.py index f84d6784e..2235fdc5d 100644 --- a/colour/models/rgb/datasets/fujifilm.py +++ b/colour/models/rgb/datasets/fujifilm.py @@ -18,10 +18,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_FLog, diff --git a/colour/models/rgb/datasets/gopro.py b/colour/models/rgb/datasets/gopro.py index 0009bb16c..b2932b4e2 100644 --- a/colour/models/rgb/datasets/gopro.py +++ b/colour/models/rgb/datasets/gopro.py @@ -26,10 +26,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_Protune, diff --git a/colour/models/rgb/datasets/itur_bt_2020.py b/colour/models/rgb/datasets/itur_bt_2020.py index 315e73ceb..69b16f2fd 100644 --- a/colour/models/rgb/datasets/itur_bt_2020.py +++ b/colour/models/rgb/datasets/itur_bt_2020.py @@ -18,10 +18,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, normalised_primary_matrix, diff --git a/colour/models/rgb/datasets/itur_bt_470.py b/colour/models/rgb/datasets/itur_bt_470.py index 252c6b62c..384abc2af 100644 --- a/colour/models/rgb/datasets/itur_bt_470.py +++ b/colour/models/rgb/datasets/itur_bt_470.py @@ -18,12 +18,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/itur_bt_709.py b/colour/models/rgb/datasets/itur_bt_709.py index 8f35650ea..0e6e79619 100644 --- a/colour/models/rgb/datasets/itur_bt_709.py +++ b/colour/models/rgb/datasets/itur_bt_709.py @@ -18,10 +18,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, normalised_primary_matrix, diff --git a/colour/models/rgb/datasets/itut_h_273.py b/colour/models/rgb/datasets/itut_h_273.py index 233ecede5..e0c56023f 100644 --- a/colour/models/rgb/datasets/itut_h_273.py +++ b/colour/models/rgb/datasets/itut_h_273.py @@ -18,9 +18,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/max_rgb.py b/colour/models/rgb/datasets/max_rgb.py index 5b0206faf..935652db2 100644 --- a/colour/models/rgb/datasets/max_rgb.py +++ b/colour/models/rgb/datasets/max_rgb.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/nikon_n_gamut.py b/colour/models/rgb/datasets/nikon_n_gamut.py index caad92211..90e2efa97 100644 --- a/colour/models/rgb/datasets/nikon_n_gamut.py +++ b/colour/models/rgb/datasets/nikon_n_gamut.py @@ -16,7 +16,11 @@ from __future__ import annotations -from colour.hints import NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_NLog, diff --git a/colour/models/rgb/datasets/ntsc.py b/colour/models/rgb/datasets/ntsc.py index ad52d6a7d..e2c94126c 100644 --- a/colour/models/rgb/datasets/ntsc.py +++ b/colour/models/rgb/datasets/ntsc.py @@ -22,7 +22,11 @@ from __future__ import annotations -from colour.hints import NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import RGB_Colourspace from colour.models.rgb.datasets.itur_bt_470 import ( CCS_WHITEPOINT_BT470_525, diff --git a/colour/models/rgb/datasets/p3_d65.py b/colour/models/rgb/datasets/p3_d65.py index 9fedf2e33..319a4c1ef 100644 --- a/colour/models/rgb/datasets/p3_d65.py +++ b/colour/models/rgb/datasets/p3_d65.py @@ -9,12 +9,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/pal_secam.py b/colour/models/rgb/datasets/pal_secam.py index 575c302aa..d0a172e53 100644 --- a/colour/models/rgb/datasets/pal_secam.py +++ b/colour/models/rgb/datasets/pal_secam.py @@ -17,7 +17,11 @@ from __future__ import annotations -from colour.hints import NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import RGB_Colourspace from colour.models.rgb.datasets.itur_bt_470 import ( CCS_WHITEPOINT_BT470_625, diff --git a/colour/models/rgb/datasets/panasonic_v_gamut.py b/colour/models/rgb/datasets/panasonic_v_gamut.py index c3c8c5393..171040680 100644 --- a/colour/models/rgb/datasets/panasonic_v_gamut.py +++ b/colour/models/rgb/datasets/panasonic_v_gamut.py @@ -14,10 +14,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_VLog, diff --git a/colour/models/rgb/datasets/plasa_ansi_e154.py b/colour/models/rgb/datasets/plasa_ansi_e154.py index 6e6b51554..6b6369ed3 100644 --- a/colour/models/rgb/datasets/plasa_ansi_e154.py +++ b/colour/models/rgb/datasets/plasa_ansi_e154.py @@ -19,10 +19,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/red.py b/colour/models/rgb/datasets/red.py index fa3d427f1..40c3263bb 100644 --- a/colour/models/rgb/datasets/red.py +++ b/colour/models/rgb/datasets/red.py @@ -27,10 +27,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_Log3G10, diff --git a/colour/models/rgb/datasets/rimm_romm_rgb.py b/colour/models/rgb/datasets/rimm_romm_rgb.py index 0b6f87ac3..1bc5f7208 100644 --- a/colour/models/rgb/datasets/rimm_romm_rgb.py +++ b/colour/models/rgb/datasets/rimm_romm_rgb.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, cctf_decoding_RIMMRGB, diff --git a/colour/models/rgb/datasets/russell_rgb.py b/colour/models/rgb/datasets/russell_rgb.py index 3932e3080..32e538a13 100644 --- a/colour/models/rgb/datasets/russell_rgb.py +++ b/colour/models/rgb/datasets/russell_rgb.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry.datasets import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/sharp.py b/colour/models/rgb/datasets/sharp.py index bf1b5ea1d..7d5ac33dd 100644 --- a/colour/models/rgb/datasets/sharp.py +++ b/colour/models/rgb/datasets/sharp.py @@ -22,10 +22,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, linear_function, diff --git a/colour/models/rgb/datasets/smpte_240m.py b/colour/models/rgb/datasets/smpte_240m.py index ed48a6ab8..f81c9bb78 100644 --- a/colour/models/rgb/datasets/smpte_240m.py +++ b/colour/models/rgb/datasets/smpte_240m.py @@ -17,10 +17,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, eotf_SMPTE240M, diff --git a/colour/models/rgb/datasets/smpte_c.py b/colour/models/rgb/datasets/smpte_c.py index 6a509fecf..49751535a 100644 --- a/colour/models/rgb/datasets/smpte_c.py +++ b/colour/models/rgb/datasets/smpte_c.py @@ -16,12 +16,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/datasets/sony.py b/colour/models/rgb/datasets/sony.py index 18b066c96..418393df6 100644 --- a/colour/models/rgb/datasets/sony.py +++ b/colour/models/rgb/datasets/sony.py @@ -45,10 +45,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, log_decoding_SLog2, diff --git a/colour/models/rgb/datasets/srgb.py b/colour/models/rgb/datasets/srgb.py index 3b1224beb..a8f2e3e75 100644 --- a/colour/models/rgb/datasets/srgb.py +++ b/colour/models/rgb/datasets/srgb.py @@ -23,10 +23,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import RGB_Colourspace, eotf_inverse_sRGB, eotf_sRGB __author__ = "Colour Developers" diff --git a/colour/models/rgb/datasets/xtreme_rgb.py b/colour/models/rgb/datasets/xtreme_rgb.py index 7b1cd4a55..09d6762a8 100644 --- a/colour/models/rgb/datasets/xtreme_rgb.py +++ b/colour/models/rgb/datasets/xtreme_rgb.py @@ -14,12 +14,16 @@ from __future__ import annotations +import typing from functools import partial import numpy as np from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.models.rgb import ( RGB_Colourspace, gamma_function, diff --git a/colour/models/rgb/derivation.py b/colour/models/rgb/derivation.py index ea049608d..6f83539ff 100644 --- a/colour/models/rgb/derivation.py +++ b/colour/models/rgb/derivation.py @@ -25,15 +25,20 @@ from __future__ import annotations +import typing + import numpy as np from colour.adaptation import chromatic_adaptation_VonKries -from colour.hints import ( - ArrayLike, - LiteralChromaticAdaptationTransform, - NDArrayFloat, - Tuple, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + Tuple, + ) + from colour.models import XYZ_to_xy, XYZ_to_xyY, xy_to_XYZ from colour.utilities import as_float, as_float_array, ones, tsplit diff --git a/colour/models/rgb/hanbury2003.py b/colour/models/rgb/hanbury2003.py index 8d53a3774..d1da75f06 100644 --- a/colour/models/rgb/hanbury2003.py +++ b/colour/models/rgb/hanbury2003.py @@ -17,10 +17,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( from_range_1, to_domain_1, diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 8596c4d26..4c41b8c08 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -27,16 +27,21 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ( - ArrayLike, - Literal, - LiteralChromaticAdaptationTransform, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Literal, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + ) + from colour.models.rgb import RGB_COLOURSPACES, RGB_to_XYZ, XYZ_to_RGB from colour.models.rgb.transfer_functions import ( eotf_inverse_ST2084, diff --git a/colour/models/rgb/itut_h_273.py b/colour/models/rgb/itut_h_273.py index 905caded5..82e1ecb99 100644 --- a/colour/models/rgb/itut_h_273.py +++ b/colour/models/rgb/itut_h_273.py @@ -54,13 +54,18 @@ https://www.itu.int/rec/T-REC-H.273-202107-I/en """ +from __future__ import annotations + import functools +import typing from dataclasses import dataclass from enum import IntEnum, auto import numpy as np -from colour.hints import Any, ArrayLike, Callable, Dict, NDArrayFloat, NoReturn +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Callable, Dict, NDArrayFloat, NoReturn + from colour.models.rgb.datasets.dcdm_xyz import ( CCS_WHITEPOINT_DCDM_XYZ, MATRIX_DCDM_XYZ_TO_XYZ, diff --git a/colour/models/rgb/prismatic.py b/colour/models/rgb/prismatic.py index 68c8e39ff..b09ac3da5 100644 --- a/colour/models/rgb/prismatic.py +++ b/colour/models/rgb/prismatic.py @@ -15,10 +15,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 0b0763550..017fde38d 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -25,19 +25,25 @@ from __future__ import annotations +import typing from copy import deepcopy import numpy as np from colour.adaptation import matrix_chromatic_adaptation_VonKries from colour.algebra import vecmul + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + LiteralChromaticAdaptationTransform, + LiteralRGBColourspace, + NDArrayFloat, + ) + from colour.hints import ( - Any, - ArrayLike, - Callable, - LiteralChromaticAdaptationTransform, - LiteralRGBColourspace, - NDArrayFloat, cast, ) from colour.models import xy_to_xyY, xy_to_XYZ, xyY_to_XYZ diff --git a/colour/models/rgb/transfer_functions/__init__.py b/colour/models/rgb/transfer_functions/__init__.py index 375aed9db..bf7613d3d 100644 --- a/colour/models/rgb/transfer_functions/__init__.py +++ b/colour/models/rgb/transfer_functions/__init__.py @@ -4,22 +4,26 @@ from functools import partial -from colour.hints import ( - Any, - ArrayLike, - NDArrayFloat, - NDArrayInt, - LiteralLogEncoding, - LiteralLogDecoding, - LiteralOETF, - LiteralOETFInverse, - LiteralEOTF, - LiteralEOTFInverse, - LiteralCCTFEncoding, - LiteralCCTFDecoding, - LiteralOOTF, - LiteralOOTFInverse, -) +import typing + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + NDArrayFloat, + NDArrayInt, + LiteralLogEncoding, + LiteralLogDecoding, + LiteralOETF, + LiteralOETFInverse, + LiteralEOTF, + LiteralEOTFInverse, + LiteralCCTFEncoding, + LiteralCCTFDecoding, + LiteralOOTF, + LiteralOOTFInverse, + ) + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index 21ab17363..d28c23a5f 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -49,9 +49,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat, NDArrayInt +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat, NDArrayInt + from colour.utilities import ( Structure, as_float, diff --git a/colour/models/rgb/transfer_functions/apple_log_profile.py b/colour/models/rgb/transfer_functions/apple_log_profile.py index e1b6448b8..92d979927 100644 --- a/colour/models/rgb/transfer_functions/apple_log_profile.py +++ b/colour/models/rgb/transfer_functions/apple_log_profile.py @@ -22,9 +22,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import Structure, as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/arib_std_b67.py b/colour/models/rgb/transfer_functions/arib_std_b67.py index cd95bd962..990836e0b 100644 --- a/colour/models/rgb/transfer_functions/arib_std_b67.py +++ b/colour/models/rgb/transfer_functions/arib_std_b67.py @@ -19,9 +19,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import gamma_function from colour.utilities import ( Structure, diff --git a/colour/models/rgb/transfer_functions/arri.py b/colour/models/rgb/transfer_functions/arri.py index 5da6b97af..225e87874 100644 --- a/colour/models/rgb/transfer_functions/arri.py +++ b/colour/models/rgb/transfer_functions/arri.py @@ -21,9 +21,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, Structure, diff --git a/colour/models/rgb/transfer_functions/blackmagic_design.py b/colour/models/rgb/transfer_functions/blackmagic_design.py index 42e0c01aa..5b83f9963 100644 --- a/colour/models/rgb/transfer_functions/blackmagic_design.py +++ b/colour/models/rgb/transfer_functions/blackmagic_design.py @@ -16,9 +16,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import Structure, as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/canon.py b/colour/models/rgb/transfer_functions/canon.py index f0878177a..dd7ade8f4 100644 --- a/colour/models/rgb/transfer_functions/canon.py +++ b/colour/models/rgb/transfer_functions/canon.py @@ -41,9 +41,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import ( CanonicalMapping, diff --git a/colour/models/rgb/transfer_functions/cineon.py b/colour/models/rgb/transfer_functions/cineon.py index db81e5f4b..703c97548 100644 --- a/colour/models/rgb/transfer_functions/cineon.py +++ b/colour/models/rgb/transfer_functions/cineon.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float, as_float_array, diff --git a/colour/models/rgb/transfer_functions/common.py b/colour/models/rgb/transfer_functions/common.py index 3293bdc26..91348c232 100644 --- a/colour/models/rgb/transfer_functions/common.py +++ b/colour/models/rgb/transfer_functions/common.py @@ -7,9 +7,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayReal +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayReal + from colour.utilities import as_float, as_float_array, as_int, as_int_array __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/davinci_intermediate.py b/colour/models/rgb/transfer_functions/davinci_intermediate.py index 5f8592069..8732fcb36 100644 --- a/colour/models/rgb/transfer_functions/davinci_intermediate.py +++ b/colour/models/rgb/transfer_functions/davinci_intermediate.py @@ -18,9 +18,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import Structure, as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/dcdm.py b/colour/models/rgb/transfer_functions/dcdm.py index c54b48550..b8ed2e9d7 100644 --- a/colour/models/rgb/transfer_functions/dcdm.py +++ b/colour/models/rgb/transfer_functions/dcdm.py @@ -21,10 +21,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal + from colour.utilities import as_float, as_float_array, as_int __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/dicom_gsdf.py b/colour/models/rgb/transfer_functions/dicom_gsdf.py index 51fddd397..d82822b76 100644 --- a/colour/models/rgb/transfer_functions/dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/dicom_gsdf.py @@ -25,9 +25,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal + from colour.utilities import ( Structure, as_float, diff --git a/colour/models/rgb/transfer_functions/dji_d_log.py b/colour/models/rgb/transfer_functions/dji_d_log.py index d1add186a..aca536759 100644 --- a/colour/models/rgb/transfer_functions/dji_d_log.py +++ b/colour/models/rgb/transfer_functions/dji_d_log.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/exponent.py b/colour/models/rgb/transfer_functions/exponent.py index 3f3744830..6e584f39c 100644 --- a/colour/models/rgb/transfer_functions/exponent.py +++ b/colour/models/rgb/transfer_functions/exponent.py @@ -18,8 +18,13 @@ from __future__ import annotations +import typing + from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( as_float, as_float_array, diff --git a/colour/models/rgb/transfer_functions/filmic_pro.py b/colour/models/rgb/transfer_functions/filmic_pro.py index 8f9df6c71..7eda6d8e7 100644 --- a/colour/models/rgb/transfer_functions/filmic_pro.py +++ b/colour/models/rgb/transfer_functions/filmic_pro.py @@ -15,10 +15,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import Extrapolator, LinearInterpolator -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/filmlight_t_log.py b/colour/models/rgb/transfer_functions/filmlight_t_log.py index 13da6b24e..f6ac1aa61 100644 --- a/colour/models/rgb/transfer_functions/filmlight_t_log.py +++ b/colour/models/rgb/transfer_functions/filmlight_t_log.py @@ -15,9 +15,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/fujifilm_f_log.py b/colour/models/rgb/transfer_functions/fujifilm_f_log.py index 7cdbf1f22..a6a41b3dc 100644 --- a/colour/models/rgb/transfer_functions/fujifilm_f_log.py +++ b/colour/models/rgb/transfer_functions/fujifilm_f_log.py @@ -19,9 +19,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index 1b7455920..9438ad33b 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -10,10 +10,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.utilities import as_float, as_float_array, validate_method __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/gopro.py b/colour/models/rgb/transfer_functions/gopro.py index 5dd4db73f..6e3b86319 100644 --- a/colour/models/rgb/transfer_functions/gopro.py +++ b/colour/models/rgb/transfer_functions/gopro.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itur_bt_1361.py b/colour/models/rgb/transfer_functions/itur_bt_1361.py index 65be8b234..d19afc817 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1361.py @@ -19,10 +19,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import oetf_BT709, oetf_inverse_BT709 from colour.utilities import ( as_float, diff --git a/colour/models/rgb/transfer_functions/itur_bt_1886.py b/colour/models/rgb/transfer_functions/itur_bt_1886.py index 8011c0dd9..f08683820 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1886.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itur_bt_2020.py b/colour/models/rgb/transfer_functions/itur_bt_2020.py index d33ec8f64..80a6c078d 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2020.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( Structure, as_float, diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 237560766..63eda9e23 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -53,10 +53,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models.rgb.transfer_functions import ( eotf_BT1886, eotf_inverse_BT1886, diff --git a/colour/models/rgb/transfer_functions/itur_bt_601.py b/colour/models/rgb/transfer_functions/itur_bt_601.py index f64f24a87..e1467e1a2 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/itur_bt_601.py @@ -20,10 +20,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/itur_bt_709.py b/colour/models/rgb/transfer_functions/itur_bt_709.py index e5fd8b86c..eb2271704 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_709.py +++ b/colour/models/rgb/transfer_functions/itur_bt_709.py @@ -20,7 +20,11 @@ from __future__ import annotations -from colour.hints import ArrayLike, NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import oetf_BT601, oetf_inverse_BT601 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itut_h_273.py b/colour/models/rgb/transfer_functions/itut_h_273.py index c7c1512c3..f8cd4f307 100644 --- a/colour/models/rgb/transfer_functions/itut_h_273.py +++ b/colour/models/rgb/transfer_functions/itut_h_273.py @@ -27,10 +27,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import ( eotf_DCDM, eotf_inverse_DCDM, diff --git a/colour/models/rgb/transfer_functions/leica_l_log.py b/colour/models/rgb/transfer_functions/leica_l_log.py index 1322f3f51..1ab12234c 100644 --- a/colour/models/rgb/transfer_functions/leica_l_log.py +++ b/colour/models/rgb/transfer_functions/leica_l_log.py @@ -16,10 +16,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/linear.py b/colour/models/rgb/transfer_functions/linear.py index 16d3791e4..32d714dae 100644 --- a/colour/models/rgb/transfer_functions/linear.py +++ b/colour/models/rgb/transfer_functions/linear.py @@ -10,7 +10,11 @@ from __future__ import annotations -from colour.hints import ArrayLike, NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index 32f351abc..6ee2a0c43 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -37,13 +37,20 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Literal, + NDArrayFloat, + ) + from colour.hints import ( - ArrayLike, - Literal, - NDArrayFloat, cast, ) from colour.utilities import ( diff --git a/colour/models/rgb/transfer_functions/nikon_n_log.py b/colour/models/rgb/transfer_functions/nikon_n_log.py index 833456e2c..70d7f45f3 100644 --- a/colour/models/rgb/transfer_functions/nikon_n_log.py +++ b/colour/models/rgb/transfer_functions/nikon_n_log.py @@ -17,10 +17,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/panalog.py b/colour/models/rgb/transfer_functions/panalog.py index 3da6ad059..878fd3148 100644 --- a/colour/models/rgb/transfer_functions/panalog.py +++ b/colour/models/rgb/transfer_functions/panalog.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float, as_float_array, diff --git a/colour/models/rgb/transfer_functions/panasonic_v_log.py b/colour/models/rgb/transfer_functions/panasonic_v_log.py index 255a7f6ad..d95494545 100644 --- a/colour/models/rgb/transfer_functions/panasonic_v_log.py +++ b/colour/models/rgb/transfer_functions/panasonic_v_log.py @@ -16,9 +16,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import Structure, as_float, from_range_1, to_domain_1 diff --git a/colour/models/rgb/transfer_functions/pivoted_log.py b/colour/models/rgb/transfer_functions/pivoted_log.py index 054676986..564ea34db 100644 --- a/colour/models/rgb/transfer_functions/pivoted_log.py +++ b/colour/models/rgb/transfer_functions/pivoted_log.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/red.py b/colour/models/rgb/transfer_functions/red.py index a3b8fadbf..c1b6111a4 100644 --- a/colour/models/rgb/transfer_functions/red.py +++ b/colour/models/rgb/transfer_functions/red.py @@ -36,9 +36,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, Literal, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models.rgb.transfer_functions import ( log_decoding_Cineon, log_encoding_Cineon, diff --git a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py index 375e3ddbf..6f15079e4 100644 --- a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py @@ -25,10 +25,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal + from colour.utilities import ( as_float, as_float_scalar, diff --git a/colour/models/rgb/transfer_functions/smpte_240m.py b/colour/models/rgb/transfer_functions/smpte_240m.py index 86cbc0a96..79ae66afd 100644 --- a/colour/models/rgb/transfer_functions/smpte_240m.py +++ b/colour/models/rgb/transfer_functions/smpte_240m.py @@ -19,10 +19,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/sony.py b/colour/models/rgb/transfer_functions/sony.py index 876d315c5..0c10b4ab4 100644 --- a/colour/models/rgb/transfer_functions/sony.py +++ b/colour/models/rgb/transfer_functions/sony.py @@ -24,12 +24,16 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ( - ArrayLike, - NDArrayFloat, -) +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + NDArrayFloat, + ) + from colour.models.rgb.transfer_functions import full_to_legal, legal_to_full from colour.utilities import ( as_float, diff --git a/colour/models/rgb/transfer_functions/srgb.py b/colour/models/rgb/transfer_functions/srgb.py index 76db90d0f..3db8ffc5c 100644 --- a/colour/models/rgb/transfer_functions/srgb.py +++ b/colour/models/rgb/transfer_functions/srgb.py @@ -25,10 +25,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( as_float, domain_range_scale, diff --git a/colour/models/rgb/transfer_functions/st_2084.py b/colour/models/rgb/transfer_functions/st_2084.py index 4c8297383..8e0a905bc 100644 --- a/colour/models/rgb/transfer_functions/st_2084.py +++ b/colour/models/rgb/transfer_functions/st_2084.py @@ -22,10 +22,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import spow -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import Structure, as_float, as_float_array __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/viper_log.py b/colour/models/rgb/transfer_functions/viper_log.py index ca0899903..d4dc6867a 100644 --- a/colour/models/rgb/transfer_functions/viper_log.py +++ b/colour/models/rgb/transfer_functions/viper_log.py @@ -17,9 +17,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, from_range_1, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index bb7e72e83..31a69a659 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -53,9 +53,14 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import Any, ArrayLike, NDArrayFloat, NDArrayReal, cast +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, NDArrayReal + +from colour.hints import NDArrayFloat, cast from colour.models.rgb.transfer_functions import ( CV_range, oetf_BT2020, diff --git a/colour/models/rgb/ycocg.py b/colour/models/rgb/ycocg.py index 63b4b4975..84c322d98 100644 --- a/colour/models/rgb/ycocg.py +++ b/colour/models/rgb/ycocg.py @@ -17,10 +17,14 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/yrg.py b/colour/models/yrg.py index ac1cfbd96..c77e3ba0b 100644 --- a/colour/models/yrg.py +++ b/colour/models/yrg.py @@ -18,10 +18,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode, vecmul -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import ( from_range_1, to_domain_1, diff --git a/colour/notation/css_color_3.py b/colour/notation/css_color_3.py index 5575c3590..9e43f6fda 100644 --- a/colour/notation/css_color_3.py +++ b/colour/notation/css_color_3.py @@ -14,7 +14,11 @@ from __future__ import annotations -from colour.hints import NDArrayFloat +import typing + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.notation import CSS_COLOR_3, HEX_to_RGB from colour.utilities import attest diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 25b72ad47..08106f7c1 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -10,10 +10,15 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import normalise_maximum -from colour.hints import ArrayLike, NDArrayFloat, NDArrayStr + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat, NDArrayStr + from colour.models import eotf_inverse_sRGB, eotf_sRGB from colour.utilities import ( as_float_array, diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 7ceb90dea..79bcc7610 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -115,6 +115,7 @@ from __future__ import annotations import re +import typing import numpy as np @@ -135,13 +136,18 @@ TOLERANCE_ABSOLUTE_DEFAULT, TOLERANCE_RELATIVE_DEFAULT, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Dict, + Literal, + NDArrayFloat, + NDArrayStr, + Tuple, + ) + from colour.hints import ( ArrayLike, - Dict, - Literal, - NDArrayFloat, - NDArrayStr, - Tuple, cast, ) from colour.models import Lab_to_LCHab # pyright: ignore diff --git a/colour/notation/tests/test_munsell.py b/colour/notation/tests/test_munsell.py index 826673518..d398997a9 100644 --- a/colour/notation/tests/test_munsell.py +++ b/colour/notation/tests/test_munsell.py @@ -3,13 +3,17 @@ from __future__ import annotations import contextlib +import typing from itertools import product import numpy as np import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.notation import ( munsell_value_ASTMD1535, munsell_value_Ladd1955, diff --git a/colour/phenomena/rayleigh.py b/colour/phenomena/rayleigh.py index 00e560427..60ddfe527 100644 --- a/colour/phenomena/rayleigh.py +++ b/colour/phenomena/rayleigh.py @@ -20,6 +20,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode @@ -29,7 +31,10 @@ SpectralShape, ) from colour.constants import CONSTANT_AVOGADRO -from colour.hints import ArrayLike, Callable, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Callable, NDArrayFloat + from colour.utilities import as_float, as_float_array, filter_kwargs __author__ = "Colour Developers" diff --git a/colour/plotting/blindness.py b/colour/plotting/blindness.py index 93d4ee77a..fe7576074 100644 --- a/colour/plotting/blindness.py +++ b/colour/plotting/blindness.py @@ -9,18 +9,24 @@ from __future__ import annotations -from matplotlib.axes import Axes -from matplotlib.figure import Figure +import typing + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes from colour.algebra import vecmul from colour.blindness import matrix_cvd_Machado2009 -from colour.hints import ( - Any, - ArrayLike, - Dict, - Literal, - Tuple, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Dict, + Literal, + Tuple, + ) + from colour.plotting import CONSTANTS_COLOUR_STYLE, override_style, plot_image from colour.utilities import optional diff --git a/colour/plotting/characterisation.py b/colour/plotting/characterisation.py index e91f048ba..aee3b2f33 100644 --- a/colour/plotting/characterisation.py +++ b/colour/plotting/characterisation.py @@ -10,12 +10,18 @@ from __future__ import annotations +import typing + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes + import numpy as np -from matplotlib.axes import Axes -from matplotlib.figure import Figure -from colour.characterisation import ColourChecker -from colour.hints import Any, Dict, Sequence, Tuple +if typing.TYPE_CHECKING: + from colour.characterisation import ColourChecker + from colour.hints import Any, Dict, Sequence, Tuple + from colour.models import xyY_to_XYZ from colour.plotting import ( CONSTANTS_COLOUR_STYLE, diff --git a/colour/plotting/colorimetry.py b/colour/plotting/colorimetry.py index 827c1675b..07826c5f4 100644 --- a/colour/plotting/colorimetry.py +++ b/colour/plotting/colorimetry.py @@ -26,15 +26,21 @@ from __future__ import annotations -from collections.abc import ValuesView +import typing from functools import reduce import matplotlib.pyplot as plt import numpy as np -from matplotlib.axes import Axes -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from collections.abc import ValuesView + from matplotlib.patches import Polygon +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes + from colour.algebra import ( LinearInterpolator, normalise_maximum, @@ -55,13 +61,18 @@ sds_and_msds_to_sds, wavelength_to_XYZ, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + Dict, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, - Callable, - Dict, List, - Sequence, - Tuple, cast, ) from colour.plotting import ( diff --git a/colour/plotting/common.py b/colour/plotting/common.py index 1aef7a8fa..ebe523632 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -30,10 +30,10 @@ import contextlib import functools import itertools +import typing from contextlib import contextmanager from dataclasses import dataclass, field from functools import partial -from pathlib import Path import matplotlib.cm import matplotlib.font_manager @@ -44,9 +44,15 @@ from matplotlib.axes import Axes from matplotlib.colors import LinearSegmentedColormap from matplotlib.figure import Figure, SubFigure -from matplotlib.patches import Patch + +if typing.TYPE_CHECKING: + from matplotlib.patches import Patch + from mpl_toolkits.mplot3d.axes3d import Axes3D +if typing.TYPE_CHECKING: + from pathlib import Path + from colour.characterisation import CCS_COLOURCHECKERS, ColourChecker from colour.colorimetry import ( MSDS_CMFS, @@ -55,22 +61,27 @@ MultiSpectralDistributions, SpectralDistribution, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + Dict, + Generator, + Literal, + LiteralChromaticAdaptationTransform, + LiteralFontScaling, + LiteralRGBColourspace, + Mapping, + NDArrayFloat, + Real, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, ArrayLike, - Callable, - Dict, - Generator, List, - Literal, - LiteralChromaticAdaptationTransform, - LiteralFontScaling, - LiteralRGBColourspace, - Mapping, - NDArrayFloat, - Real, - Sequence, - Tuple, TypedDict, cast, ) diff --git a/colour/plotting/corresponding.py b/colour/plotting/corresponding.py index 23445ecea..88f3eed3d 100644 --- a/colour/plotting/corresponding.py +++ b/colour/plotting/corresponding.py @@ -9,14 +9,21 @@ from __future__ import annotations -from matplotlib.axes import Axes -from matplotlib.figure import Figure +import typing + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes from colour.corresponding import ( CorrespondingColourDataset, corresponding_chromaticities_prediction, ) -from colour.hints import Any, Dict, Literal, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import Any, Dict, Literal, Tuple + +from colour.hints import cast from colour.plotting import ( CONSTANTS_COLOUR_STYLE, artist, diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index c5f2d4231..ec8cb87d0 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -16,12 +16,21 @@ from __future__ import annotations import bisect -from collections.abc import ValuesView +import typing import numpy as np -from matplotlib.axes import Axes + +if typing.TYPE_CHECKING: + from collections.abc import ValuesView + +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.collections import LineCollection -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.patches import Polygon from colour.algebra import normalise_maximum, normalise_vector @@ -33,15 +42,20 @@ sds_and_msds_to_sds, ) from colour.constants import DTYPE_FLOAT_DEFAULT + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + Dict, + List, + Literal, + NDArray, + Sequence, + ) + from colour.hints import ( - Any, - ArrayLike, - Callable, - Dict, - List, - Literal, - NDArray, - Sequence, Tuple, cast, ) diff --git a/colour/plotting/graph.py b/colour/plotting/graph.py index cef68605e..3e0a5d728 100644 --- a/colour/plotting/graph.py +++ b/colour/plotting/graph.py @@ -10,13 +10,18 @@ from __future__ import annotations import os +import typing import colour from colour.graph import ( CONVERSION_GRAPH_NODE_LABELS, describe_conversion_path, ) -from colour.hints import Literal, cast + +if typing.TYPE_CHECKING: + from colour.hints import Literal + +from colour.hints import cast from colour.utilities import required, validate_method __author__ = "Colour Developers" diff --git a/colour/plotting/models.py b/colour/plotting/models.py index e2e256543..732535f12 100644 --- a/colour/plotting/models.py +++ b/colour/plotting/models.py @@ -43,11 +43,11 @@ from __future__ import annotations +import typing + import numpy as np import scipy.optimize -from matplotlib.axes import Axes from matplotlib.collections import LineCollection -from matplotlib.figure import Figure from matplotlib.patches import Ellipse from matplotlib.path import Path @@ -61,19 +61,26 @@ point_at_angle_on_ellipse, ) from colour.graph import convert + +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.figure import Figure + from colour.hints import ( + Any, + ArrayLike, + Callable, + Dict, + Literal, + LiteralColourspaceModel, + LiteralRGBColourspace, + NDArray, + NDArrayFloat, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, - ArrayLike, - Callable, - Dict, List, - Literal, - LiteralColourspaceModel, - LiteralRGBColourspace, - NDArray, - NDArrayFloat, - Sequence, - Tuple, cast, ) from colour.models import LCHab_to_Lab # pyright: ignore diff --git a/colour/plotting/notation.py b/colour/plotting/notation.py index 337a7f0f9..fb0ad8230 100644 --- a/colour/plotting/notation.py +++ b/colour/plotting/notation.py @@ -10,11 +10,17 @@ from __future__ import annotations +import typing + import numpy as np -from matplotlib.axes import Axes -from matplotlib.figure import Figure -from colour.hints import Any, Callable, Dict, Sequence, Tuple +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from colour.hints import Any, Callable, Dict, Sequence, Tuple + from colour.notation import MUNSELL_VALUE_METHODS from colour.plotting import ( filter_passthrough, diff --git a/colour/plotting/phenomena.py b/colour/plotting/phenomena.py index c7caf3288..b71da1501 100644 --- a/colour/plotting/phenomena.py +++ b/colour/plotting/phenomena.py @@ -10,16 +10,24 @@ from __future__ import annotations +import typing + import matplotlib.pyplot as plt -from matplotlib.axes import Axes -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes from colour.algebra import normalise_maximum from colour.colorimetry import ( MultiSpectralDistributions, sd_to_XYZ, ) -from colour.hints import Any, ArrayLike, Dict, Sequence, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Dict, Sequence, Tuple + +from colour.hints import cast from colour.phenomena import sd_rayleigh_scattering from colour.phenomena.rayleigh import ( CONSTANT_AVERAGE_PRESSURE_MEAN_SEA_LEVEL, diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index 5bc3af990..3ad36d749 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -12,12 +12,18 @@ from __future__ import annotations -from collections.abc import ValuesView +import typing + +if typing.TYPE_CHECKING: + from collections.abc import ValuesView + from itertools import cycle +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes + import numpy as np -from matplotlib.axes import Axes -from matplotlib.figure import Figure from colour.colorimetry import ( MultiSpectralDistributions, @@ -25,13 +31,18 @@ sds_and_msds_to_sds, ) from colour.constants import DTYPE_FLOAT_DEFAULT + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Dict, + Literal, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, - Dict, List, - Literal, - Sequence, - Tuple, cast, ) from colour.plotting import ( diff --git a/colour/plotting/section.py b/colour/plotting/section.py index 850529ab6..ffb182109 100644 --- a/colour/plotting/section.py +++ b/colour/plotting/section.py @@ -12,10 +12,18 @@ from __future__ import annotations +import typing + import numpy as np -from matplotlib.axes import Axes + +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.collections import LineCollection -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.patches import Polygon from colour.colorimetry import ( @@ -26,16 +34,21 @@ ) from colour.geometry import hull_section, primitive_cube from colour.graph import convert + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Dict, + Literal, + LiteralColourspaceModel, + LiteralRGBColourspace, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, - ArrayLike, - Dict, - Literal, - LiteralColourspaceModel, - LiteralRGBColourspace, Real, - Sequence, - Tuple, cast, ) from colour.models import ( diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index b7bd5d12e..b2022c3cd 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -17,25 +17,37 @@ from __future__ import annotations +import typing + import numpy as np -from matplotlib.axes import Axes + +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.collections import LineCollection -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure from colour.algebra import normalise_maximum, normalise_vector from colour.colorimetry import CCS_ILLUMINANTS, MSDS_CMFS from colour.constants import DTYPE_FLOAT_DEFAULT + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + Dict, + List, + Literal, + NDArray, + NDArrayFloat, + Sequence, + Tuple, + ) + from colour.hints import ( - Any, - ArrayLike, - Callable, - Dict, - List, - Literal, - NDArray, - NDArrayFloat, - Sequence, - Tuple, cast, ) from colour.models import ( diff --git a/colour/plotting/tm3018/components.py b/colour/plotting/tm3018/components.py index af91aae3a..8ce3479a7 100644 --- a/colour/plotting/tm3018/components.py +++ b/colour/plotting/tm3018/components.py @@ -17,15 +17,23 @@ from __future__ import annotations import os +import typing import numpy as np -from matplotlib.axes import Axes -from matplotlib.figure import Figure + +if typing.TYPE_CHECKING: + from matplotlib.axes import Axes + from matplotlib.figure import Figure + from matplotlib.patches import Circle from colour.algebra import sdiv, sdiv_mode from colour.colorimetry import sd_to_XYZ -from colour.hints import Any, ArrayLike, Dict, Literal, Tuple + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, Dict, Literal, Tuple + from colour.quality import ColourQuality_Specification_ANSIIESTM3018 + from colour.io import read_image from colour.plotting import ( CONSTANTS_COLOUR_STYLE, @@ -34,7 +42,6 @@ plot_image, render, ) -from colour.quality import ColourQuality_Specification_ANSIIESTM3018 from colour.utilities import as_float_array, validate_method __author__ = "Colour Developers" diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index 5c136b617..47718e188 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -14,12 +14,20 @@ from __future__ import annotations +import typing + +if typing.TYPE_CHECKING: + from matplotlib.figure import Figure + from matplotlib.axes import Axes + import matplotlib.pyplot as plt -from matplotlib.axes import Axes -from matplotlib.figure import Figure from colour.colorimetry import SpectralDistribution, sd_to_XYZ -from colour.hints import Any, Dict, Literal, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import Any, Dict, Literal, Tuple + +from colour.hints import cast from colour.io import SpectralDistribution_IESTM2714 from colour.models import Luv_to_uv, XYZ_to_Luv, XYZ_to_xy from colour.plotting import CONSTANTS_COLOUR_STYLE, override_style, render diff --git a/colour/plotting/volume.py b/colour/plotting/volume.py index 6f30461d5..67e30c39e 100644 --- a/colour/plotting/volume.py +++ b/colour/plotting/volume.py @@ -10,6 +10,8 @@ from __future__ import annotations +import typing + import matplotlib.pyplot as plt import numpy as np from matplotlib.figure import Figure @@ -23,14 +25,19 @@ primitive_vertices_grid_mpl, ) from colour.graph import convert + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + LiteralColourspaceModel, + LiteralRGBColourspace, + NDArrayFloat, + ) + from colour.hints import ( - Any, - ArrayLike, List, - Literal, - LiteralColourspaceModel, - LiteralRGBColourspace, - NDArrayFloat, Sequence, Tuple, cast, diff --git a/colour/quality/__init__.py b/colour/quality/__init__.py index ed72189f7..00f801ec2 100644 --- a/colour/quality/__init__.py +++ b/colour/quality/__init__.py @@ -2,8 +2,11 @@ from __future__ import annotations -from colour.colorimetry import SpectralDistribution -from colour.hints import Literal +import typing + +if typing.TYPE_CHECKING: + from colour.colorimetry import SpectralDistribution + from colour.hints import Literal from .datasets import * # noqa: F403 from . import datasets diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index bc0000b90..56338dcbf 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -16,6 +16,7 @@ from __future__ import annotations import os +import typing from dataclasses import dataclass import numpy as np @@ -37,7 +38,11 @@ sd_CIE_illuminant_D_series, sd_to_XYZ, ) -from colour.hints import ArrayLike, List, NDArrayFloat, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, List, Tuple + +from colour.hints import NDArrayFloat, 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 ( diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 4214cd7ad..468bd2f64 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -23,6 +23,7 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np @@ -41,12 +42,17 @@ sd_CIE_illuminant_D_series, sd_to_XYZ, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Dict, + Literal, + NDArrayFloat, + Tuple, + ) + from colour.hints import ( - ArrayLike, - Dict, - Literal, - NDArrayFloat, - Tuple, cast, ) from colour.models import Lab_to_LCHab # pyright: ignore diff --git a/colour/quality/cri.py b/colour/quality/cri.py index dfc571c58..ed66b8fc1 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -17,6 +17,7 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np @@ -33,7 +34,11 @@ sd_CIE_illuminant_D_series, sd_to_XYZ, ) -from colour.hints import Dict, NDArrayFloat, Tuple, cast + +if typing.TYPE_CHECKING: + from colour.hints import Dict, NDArrayFloat, Tuple + +from colour.hints import cast from colour.models import UCS_to_uv, XYZ_to_UCS, XYZ_to_xyY from colour.quality.datasets.tcs import INDEXES_TO_NAMES_TCS, SDS_TCS from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Robertson1968 diff --git a/colour/quality/ssi.py b/colour/quality/ssi.py index 1a9b8f3ed..4394e121f 100644 --- a/colour/quality/ssi.py +++ b/colour/quality/ssi.py @@ -16,12 +16,17 @@ from __future__ import annotations +import typing + import numpy as np from scipy.ndimage import convolve1d from colour.algebra import LinearInterpolator, sdiv, sdiv_mode from colour.colorimetry import SpectralDistribution, SpectralShape, reshape_sd -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import zeros __author__ = "Colour Developers" diff --git a/colour/quality/tm3018.py b/colour/quality/tm3018.py index 5bb2de7e8..fcb5c2279 100644 --- a/colour/quality/tm3018.py +++ b/colour/quality/tm3018.py @@ -19,12 +19,16 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np -from colour.colorimetry import SpectralDistribution -from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple, cast +if typing.TYPE_CHECKING: + from colour.colorimetry import SpectralDistribution + from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple + +from colour.hints import cast from colour.quality import colour_fidelity_index_CIE2017 from colour.quality.cfi2017 import ( ColourRendering_Specification_CIE2017, diff --git a/colour/recovery/__init__.py b/colour/recovery/__init__.py index 4d4659d36..abf9295b1 100644 --- a/colour/recovery/__init__.py +++ b/colour/recovery/__init__.py @@ -22,8 +22,12 @@ from __future__ import annotations -from colour.colorimetry import SpectralDistribution -from colour.hints import Any, ArrayLike, Literal +import typing + +if typing.TYPE_CHECKING: + from colour.colorimetry import SpectralDistribution + from colour.hints import Any, ArrayLike, Literal + from colour.utilities import ( CanonicalMapping, as_float_array, diff --git a/colour/recovery/datasets/dyer2017.py b/colour/recovery/datasets/dyer2017.py index 2720bc1cb..4ece07b07 100644 --- a/colour/recovery/datasets/dyer2017.py +++ b/colour/recovery/datasets/dyer2017.py @@ -13,10 +13,14 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import SpectralShape -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/recovery/datasets/mallett2019.py b/colour/recovery/datasets/mallett2019.py index 9effc2a89..bb574f98a 100644 --- a/colour/recovery/datasets/mallett2019.py +++ b/colour/recovery/datasets/mallett2019.py @@ -14,10 +14,14 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import MultiSpectralDistributions, SpectralShape -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/recovery/datasets/otsu2018.py b/colour/recovery/datasets/otsu2018.py index e9dc0bce8..4e8fc5331 100644 --- a/colour/recovery/datasets/otsu2018.py +++ b/colour/recovery/datasets/otsu2018.py @@ -14,10 +14,14 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import SpectralShape -from colour.hints import NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 0d58921aa..4c61a44e1 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -20,9 +20,13 @@ from __future__ import annotations import struct -from pathlib import Path +import typing import numpy as np + +if typing.TYPE_CHECKING: + from pathlib import Path + from scipy.interpolate import RegularGridInterpolator from scipy.optimize import minimize @@ -37,12 +41,15 @@ ) from colour.constants import DTYPE_INT_DEFAULT from colour.difference import JND_CIE1976 -from colour.hints import ( - ArrayLike, - Callable, - NDArrayFloat, - Tuple, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Callable, + NDArrayFloat, + Tuple, + ) + from colour.models import RGB_Colourspace, RGB_to_XYZ, XYZ_to_Lab, XYZ_to_xy from colour.utilities import ( as_float_array, diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index 99c117b4b..cd45113ce 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -19,6 +19,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import eigen_decomposition @@ -30,11 +32,16 @@ reshape_msds, reshape_sd, ) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Mapping, + NDArrayFloat, + Tuple, + ) + from colour.hints import ( - ArrayLike, - Mapping, - NDArrayFloat, - Tuple, cast, ) from colour.recovery import BASIS_FUNCTIONS_DYER2017 diff --git a/colour/recovery/mallett2019.py b/colour/recovery/mallett2019.py index 78c359eec..3ec50a4cc 100644 --- a/colour/recovery/mallett2019.py +++ b/colour/recovery/mallett2019.py @@ -17,6 +17,8 @@ from __future__ import annotations +import typing + import numpy as np from scipy.linalg import block_diag from scipy.optimize import Bounds, LinearConstraint, minimize @@ -26,8 +28,11 @@ SpectralDistribution, handle_spectral_arguments, ) -from colour.hints import ArrayLike, Callable -from colour.models import RGB_Colourspace + +if typing.TYPE_CHECKING: + from colour.models import RGB_Colourspace + from colour.hints import ArrayLike, Callable + from colour.recovery import MSDS_BASIS_FUNCTIONS_sRGB_MALLETT2019 from colour.utilities import to_domain_1 diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 6e9542b4f..89aefaf1e 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -16,6 +16,8 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize @@ -27,7 +29,11 @@ sd_ones, sd_to_XYZ_integration, ) -from colour.hints import ArrayLike, NDArrayFloat, cast + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike + +from colour.hints import NDArrayFloat, cast from colour.utilities import from_range_100, to_domain_1 __author__ = "Colour Developers" diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index fe5f49aed..a6a877d26 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -18,8 +18,11 @@ from __future__ import annotations +import typing from dataclasses import dataclass -from pathlib import Path + +if typing.TYPE_CHECKING: + from pathlib import Path import numpy as np @@ -33,17 +36,19 @@ reshape_msds, sd_to_XYZ, ) -from colour.hints import ( - Any, - ArrayLike, - Callable, - Dict, - NDArrayFloat, - Self, - Sequence, - Tuple, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Callable, + Dict, + Self, + Sequence, + Tuple, + ) + +from colour.hints import NDArrayFloat, cast from colour.models import XYZ_to_xy from colour.recovery import ( BASIS_FUNCTIONS_OTSU2018, diff --git a/colour/recovery/smits1999.py b/colour/recovery/smits1999.py index 4759d6dfc..d0ec14213 100644 --- a/colour/recovery/smits1999.py +++ b/colour/recovery/smits1999.py @@ -13,8 +13,13 @@ from __future__ import annotations +import typing + from colour.colorimetry import CCS_ILLUMINANTS, SpectralDistribution -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import ( RGB_Colourspace, RGB_COLOURSPACE_sRGB, diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index 105b19585..cd3c0c0ce 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -5,6 +5,7 @@ import os import shutil import tempfile +import typing import numpy as np import pytest @@ -13,7 +14,10 @@ from colour.colorimetry import handle_spectral_arguments, sd_to_XYZ from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.difference import JND_CIE1976, delta_E_CIE1976 -from colour.hints import Type + +if typing.TYPE_CHECKING: + from colour.hints import Type + from colour.models import ( RGB_COLOURSPACE_sRGB, RGB_to_XYZ, diff --git a/colour/temperature/__init__.py b/colour/temperature/__init__.py index c54661a0d..5dc136d7a 100644 --- a/colour/temperature/__init__.py +++ b/colour/temperature/__init__.py @@ -43,7 +43,11 @@ from __future__ import annotations -from colour.hints import Any, ArrayLike, NDArrayFloat, Literal +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any, ArrayLike, NDArrayFloat, Literal + from colour.utilities import ( CanonicalMapping, filter_kwargs, diff --git a/colour/temperature/cie_d.py b/colour/temperature/cie_d.py index 4b4216553..574fa5eca 100644 --- a/colour/temperature/cie_d.py +++ b/colour/temperature/cie_d.py @@ -22,11 +22,16 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize from colour.colorimetry import daylight_locus_function -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tstack, usage_warning __author__ = "Colour Developers" diff --git a/colour/temperature/hernandez1999.py b/colour/temperature/hernandez1999.py index bb400d4da..43a0e6f3b 100644 --- a/colour/temperature/hernandez1999.py +++ b/colour/temperature/hernandez1999.py @@ -22,12 +22,17 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize from colour.algebra import sdiv, sdiv_mode from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tsplit, usage_warning __author__ = "Colour Developers" diff --git a/colour/temperature/kang2002.py b/colour/temperature/kang2002.py index 0dc76c25b..e60c852af 100644 --- a/colour/temperature/kang2002.py +++ b/colour/temperature/kang2002.py @@ -21,10 +21,14 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tstack, usage_warning __author__ = "Colour Developers" diff --git a/colour/temperature/krystek1985.py b/colour/temperature/krystek1985.py index bf3e54352..246c51d3d 100644 --- a/colour/temperature/krystek1985.py +++ b/colour/temperature/krystek1985.py @@ -21,10 +21,14 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize -from colour.hints import ArrayLike, NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tstack __author__ = "Colour Developers" diff --git a/colour/temperature/mccamy1992.py b/colour/temperature/mccamy1992.py index 2ade26fdf..a44b55108 100644 --- a/colour/temperature/mccamy1992.py +++ b/colour/temperature/mccamy1992.py @@ -20,12 +20,17 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize from colour.algebra import sdiv, sdiv_mode from colour.colorimetry import CCS_ILLUMINANTS -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float, as_float_array, tsplit, usage_warning __author__ = "Colour Developers" diff --git a/colour/temperature/ohno2013.py b/colour/temperature/ohno2013.py index f0a4039bf..0a43ef5fb 100644 --- a/colour/temperature/ohno2013.py +++ b/colour/temperature/ohno2013.py @@ -21,6 +21,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import euclidean_distance, sdiv, sdiv_mode @@ -28,7 +30,10 @@ MultiSpectralDistributions, handle_spectral_arguments, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import UCS_to_uv, UCS_to_XYZ, XYZ_to_UCS, uv_to_UCS from colour.temperature import CCT_to_uv_Planck1900 from colour.utilities import ( diff --git a/colour/temperature/planck1900.py b/colour/temperature/planck1900.py index 1a892fb10..cb217c15b 100644 --- a/colour/temperature/planck1900.py +++ b/colour/temperature/planck1900.py @@ -17,6 +17,8 @@ from __future__ import annotations +import typing + import numpy as np from scipy.optimize import minimize @@ -26,7 +28,10 @@ msds_to_XYZ_integration, planck_law, ) -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import UCS_to_uv, XYZ_to_UCS from colour.utilities import as_float, as_float_array diff --git a/colour/temperature/robertson1968.py b/colour/temperature/robertson1968.py index d0ba3f320..2bb852387 100644 --- a/colour/temperature/robertson1968.py +++ b/colour/temperature/robertson1968.py @@ -39,12 +39,16 @@ from __future__ import annotations +import typing from dataclasses import dataclass import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.utilities import as_float_array, tsplit __author__ = "Colour Developers" diff --git a/colour/utilities/__init__.py b/colour/utilities/__init__.py index 19b10f5a0..ba4eb9012 100644 --- a/colour/utilities/__init__.py +++ b/colour/utilities/__init__.py @@ -4,7 +4,10 @@ import sys -from colour.hints import Any +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any from .verbose import ( MixinLogging, diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 57ddb8e41..50e98e7bd 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -20,6 +20,7 @@ import functools import sys +import typing from collections.abc import KeysView, ValuesView from contextlib import contextmanager from dataclasses import fields, is_dataclass, replace @@ -28,27 +29,27 @@ import numpy as np from colour.constants import DTYPE_FLOAT_DEFAULT, DTYPE_INT_DEFAULT, EPSILON -from colour.hints import ( - Any, - ArrayLike, - Callable, - Dataclass, - DType, - DTypeBoolean, - DTypeFloat, - DTypeInt, - DTypeReal, - Generator, - Literal, - NDArray, - NDArrayFloat, - NDArrayInt, - Real, - Self, - Sequence, - Type, - cast, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + Dataclass, + DType, + DTypeBoolean, + DTypeReal, + Generator, + Literal, + NDArray, + NDArrayFloat, + NDArrayInt, + Real, + Self, + Sequence, + Type, + ) + +from colour.hints import ArrayLike, DTypeFloat, DTypeInt, cast from colour.utilities import ( CACHE_REGISTRY, attest, diff --git a/colour/utilities/callback.py b/colour/utilities/callback.py index 778344665..8a3df821d 100644 --- a/colour/utilities/callback.py +++ b/colour/utilities/callback.py @@ -7,14 +7,12 @@ from __future__ import annotations +import typing from collections import defaultdict from dataclasses import dataclass -from colour.hints import ( - Any, - Callable, - List, -) +if typing.TYPE_CHECKING: # pragma: no cover + from colour.hints import Any, Callable, List __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/utilities/common.py b/colour/utilities/common.py index 307e748dc..e84612446 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -23,6 +23,7 @@ import os import re import types +import typing import unicodedata import warnings from contextlib import contextmanager @@ -32,18 +33,21 @@ import numpy as np from colour.constants import THRESHOLD_INTEGER -from colour.hints import ( - Any, - Callable, - DTypeBoolean, - Generator, - Iterable, - Literal, - Mapping, - Self, - Sequence, - TypeVar, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + DTypeBoolean, + Generator, + Iterable, + Literal, + Mapping, + Self, + Sequence, + ) + +from colour.hints import TypeVar from colour.utilities import CanonicalMapping, Lookup, is_xxhash_installed __author__ = "Colour Developers" @@ -1097,7 +1101,8 @@ def slugify(object_: Any, allow_unicode: bool = False) -> str: int_digest = xxhash.xxh3_64_intdigest if is_documentation_building(): # pragma: no cover - import array + if typing.TYPE_CHECKING: + import array def int_digest( args: ( # noqa: ARG001 diff --git a/colour/utilities/deprecation.py b/colour/utilities/deprecation.py index 4fd243267..1b6ea78d4 100644 --- a/colour/utilities/deprecation.py +++ b/colour/utilities/deprecation.py @@ -8,11 +8,14 @@ from __future__ import annotations import sys +import typing from dataclasses import dataclass from importlib import import_module from operator import attrgetter -from colour.hints import Any, ModuleType +if typing.TYPE_CHECKING: + from colour.hints import Any, ModuleType + from colour.utilities import MixinDataclassIterable, attest, optional, usage_warning __author__ = "Colour Developers" diff --git a/colour/utilities/metrics.py b/colour/utilities/metrics.py index 357b08e81..96b32ba95 100644 --- a/colour/utilities/metrics.py +++ b/colour/utilities/metrics.py @@ -18,15 +18,20 @@ from __future__ import annotations +import typing + import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.hints import ( - ArrayLike, - NDArrayFloat, - Real, - Tuple, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + NDArrayFloat, + Real, + Tuple, + ) + from colour.utilities import as_float, as_float_array, zeros __author__ = "Colour Developers" diff --git a/colour/utilities/network.py b/colour/utilities/network.py index c6a42d2dc..c8e4199de 100644 --- a/colour/utilities/network.py +++ b/colour/utilities/network.py @@ -31,17 +31,20 @@ import concurrent.futures import os import threading +import typing + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Dict, + Generator, + List, + Self, + Sequence, + Tuple, + Type, + ) -from colour.hints import ( - Any, - Dict, - Generator, - List, - Self, - Sequence, - Tuple, - Type, -) from colour.utilities import MixinLogging, attest, optional, required __author__ = "Colour Developers" diff --git a/colour/utilities/requirements.py b/colour/utilities/requirements.py index 8e0ffdf06..756d5044c 100644 --- a/colour/utilities/requirements.py +++ b/colour/utilities/requirements.py @@ -10,12 +10,15 @@ import functools import shutil import subprocess +import typing + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + Literal, + ) -from colour.hints import ( - Any, - Callable, - Literal, -) from colour.utilities import CanonicalMapping __author__ = "Colour Developers" diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index 278c4f210..05977c3a2 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -28,15 +28,17 @@ from __future__ import annotations import re +import typing from collections import Counter from collections.abc import MutableMapping -from colour.hints import ( - Any, - Generator, - Iterable, - Mapping, -) +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Generator, + Iterable, + ) +from colour.hints import Mapping from colour.utilities.documentation import is_documentation_building __author__ = "Colour Developers" diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index a929f688e..9d770ac88 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -2,6 +2,7 @@ from __future__ import annotations +import typing import unittest from copy import deepcopy from dataclasses import dataclass, field, fields @@ -14,7 +15,10 @@ DTYPE_INT_DEFAULT, TOLERANCE_ABSOLUTE_TESTS, ) -from colour.hints import ArrayLike, DType, NDArray, NDArrayFloat, Type + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, DType, NDArray, NDArrayFloat, Type + from colour.utilities import ( MixinDataclassArithmetic, MixinDataclassArray, diff --git a/colour/utilities/tests/test_common.py b/colour/utilities/tests/test_common.py index eec5be2ee..5d3df7a99 100644 --- a/colour/utilities/tests/test_common.py +++ b/colour/utilities/tests/test_common.py @@ -2,13 +2,16 @@ from __future__ import annotations +import typing import unicodedata from functools import partial import numpy as np import pytest -from colour.hints import Any, Real, Tuple +if typing.TYPE_CHECKING: + from colour.hints import Any, Real, Tuple + from colour.utilities import ( CacheRegistry, CanonicalMapping, diff --git a/colour/utilities/tests/test_deprecated.py b/colour/utilities/tests/test_deprecated.py index 6101abd6d..32eebee9e 100644 --- a/colour/utilities/tests/test_deprecated.py +++ b/colour/utilities/tests/test_deprecated.py @@ -4,8 +4,11 @@ import contextlib import sys +import typing + +if typing.TYPE_CHECKING: + from colour.hints import Any -from colour.hints import Any from colour.utilities.deprecation import ( ModuleAPI, ObjectRemoved, diff --git a/colour/utilities/tests/test_network.py b/colour/utilities/tests/test_network.py index 2586dfc05..a6e5116d2 100644 --- a/colour/utilities/tests/test_network.py +++ b/colour/utilities/tests/test_network.py @@ -3,10 +3,13 @@ from __future__ import annotations import re +import typing import numpy as np -from colour.hints import Any +if typing.TYPE_CHECKING: + from colour.hints import Any + from colour.utilities import ( ExecutionNode, For, diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index 480fe7a73..7fe4b0fd2 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -12,6 +12,7 @@ import os import sys import traceback +import typing import warnings from collections import defaultdict from contextlib import contextmanager, suppress @@ -21,21 +22,22 @@ import numpy as np -from colour.hints import ( - Any, - Callable, - ClassVar, - Dict, - Generator, - List, - Literal, - LiteralWarning, - Mapping, - Self, - TextIO, - Type, - cast, -) +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + Callable, + ClassVar, + Dict, + Generator, + List, + Literal, + Mapping, + Self, + TextIO, + Type, + ) + +from colour.hints import LiteralWarning, cast __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/volume/datasets/optimal_colour_stimuli.py b/colour/volume/datasets/optimal_colour_stimuli.py index 2ad48c063..f75fe5d56 100644 --- a/colour/volume/datasets/optimal_colour_stimuli.py +++ b/colour/volume/datasets/optimal_colour_stimuli.py @@ -27,9 +27,13 @@ from __future__ import annotations +import typing + import numpy as np -from colour.hints import NDArrayFloat +if typing.TYPE_CHECKING: + from colour.hints import NDArrayFloat + from colour.utilities import CanonicalMapping __author__ = "Colour Developers" diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index 2fb3c9ad8..e4158f3bd 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -7,11 +7,16 @@ from __future__ import annotations +import typing + import numpy as np from scipy.spatial import Delaunay from colour.constants import EPSILON -from colour.hints import ArrayLike, Literal, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, Literal, NDArrayFloat + from colour.models import xyY_to_XYZ from colour.utilities import ( CACHE_REGISTRY, diff --git a/colour/volume/mesh.py b/colour/volume/mesh.py index 09c69a240..1c508839e 100644 --- a/colour/volume/mesh.py +++ b/colour/volume/mesh.py @@ -7,11 +7,15 @@ from __future__ import annotations +import typing + import numpy as np from scipy.spatial import Delaunay from colour.constants import EPSILON -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/volume/pointer_gamut.py b/colour/volume/pointer_gamut.py index 504168ce1..305ab7156 100644 --- a/colour/volume/pointer_gamut.py +++ b/colour/volume/pointer_gamut.py @@ -7,8 +7,13 @@ from __future__ import annotations +import typing + from colour.constants import EPSILON -from colour.hints import ArrayLike, NDArrayFloat + +if typing.TYPE_CHECKING: + from colour.hints import ArrayLike, NDArrayFloat + from colour.models import LCHab_to_Lab # pyright: ignore from colour.models import ( CCS_ILLUMINANT_POINTER_GAMUT, diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index 26321f18b..ba8e2c689 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -14,18 +14,22 @@ from __future__ import annotations import itertools +import typing import numpy as np from colour.algebra import random_triplet_generator from colour.colorimetry import CCS_ILLUMINANTS from colour.constants import DTYPE_INT_DEFAULT -from colour.hints import ( - ArrayLike, - Callable, - LiteralChromaticAdaptationTransform, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + ArrayLike, + Callable, + LiteralChromaticAdaptationTransform, + NDArrayFloat, + ) + from colour.models import ( Lab_to_XYZ, RGB_Colourspace, diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py index d02420f60..483bd0b66 100644 --- a/colour/volume/spectrum.py +++ b/colour/volume/spectrum.py @@ -22,6 +22,8 @@ from __future__ import annotations +import typing + import numpy as np from colour.colorimetry import ( @@ -32,12 +34,15 @@ msds_to_XYZ, ) from colour.constants import DTYPE_FLOAT_DEFAULT, EPSILON -from colour.hints import ( - Any, - ArrayLike, - Literal, - NDArrayFloat, -) + +if typing.TYPE_CHECKING: + from colour.hints import ( + Any, + ArrayLike, + Literal, + NDArrayFloat, + ) + from colour.utilities import ( CACHE_REGISTRY, is_caching_enabled, diff --git a/docs/colour.hints.rst b/docs/colour.hints.rst index 2a3dc3d80..924fa5e11 100644 --- a/docs/colour.hints.rst +++ b/docs/colour.hints.rst @@ -27,7 +27,6 @@ Annotation Type Hints Sequence Set SupportsIndex - TYPE_CHECKING TextIO Tuple Type diff --git a/pyproject.toml b/pyproject.toml index 4f893f1cb..6211f2c31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -192,7 +192,7 @@ select = [ "SIM", # flake8-simplify "T10", # flake8-debugger "T20", # flake8-print - # "TCH", # flake8-type-checking + "TC", # flake8-type-checking "TID", # flake8-tidy-imports "TRY", # tryceratops "UP", # pyupgrade diff --git a/tasks.py b/tasks.py index c9ad95caf..a62803f96 100644 --- a/tasks.py +++ b/tasks.py @@ -10,6 +10,7 @@ import inspect import os import re +import typing import uuid import biblib.bib @@ -20,7 +21,9 @@ if not hasattr(inspect, "getargspec"): inspect.getargspec = inspect.getfullargspec # pyright: ignore -from invoke.context import Context +if typing.TYPE_CHECKING: + from invoke.context import Context + from invoke.tasks import task __author__ = "Colour Developers" From 8d621f1babab52282e6e0d52ad5dc7277e3dc5fc Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:25:40 +1300 Subject: [PATCH 32/42] Enable `INT` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 6211f2c31..ead593705 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -172,6 +172,7 @@ select = [ "I", # isort "ICN", # flake8-import-conventions "INP", # flake8-no-pep420 + "INT", # flake8-gettext "ISC", # flake8-implicit-str-concat "LOG", # flake8-logging "N", # pep8-naming From 623b4379bfca488d8df1634cc9c1ecc324ea8603 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:28:17 +1300 Subject: [PATCH 33/42] Update `pyproject.toml` file. --- pyproject.toml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ead593705..9cd1ca4dd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -154,6 +154,7 @@ select = [ "ANN", # flake8-annotations "ASYNC", # flake8-async "B", # flake8-bugbear + # "C", # Pylint - Convention "BLE", # flake8-blind-except "C4", # flake8-comprehensions # "C90", # mccabe @@ -161,11 +162,12 @@ select = [ "CPY", # flake8-copyright "DTZ", # flake8-datetimez "D", # pydocstyle - "E", # pydocstyle + "E", # Pylint - Error # "ERA", # eradicate "EM", # flake8-errmsg "EXE", # flake8-executable "F", # flake8 + # "FIX", # flake8-fixme "FA", # flake8-future-annotations # "FBT", # flake8-boolean-trap "G", # flake8-logging-format @@ -194,10 +196,11 @@ select = [ "T10", # flake8-debugger "T20", # flake8-print "TC", # flake8-type-checking + # "TD", # flake8-todos "TID", # flake8-tidy-imports "TRY", # tryceratops "UP", # pyupgrade - "W", # pydocstyle + "W", # Pylint - Warning "YTT", # flake8-2020 ] ignore = [ From 08feb3b56f06950fe75d5d8bf9deaaf04a48ea41 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:31:19 +1300 Subject: [PATCH 34/42] Enable `R` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 9cd1ca4dd..d8d23909a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -186,6 +186,7 @@ select = [ # "PTH", # flake8-use-pathlib [Enable] "PYI", # flake8-pyi "Q", # flake8-quotes + "R", # pylint-refactor "RET", # flake8-return "RSE", # flake8-raise "RUF", # Ruff From fe08ef5d1876ef69abcc9b2cc7394173c6275e58 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:38:04 +1300 Subject: [PATCH 35/42] Enable `FLY` checks. --- colour/__init__.py | 2 +- colour/notation/munsell.py | 3 +-- pyproject.toml | 1 + tasks.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/colour/__init__.py b/colour/__init__.py index ca0f660e9..66d27dcb7 100644 --- a/colour/__init__.py +++ b/colour/__init__.py @@ -910,7 +910,7 @@ __major_version__ = "0" __minor_version__ = "4" __change_version__ = "6" -__version__ = ".".join((__major_version__, __minor_version__, __change_version__)) +__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}" # TODO: Remove legacy printing support when deemed appropriate. with contextlib.suppress(TypeError): diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 79bcc7610..eb0341fd8 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -2398,8 +2398,7 @@ def xy_from_renotation_ovoid(specification: ArrayLike) -> NDArrayFloat: attest( interpolation_method is not None, - f"Interpolation method must be one of: " - f"\"{', '.join(['Linear', 'Radial'])}\"", + f"Interpolation method must be one of: \"{'Linear, Radial'}\"", ) hue_angle_lower_upper = np.squeeze([hue_angle_lower, hue_angle_upper]) diff --git a/pyproject.toml b/pyproject.toml index d8d23909a..3e4283995 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -170,6 +170,7 @@ select = [ # "FIX", # flake8-fixme "FA", # flake8-future-annotations # "FBT", # flake8-boolean-trap + "FLY", # flynt "G", # flake8-logging-format "I", # isort "ICN", # flake8-import-conventions diff --git a/tasks.py b/tasks.py index a62803f96..3846fe18e 100644 --- a/tasks.py +++ b/tasks.py @@ -473,7 +473,7 @@ def tag(ctx: Context) -> None: 1 ) - version = ".".join((major_version, minor_version, change_version)) + version = f"{major_version}.{minor_version}.{change_version}" result = ctx.run("git ls-remote --tags upstream", hide="both") remote_tags = result.stdout.strip().split("\n") # pyright: ignore From 869a522beaf696ad5705686bd1c96d84148a7fd0 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:43:36 +1300 Subject: [PATCH 36/42] Enable `NPY` checks. --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3e4283995..c56334769 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -179,6 +179,7 @@ select = [ "ISC", # flake8-implicit-str-concat "LOG", # flake8-logging "N", # pep8-naming + "NPY", # Numpy "PD", # pandas-vet "PIE", # flake8-pie "PGH", # pygrep-hooks @@ -220,6 +221,7 @@ ignore = [ "N813", # Camelcase `.*` imported as lowercase `.*` "N815", # Variable `.*` in class scope should not be mixedCase "N816", # Variable `.*` in global scope should not be mixedCase + "NPY002", # Replace legacy `np.random.random` call with `np.random.Generator` "PGH003", # Use specific rule codes when ignoring type issues "PLR0912", # Too many branches "PLR0913", # Too many arguments in function definition From 7eee26421ed61669d489d237694d6bf13486e41f Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 15:55:25 +1300 Subject: [PATCH 37/42] Enable `PERF` checks. --- colour/algebra/tests/test_interpolation.py | 6 +++--- colour/geometry/vertices.py | 2 +- colour/io/fichet2021.py | 11 +++++------ colour/io/image.py | 14 +++++++------- colour/io/uprtek_sekonic.py | 2 +- colour/models/tests/test_cam02_ucs.py | 2 +- colour/quality/cfi2017.py | 11 +++++------ colour/recovery/tests/test_otsu2018.py | 2 +- colour/utilities/verbose.py | 4 ++-- colour/volume/rgb.py | 14 ++++++-------- colour/volume/spectrum.py | 2 +- pyproject.toml | 1 + 12 files changed, 34 insertions(+), 37 deletions(-) diff --git a/colour/algebra/tests/test_interpolation.py b/colour/algebra/tests/test_interpolation.py index 7daf863df..51bc74009 100644 --- a/colour/algebra/tests/test_interpolation.py +++ b/colour/algebra/tests/test_interpolation.py @@ -1289,7 +1289,7 @@ def test_nan__call__(self) -> None: try: linear_interpolator = LinearInterpolator(case, case) linear_interpolator(case[0]) - except ValueError: + except ValueError: # noqa: PERF203 pass @@ -1377,7 +1377,7 @@ def test_nan__call__(self) -> None: try: sprague_interpolator = SpragueInterpolator(case, case) sprague_interpolator(case[0]) # pragma: no cover - except AssertionError: + except AssertionError: # noqa: PERF203 pass @@ -1574,7 +1574,7 @@ def test_nan__call__(self) -> None: try: null_interpolator = NullInterpolator(case, case) null_interpolator(case[0]) - except ValueError: + except ValueError: # noqa: PERF203 pass diff --git a/colour/geometry/vertices.py b/colour/geometry/vertices.py index 632d35e31..825b7c84c 100644 --- a/colour/geometry/vertices.py +++ b/colour/geometry/vertices.py @@ -192,7 +192,7 @@ def primitive_vertices_grid_mpl( quads = [] for i in range(width_segments): for j in range(height_segments): - quads.append( + quads.append( # noqa: PERF401 primitive_vertices_quad_mpl( w_x, h_y, depth, (i * w_x + u, j * h_y + v), axis ) diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index 91c67153f..41532fb02 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -407,13 +407,12 @@ def from_spectral_image(path: str | Path) -> Specification_Fichet2021: wavelength = match_groups_to_nm(match.group(1), multiplier, units) components["T"][wavelength] = i - attributes = [] - for attribute in image_specification.extra_attribs: - attributes.append( - Image_Specification_Attribute( - attribute.name, attribute.value, attribute.type - ) + attributes = [ + Image_Specification_Attribute( + attribute.name, attribute.value, attribute.type ) + for attribute in image_specification.extra_attribs + ] return Specification_Fichet2021( path, diff --git a/colour/io/image.py b/colour/io/image.py index dc5f1675b..4597784bb 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -340,7 +340,7 @@ def read_image_OpenImageIO( ] = "float32", additional_data: bool = False, **kwargs: Any, -) -> NDArrayReal | Tuple[NDArrayReal, Tuple[Image_Specification_Attribute]]: +) -> NDArrayReal | Tuple[NDArrayReal, Tuple[Image_Specification_Attribute, ...]]: """ Read the image data at given path using *OpenImageIO*. @@ -410,15 +410,15 @@ def read_image_OpenImageIO( image = cast(NDArrayReal, np.squeeze(image)) if additional_data: - extra_attributes = [] - for attribute in image_specification.extra_attribs: - extra_attributes.append( - Image_Specification_Attribute( - attribute.name, attribute.value, attribute.type - ) + extra_attributes = [ + Image_Specification_Attribute( + attribute.name, attribute.value, attribute.type ) + for attribute in image_specification.extra_attribs + ] return image, tuple(extra_attributes) + return image diff --git a/colour/io/uprtek_sekonic.py b/colour/io/uprtek_sekonic.py index 5b26b4ae8..d976e8db4 100644 --- a/colour/io/uprtek_sekonic.py +++ b/colour/io/uprtek_sekonic.py @@ -412,7 +412,7 @@ def as_array(a: Any) -> list: self._metadata[attribute] = method( value # pyright: ignore ) - except (TypeError, ValueError): + except (TypeError, ValueError): # noqa: PERF203 self._metadata[attribute] = value else: break diff --git a/colour/models/tests/test_cam02_ucs.py b/colour/models/tests/test_cam02_ucs.py index 764d54424..ee9e731bd 100644 --- a/colour/models/tests/test_cam02_ucs.py +++ b/colour/models/tests/test_cam02_ucs.py @@ -557,5 +557,5 @@ def test_nan_UCS_Luo2006_to_XYZ(self) -> None: for case in cases: try: UCS_Luo2006_to_XYZ(case, COEFFICIENTS_UCS_LUO2006["CAM02-LCD"]) - except ValueError as error: + except ValueError as error: # noqa: PERF203 attest("CAM_Specification_CIECAM02" in str(error)) diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index 56338dcbf..6ad164c9f 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -503,13 +503,12 @@ def tcs_colorimetry_data( ] ) Jpapbp = JMh_CIECAM02_to_CAM02UCS(JMh) - tcs_data = [] specification = as_float_array(specification).transpose((0, 2, 1)) specification = [CAM_Specification_CIECAM02(*t) for t in specification] - for sd_idx in range(len(sd_irradiance)): - tcs_data.append( + return tuple( + [ DataColorimetry_TCS_CIE2017( sds_tcs.display_labels, XYZ[sd_idx], @@ -517,9 +516,9 @@ def tcs_colorimetry_data( JMh[sd_idx], Jpapbp[sd_idx], ) - ) - - return tuple(tcs_data) + for sd_idx in range(len(sd_irradiance)) + ] + ) def delta_E_to_R_f(delta_E: ArrayLike) -> NDArrayFloat: diff --git a/colour/recovery/tests/test_otsu2018.py b/colour/recovery/tests/test_otsu2018.py index 77a7e1ba2..9135483f3 100644 --- a/colour/recovery/tests/test_otsu2018.py +++ b/colour/recovery/tests/test_otsu2018.py @@ -225,7 +225,7 @@ def test_XYZ_to_sd_Otsu2018(self) -> None: """Test :func:`colour.recovery.otsu2018.XYZ_to_sd_Otsu2018` definition.""" # Tests the round-trip with values of a colour checker. - for _name, sd in SDS_COLOURCHECKERS["ColorChecker N Ohta"].items(): + for sd in SDS_COLOURCHECKERS["ColorChecker N Ohta"].values(): XYZ = sd_to_XYZ(sd, self._cmfs, self._sd_D65) / 100 Lab = XYZ_to_Lab(XYZ, self._xy_D65) diff --git a/colour/utilities/verbose.py b/colour/utilities/verbose.py index 7fe4b0fd2..0ea54485c 100644 --- a/colour/utilities/verbose.py +++ b/colour/utilities/verbose.py @@ -889,7 +889,7 @@ def _get_package_version(package: str, mapping: Mapping) -> str: package = mapping.get(package, package) # noqa: PLW2901 environment["Development"][package] = version - except Exception: # pragma: no cover # noqa: BLE001, S112 + except Exception: # pragma: no cover # noqa: BLE001, PERF203, S112 continue environment["Development"].update(ANCILLARY_DEVELOPMENT_PACKAGES) @@ -902,7 +902,7 @@ def _get_package_version(package: str, mapping: Mapping) -> str: package = mapping.get(package, package) # noqa: PLW2901 environment["Extras"][package] = version - except Exception: # pragma: no cover # noqa: BLE001, S112 + except Exception: # pragma: no cover # noqa: BLE001, PERF203, S112 continue environment["Extras"].update(ANCILLARY_EXTRAS_PACKAGES) diff --git a/colour/volume/rgb.py b/colour/volume/rgb.py index ba8e2c689..e6954feb1 100644 --- a/colour/volume/rgb.py +++ b/colour/volume/rgb.py @@ -183,19 +183,17 @@ def RGB_colourspace_limits(colourspace: RGB_Colourspace) -> NDArrayFloat: [-107.8503557..., 94.4894974...]]) """ - Lab_c = [] - for combination in list(itertools.product([0, 1], repeat=3)): - Lab_c.append( + Lab = np.array( + [ XYZ_to_Lab( RGB_to_XYZ(combination, colourspace), colourspace.whitepoint, ) - ) - Lab = np.array(Lab_c) + for combination in list(itertools.product([0, 1], repeat=3)) + ] + ) - limits = [] - for i in np.arange(3): - limits.append((np.min(Lab[..., i]), np.max(Lab[..., i]))) + limits = [(np.min(Lab[..., i]), np.max(Lab[..., i])) for i in np.arange(3)] return np.array(limits) diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py index 483bd0b66..7b3a3c76d 100644 --- a/colour/volume/spectrum.py +++ b/colour/volume/spectrum.py @@ -230,7 +230,7 @@ def generate_pulse_waves( if pulse_order.lower() == "bins": for square_wave_basis in square_waves_basis: for i in range(bins): - square_waves.append(np.roll(square_wave_basis, i)) + square_waves.append(np.roll(square_wave_basis, i)) # noqa: PERF401 else: for i in range(bins): for j, square_wave_basis in enumerate(square_waves_basis): diff --git a/pyproject.toml b/pyproject.toml index c56334769..b8eadf875 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -181,6 +181,7 @@ select = [ "N", # pep8-naming "NPY", # Numpy "PD", # pandas-vet + "PERF", # Perflint "PIE", # flake8-pie "PGH", # pygrep-hooks "PL", # pylint From 23ee40694bc9a3771fb96ba3e5ae4cbacadac82b Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 16:10:23 +1300 Subject: [PATCH 38/42] Enable `FURB` checks. --- colour/io/luts/sony_spi1d.py | 2 +- colour/io/luts/sony_spi3d.py | 2 +- colour/io/luts/tests/test_sony_spi3d.py | 2 +- colour/quality/cqs.py | 9 ++------- pyproject.toml | 1 + 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/colour/io/luts/sony_spi1d.py b/colour/io/luts/sony_spi1d.py index 4d4411d91..2126c9a1a 100644 --- a/colour/io/luts/sony_spi1d.py +++ b/colour/io/luts/sony_spi1d.py @@ -106,7 +106,7 @@ def read_LUT_SonySPI1D(path: str | Path) -> LUT1D | LUT3x1D: comments = [] with open(path) as spi1d_file: - lines = filter(None, (line.strip() for line in spi1d_file.readlines())) + lines = filter(None, (line.strip() for line in spi1d_file)) for line in lines: if line.startswith("#"): comments.append(line[1:].strip()) diff --git a/colour/io/luts/sony_spi3d.py b/colour/io/luts/sony_spi3d.py index 08fac7327..186c49b38 100644 --- a/colour/io/luts/sony_spi3d.py +++ b/colour/io/luts/sony_spi3d.py @@ -105,7 +105,7 @@ def read_LUT_SonySPI3D(path: str | Path) -> LUT3D: comments = [] with open(path) as spi3d_file: - lines = filter(None, (line.strip() for line in spi3d_file.readlines())) + lines = filter(None, (line.strip() for line in spi3d_file)) for line in lines: if line.startswith("#"): comments.append(line[1:].strip()) diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index 52e2e00a9..d81dfed7e 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -215,7 +215,7 @@ def test_write_LUT_SonySPI3D(self) -> None: indexes = [] with open(path) as spi3d_file: - lines = filter(None, (line.strip() for line in spi3d_file.readlines())) + lines = filter(None, (line.strip() for line in spi3d_file)) for line in lines: tokens = line.split() if len(tokens) == 6: diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 468bd2f64..597c73062 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -297,12 +297,7 @@ def colour_quality_scale( else: p_delta_C = cast( float, - np.average( - [ - sample_data.D_C_ab if sample_data.D_C_ab > 0 else 0 - for sample_data in Q_as.values() - ] - ), + np.average([max(0, sample_data.D_C_ab) for sample_data in Q_as.values()]), ) Q_p = 100 - 3.6 * (D_Ep_RMS - p_delta_C) Q_d = G_t / G_r * CCT_f * 100 @@ -469,7 +464,7 @@ def CCT_factor( ) G_r = gamut_area(Lab) / GAMUT_AREA_D65 - return 1 if G_r > 1 else G_r + return min(G_r, 1) def scale_conversion(D_E_ab: float, CCT_f: float, scaling_f: float) -> float: diff --git a/pyproject.toml b/pyproject.toml index b8eadf875..d4f79db75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -171,6 +171,7 @@ select = [ "FA", # flake8-future-annotations # "FBT", # flake8-boolean-trap "FLY", # flynt + "FURB", # Refurb "G", # flake8-logging-format "I", # isort "ICN", # flake8-import-conventions From 2ad603180cad184a6a30e926c732d005cf22fb5f Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 16:11:27 +1300 Subject: [PATCH 39/42] Enable `DOC` checks. --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index d4f79db75..01134fcc7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -162,6 +162,7 @@ select = [ "CPY", # flake8-copyright "DTZ", # flake8-datetimez "D", # pydocstyle + "DOC", # pydoclint "E", # Pylint - Error # "ERA", # eradicate "EM", # flake8-errmsg From 58f96f7502a2977187a9c7fca2a452f16d341bf2 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 16:14:39 +1300 Subject: [PATCH 40/42] Enable all the *Ruff* checks but the currently ignored ones. --- colour/adaptation/tests/test_fairchild2020.py | 4 +- colour/algebra/common.py | 8 +-- colour/appearance/ciecam02.py | 5 +- colour/appearance/hellwig2022.py | 5 +- colour/appearance/hke.py | 7 +- colour/appearance/llab.py | 8 +-- colour/appearance/tests/test_atd95.py | 6 +- colour/appearance/tests/test_hunt.py | 6 +- colour/appearance/tests/test_nayatani95.py | 6 +- colour/appearance/tests/test_rlab.py | 6 +- colour/blindness/machado2009.py | 6 +- colour/characterisation/aces_it.py | 13 +--- colour/colorimetry/dominant.py | 16 +---- colour/colorimetry/photometry.py | 6 +- colour/colorimetry/tests/test_correction.py | 5 +- colour/colorimetry/tests/test_dominant.py | 4 +- colour/colorimetry/tests/test_yellowness.py | 5 +- colour/colorimetry/whiteness.py | 1 + colour/constants/cie.py | 5 +- colour/constants/codata.py | 5 +- colour/constants/common.py | 5 +- colour/continuous/signal.py | 12 +--- colour/continuous/tests/test_multi_signal.py | 6 +- colour/continuous/tests/test_signal.py | 6 +- colour/corresponding/datasets/breneman1987.py | 5 +- colour/difference/cam16_ucs.py | 4 +- colour/difference/delta_e.py | 5 +- colour/difference/stress.py | 7 +- colour/difference/tests/test_cam02_ucs.py | 6 +- .../examples/plotting/examples_blindness.py | 6 +- .../examples_characterisation_plots.py | 6 +- .../plotting/examples_corresponding.py | 5 +- colour/examples/plotting/examples_tm3018.py | 5 +- .../plotting/examples_volume_plots.py | 6 +- colour/geometry/ellipse.py | 8 +-- colour/geometry/primitives.py | 5 +- colour/geometry/section.py | 7 +- colour/geometry/tests/test_intersection.py | 5 +- colour/geometry/tests/test_primitives.py | 6 +- colour/geometry/tests/test_section.py | 6 +- colour/graph/conversion.py | 5 +- colour/io/ctl.py | 11 +-- colour/io/fichet2021.py | 7 +- colour/io/image.py | 5 +- colour/io/luts/lut.py | 17 +---- colour/io/luts/operator.py | 9 +-- colour/io/luts/sequence.py | 4 +- colour/io/luts/tests/test_iridas_cube.py | 7 +- colour/io/luts/tests/test_sony_spi3d.py | 7 +- colour/io/tests/test_uprtek_sekonic.py | 5 +- colour/models/cie_luv.py | 6 +- colour/models/cie_ucs.py | 7 +- colour/models/cie_uvw.py | 8 +-- colour/models/common.py | 5 +- colour/models/hdr_cie_lab.py | 5 +- colour/models/hdr_ipt.py | 5 +- colour/models/icacb.py | 5 +- colour/models/jzazbz.py | 10 +-- colour/models/rgb/cmyk.py | 8 +-- colour/models/rgb/cylindrical.py | 8 +-- .../rgb/datasets/adobe_wide_gamut_rgb.py | 6 +- colour/models/rgb/datasets/apple_rgb.py | 6 +- colour/models/rgb/datasets/best_rgb.py | 6 +- colour/models/rgb/datasets/beta_rgb.py | 6 +- colour/models/rgb/datasets/color_match_rgb.py | 6 +- colour/models/rgb/datasets/dci_p3.py | 6 +- colour/models/rgb/datasets/don_rgb_4.py | 6 +- colour/models/rgb/datasets/eci_rgb_v2.py | 6 +- colour/models/rgb/datasets/ekta_space_ps5.py | 6 +- colour/models/rgb/datasets/itur_bt_470.py | 6 +- colour/models/rgb/datasets/max_rgb.py | 6 +- colour/models/rgb/datasets/nikon_n_gamut.py | 6 +- colour/models/rgb/datasets/p3_d65.py | 6 +- .../models/rgb/datasets/panasonic_v_gamut.py | 6 +- colour/models/rgb/datasets/russell_rgb.py | 6 +- colour/models/rgb/datasets/smpte_c.py | 6 +- .../models/rgb/datasets/tests/test__init__.py | 5 +- colour/models/rgb/datasets/xtreme_rgb.py | 6 +- colour/models/rgb/hanbury2003.py | 8 +-- colour/models/rgb/ictcp.py | 6 +- colour/models/rgb/itut_h_273.py | 5 +- colour/models/rgb/rgb_colourspace.py | 9 +-- colour/models/rgb/tests/test_cmyk.py | 7 +- colour/models/rgb/tests/test_ictcp.py | 7 +- colour/models/rgb/transfer_functions/aces.py | 8 +-- .../models/rgb/transfer_functions/cineon.py | 7 +- .../rgb/transfer_functions/dicom_gsdf.py | 8 +-- .../models/rgb/transfer_functions/exponent.py | 7 +- .../rgb/transfer_functions/itur_bt_1361.py | 7 +- .../rgb/transfer_functions/itur_bt_2100.py | 4 +- .../rgb/transfer_functions/itur_bt_601.py | 7 +- .../rgb/transfer_functions/itut_h_273.py | 7 +- colour/models/rgb/transfer_functions/log.py | 4 +- .../models/rgb/transfer_functions/panalog.py | 7 +- .../rgb/transfer_functions/smpte_240m.py | 7 +- colour/models/rgb/transfer_functions/srgb.py | 7 +- .../transfer_functions/tests/test_common.py | 6 +- .../tests/test_dicom_gsdf.py | 5 +- .../tests/test_itur_bt_1361.py | 5 +- .../tests/test_itur_bt_1886.py | 5 +- .../tests/test_itur_bt_2020.py | 5 +- .../tests/test_leica_l_log.py | 5 +- .../tests/test_nikon_n_log.py | 5 +- .../tests/test_panasonic_vlog.py | 5 +- .../transfer_functions/tests/test_st_2084.py | 5 +- colour/models/tests/test_din99.py | 7 +- colour/models/tests/test_jzazbz.py | 7 +- colour/models/tests/test_yrg.py | 7 +- colour/models/yrg.py | 7 +- colour/notation/munsell.py | 11 +-- colour/notation/tests/test_hexadecimal.py | 5 +- colour/plotting/colorimetry.py | 12 +--- colour/plotting/common.py | 7 +- colour/plotting/diagrams.py | 5 +- colour/plotting/graph.py | 5 +- colour/plotting/models.py | 5 +- colour/plotting/notation.py | 6 +- colour/plotting/phenomena.py | 5 +- colour/plotting/quality.py | 5 +- colour/plotting/section.py | 5 +- colour/plotting/temperature.py | 9 +-- .../plotting/tests/test_characterisation.py | 5 +- colour/plotting/tests/test_diagrams.py | 7 +- colour/plotting/tests/test_phenomena.py | 5 +- colour/plotting/tests/test_section.py | 10 +-- colour/plotting/volume.py | 12 +--- colour/quality/cqs.py | 24 ++----- colour/quality/tests/test_cqs.py | 5 +- colour/quality/tests/test_cri.py | 5 +- colour/recovery/jiang2013.py | 4 +- colour/recovery/smits1999.py | 6 +- colour/recovery/tests/test_jakob2019.py | 7 +- colour/recovery/tests/test_jiang2013.py | 5 +- colour/temperature/ohno2013.py | 5 +- colour/temperature/tests/test_ohno2013.py | 4 +- colour/utilities/callback.py | 2 +- colour/utilities/tests/test_array.py | 7 +- colour/utilities/tests/test_deprecated.py | 6 +- colour/volume/macadam_limits.py | 6 +- colour/volume/spectrum.py | 7 +- pyproject.toml | 71 +++---------------- utilities/generate_plots.py | 11 +-- 142 files changed, 169 insertions(+), 820 deletions(-) diff --git a/colour/adaptation/tests/test_fairchild2020.py b/colour/adaptation/tests/test_fairchild2020.py index 399b9d94d..c753b21c5 100644 --- a/colour/adaptation/tests/test_fairchild2020.py +++ b/colour/adaptation/tests/test_fairchild2020.py @@ -13,9 +13,7 @@ chromatic_adaptation_vK20, matrix_chromatic_adaptation_vk20, ) -from colour.adaptation.fairchild2020 import ( - CONDITIONS_DEGREE_OF_ADAPTATION_VK20, -) +from colour.adaptation.fairchild2020 import CONDITIONS_DEGREE_OF_ADAPTATION_VK20 from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.utilities import domain_range_scale, ignore_numpy_errors diff --git a/colour/algebra/common.py b/colour/algebra/common.py index b98120b9b..51383a967 100644 --- a/colour/algebra/common.py +++ b/colour/algebra/common.py @@ -24,13 +24,7 @@ ) from colour.hints import Literal, cast -from colour.utilities import ( - as_float, - as_float_array, - optional, - tsplit, - validate_method, -) +from colour.utilities import as_float, as_float_array, optional, tsplit, validate_method __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 65877cdee..71fd35c21 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -69,10 +69,7 @@ tstack, zeros, ) -from colour.utilities.documentation import ( - DocstringDict, - is_documentation_building, -) +from colour.utilities.documentation import DocstringDict, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/hellwig2022.py b/colour/appearance/hellwig2022.py index c8f46c234..78970e744 100644 --- a/colour/appearance/hellwig2022.py +++ b/colour/appearance/hellwig2022.py @@ -30,10 +30,7 @@ import numpy as np from colour.algebra import sdiv, sdiv_mode, spow, vecmul -from colour.appearance.cam16 import ( - MATRIX_16, - MATRIX_INVERSE_16, -) +from colour.appearance.cam16 import MATRIX_16, MATRIX_INVERSE_16 from colour.appearance.ciecam02 import ( VIEWING_CONDITIONS_CIECAM02, InductionFactors_CIECAM02, diff --git a/colour/appearance/hke.py b/colour/appearance/hke.py index 20e0db884..bdb56eb9a 100644 --- a/colour/appearance/hke.py +++ b/colour/appearance/hke.py @@ -34,12 +34,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat -from colour.utilities import ( - CanonicalMapping, - as_float_array, - tsplit, - validate_method, -) +from colour.utilities import CanonicalMapping, as_float_array, tsplit, validate_method __author__ = "Ilia Sibiryakov" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/llab.py b/colour/appearance/llab.py index 6a8d26822..315236f9e 100644 --- a/colour/appearance/llab.py +++ b/colour/appearance/llab.py @@ -32,13 +32,7 @@ import numpy as np -from colour.algebra import ( - polar_to_cartesian, - sdiv, - sdiv_mode, - spow, - vecmul, -) +from colour.algebra import polar_to_cartesian, sdiv, sdiv_mode, spow, vecmul if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat diff --git a/colour/appearance/tests/test_atd95.py b/colour/appearance/tests/test_atd95.py index 4286d3fec..5bb65a6ef 100644 --- a/colour/appearance/tests/test_atd95.py +++ b/colour/appearance/tests/test_atd95.py @@ -8,11 +8,7 @@ from colour.appearance import XYZ_to_ATD95 from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.utilities import ( - as_float_array, - domain_range_scale, - ignore_numpy_errors, -) +from colour.utilities import as_float_array, domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/tests/test_hunt.py b/colour/appearance/tests/test_hunt.py index 00dd6bdd4..f1e5f87c4 100644 --- a/colour/appearance/tests/test_hunt.py +++ b/colour/appearance/tests/test_hunt.py @@ -13,11 +13,7 @@ XYZ_to_Hunt, ) from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.utilities import ( - as_float_array, - domain_range_scale, - ignore_numpy_errors, -) +from colour.utilities import as_float_array, domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/tests/test_nayatani95.py b/colour/appearance/tests/test_nayatani95.py index 470a087ca..573de5c9d 100644 --- a/colour/appearance/tests/test_nayatani95.py +++ b/colour/appearance/tests/test_nayatani95.py @@ -8,11 +8,7 @@ from colour.appearance import XYZ_to_Nayatani95 from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.utilities import ( - as_float_array, - domain_range_scale, - ignore_numpy_errors, -) +from colour.utilities import as_float_array, domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/appearance/tests/test_rlab.py b/colour/appearance/tests/test_rlab.py index 470a087ca..573de5c9d 100644 --- a/colour/appearance/tests/test_rlab.py +++ b/colour/appearance/tests/test_rlab.py @@ -8,11 +8,7 @@ from colour.appearance import XYZ_to_Nayatani95 from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.utilities import ( - as_float_array, - domain_range_scale, - ignore_numpy_errors, -) +from colour.utilities import as_float_array, domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index 3cee070e1..ec986b91a 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -38,11 +38,7 @@ if typing.TYPE_CHECKING: from colour.characterisation import RGB_DisplayPrimaries -from colour.colorimetry import ( - LMS_ConeFundamentals, - SpectralShape, - reshape_msds, -) +from colour.colorimetry import LMS_ConeFundamentals, SpectralShape, reshape_msds if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index dfae9928f..0d81fbc4c 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -62,10 +62,7 @@ from scipy.optimize import minimize from colour.adaptation import matrix_chromatic_adaptation_VonKries -from colour.algebra import ( - euclidean_distance, - vecmul, -) +from colour.algebra import euclidean_distance, vecmul from colour.characterisation import ( MSDS_ACES_RICD, RGB_CameraSensitivities, @@ -98,13 +95,7 @@ from colour.hints import cast from colour.io import read_sds_from_csv_file -from colour.models import ( - XYZ_to_Jzazbz, - XYZ_to_Lab, - XYZ_to_Oklab, - XYZ_to_xy, - xy_to_XYZ, -) +from colour.models import XYZ_to_Jzazbz, XYZ_to_Lab, XYZ_to_Oklab, XYZ_to_xy, xy_to_XYZ from colour.models.rgb import ( RGB_COLOURSPACE_ACES2065_1, RGB_Colourspace, diff --git a/colour/colorimetry/dominant.py b/colour/colorimetry/dominant.py index 32f982a57..ddc32dc02 100644 --- a/colour/colorimetry/dominant.py +++ b/colour/colorimetry/dominant.py @@ -28,19 +28,9 @@ import numpy as np import scipy.spatial.distance -from colour.algebra import ( - euclidean_distance, - sdiv, - sdiv_mode, -) -from colour.colorimetry import ( - MultiSpectralDistributions, - handle_spectral_arguments, -) -from colour.geometry import ( - extend_line_segment, - intersect_line_segments, -) +from colour.algebra import euclidean_distance, sdiv, sdiv_mode +from colour.colorimetry import MultiSpectralDistributions, handle_spectral_arguments +from colour.geometry import extend_line_segment, intersect_line_segments if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple diff --git a/colour/colorimetry/photometry.py b/colour/colorimetry/photometry.py index e90c369c6..a005a2e18 100644 --- a/colour/colorimetry/photometry.py +++ b/colour/colorimetry/photometry.py @@ -17,11 +17,7 @@ import numpy as np -from colour.colorimetry import ( - SDS_LEFS_PHOTOPIC, - SpectralDistribution, - reshape_sd, -) +from colour.colorimetry import SDS_LEFS_PHOTOPIC, SpectralDistribution, reshape_sd from colour.constants import CONSTANT_K_M from colour.utilities import as_float_scalar, optional diff --git a/colour/colorimetry/tests/test_correction.py b/colour/colorimetry/tests/test_correction.py index 6ba8e78b6..c712025f4 100644 --- a/colour/colorimetry/tests/test_correction.py +++ b/colour/colorimetry/tests/test_correction.py @@ -4,10 +4,7 @@ import numpy as np -from colour.colorimetry import ( - SpectralDistribution, - bandpass_correction_Stearns1988, -) +from colour.colorimetry import SpectralDistribution, bandpass_correction_Stearns1988 from colour.constants import TOLERANCE_ABSOLUTE_TESTS __author__ = "Colour Developers" diff --git a/colour/colorimetry/tests/test_dominant.py b/colour/colorimetry/tests/test_dominant.py index 7f7f92a1b..5610d63b7 100644 --- a/colour/colorimetry/tests/test_dominant.py +++ b/colour/colorimetry/tests/test_dominant.py @@ -14,9 +14,7 @@ dominant_wavelength, excitation_purity, ) -from colour.colorimetry.dominant import ( - closest_spectral_locus_wavelength, -) +from colour.colorimetry.dominant import closest_spectral_locus_wavelength from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.models import XYZ_to_xy from colour.utilities import ignore_numpy_errors diff --git a/colour/colorimetry/tests/test_yellowness.py b/colour/colorimetry/tests/test_yellowness.py index 560e50359..6cae1e594 100644 --- a/colour/colorimetry/tests/test_yellowness.py +++ b/colour/colorimetry/tests/test_yellowness.py @@ -11,10 +11,7 @@ yellowness_ASTME313, yellowness_ASTME313_alternative, ) -from colour.colorimetry.yellowness import ( - YELLOWNESS_COEFFICIENTS_ASTME313, - yellowness, -) +from colour.colorimetry.yellowness import YELLOWNESS_COEFFICIENTS_ASTME313, yellowness from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.utilities import domain_range_scale, ignore_numpy_errors diff --git a/colour/colorimetry/whiteness.py b/colour/colorimetry/whiteness.py index 069fc9e68..6f4faa48e 100644 --- a/colour/colorimetry/whiteness.py +++ b/colour/colorimetry/whiteness.py @@ -48,6 +48,7 @@ if typing.TYPE_CHECKING: from colour.hints import Any, ArrayLike, Literal, NDArrayFloat + from colour.utilities import ( CanonicalMapping, as_float, diff --git a/colour/constants/cie.py b/colour/constants/cie.py index 5634cb555..7df09e61d 100644 --- a/colour/constants/cie.py +++ b/colour/constants/cie.py @@ -12,10 +12,7 @@ ISBN:978-0-471-39918-6 """ -from colour.utilities.documentation import ( - DocstringFloat, - is_documentation_building, -) +from colour.utilities.documentation import DocstringFloat, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/constants/codata.py b/colour/constants/codata.py index 034804df1..865cadacc 100644 --- a/colour/constants/codata.py +++ b/colour/constants/codata.py @@ -6,10 +6,7 @@ Science and Technology (CODATA). """ -from colour.utilities.documentation import ( - DocstringFloat, - is_documentation_building, -) +from colour.utilities.documentation import DocstringFloat, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/constants/common.py b/colour/constants/common.py index f8033eeb7..44e7c403e 100644 --- a/colour/constants/common.py +++ b/colour/constants/common.py @@ -13,10 +13,7 @@ import numpy as np from colour.hints import DTypeFloat, Type, cast -from colour.utilities.documentation import ( - DocstringFloat, - is_documentation_building, -) +from colour.utilities.documentation import DocstringFloat, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 596512d39..4f2c6d562 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -12,17 +12,7 @@ import typing from collections.abc import Iterator, KeysView, Mapping, Sequence, ValuesView from operator import pow # noqa: A004 -from operator import ( - add, - iadd, - imul, - ipow, - isub, - itruediv, - mul, - sub, - truediv, -) +from operator import add, iadd, imul, ipow, isub, itruediv, mul, sub, truediv import numpy as np diff --git a/colour/continuous/tests/test_multi_signal.py b/colour/continuous/tests/test_multi_signal.py index a2ad76680..46822ed8d 100644 --- a/colour/continuous/tests/test_multi_signal.py +++ b/colour/continuous/tests/test_multi_signal.py @@ -8,11 +8,7 @@ import numpy as np import pytest -from colour.algebra import ( - CubicSplineInterpolator, - Extrapolator, - KernelInterpolator, -) +from colour.algebra import CubicSplineInterpolator, Extrapolator, KernelInterpolator from colour.constants import DTYPE_FLOAT_DEFAULT, TOLERANCE_ABSOLUTE_TESTS from colour.continuous import MultiSignals, Signal from colour.utilities import ( diff --git a/colour/continuous/tests/test_signal.py b/colour/continuous/tests/test_signal.py index 7043d3429..10a39ca98 100644 --- a/colour/continuous/tests/test_signal.py +++ b/colour/continuous/tests/test_signal.py @@ -8,11 +8,7 @@ import numpy as np import pytest -from colour.algebra import ( - CubicSplineInterpolator, - Extrapolator, - KernelInterpolator, -) +from colour.algebra import CubicSplineInterpolator, Extrapolator, KernelInterpolator from colour.constants import DTYPE_FLOAT_DEFAULT, TOLERANCE_ABSOLUTE_TESTS from colour.continuous import Signal from colour.utilities import ColourRuntimeWarning, attest, is_pandas_installed diff --git a/colour/corresponding/datasets/breneman1987.py b/colour/corresponding/datasets/breneman1987.py index 84fc6fa92..886947d2d 100644 --- a/colour/corresponding/datasets/breneman1987.py +++ b/colour/corresponding/datasets/breneman1987.py @@ -24,10 +24,7 @@ from colour.hints import NDArrayFloat, Tuple from colour.utilities import MixinDataclassIterable, as_float_array -from colour.utilities.documentation import ( - DocstringDict, - is_documentation_building, -) +from colour.utilities.documentation import DocstringDict, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/difference/cam16_ucs.py b/colour/difference/cam16_ucs.py index 62de1db86..ae95f7462 100644 --- a/colour/difference/cam16_ucs.py +++ b/colour/difference/cam16_ucs.py @@ -24,9 +24,7 @@ delta_E_CAM02UCS, delta_E_Luo2006, ) -from colour.models.cam16_ucs import ( - _UCS_Luo2006_callable_to_UCS_Li2017_docstring, -) +from colour.models.cam16_ucs import _UCS_Luo2006_callable_to_UCS_Li2017_docstring from colour.utilities import copy_definition __author__ = "Colour Developers" diff --git a/colour/difference/delta_e.py b/colour/difference/delta_e.py index f00a68e44..687471bd4 100644 --- a/colour/difference/delta_e.py +++ b/colour/difference/delta_e.py @@ -63,10 +63,7 @@ tsplit, zeros, ) -from colour.utilities.documentation import ( - DocstringFloat, - is_documentation_building, -) +from colour.utilities.documentation import DocstringFloat, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/difference/stress.py b/colour/difference/stress.py index 384a29a7f..3465f607a 100644 --- a/colour/difference/stress.py +++ b/colour/difference/stress.py @@ -29,12 +29,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat -from colour.utilities import ( - CanonicalMapping, - as_float, - as_float_array, - validate_method, -) +from colour.utilities import CanonicalMapping, as_float, as_float_array, validate_method __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/difference/tests/test_cam02_ucs.py b/colour/difference/tests/test_cam02_ucs.py index 7e99c2ca7..a8d5f6e64 100644 --- a/colour/difference/tests/test_cam02_ucs.py +++ b/colour/difference/tests/test_cam02_ucs.py @@ -7,11 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.difference import ( - delta_E_CAM02LCD, - delta_E_CAM02SCD, - delta_E_CAM02UCS, -) +from colour.difference import delta_E_CAM02LCD, delta_E_CAM02SCD, delta_E_CAM02UCS from colour.difference.cam02_ucs import delta_E_Luo2006 from colour.models.cam02_ucs import COEFFICIENTS_UCS_LUO2006 from colour.utilities import ignore_numpy_errors diff --git a/colour/examples/plotting/examples_blindness.py b/colour/examples/plotting/examples_blindness.py index 3d3266022..6903ae561 100644 --- a/colour/examples/plotting/examples_blindness.py +++ b/colour/examples/plotting/examples_blindness.py @@ -5,11 +5,7 @@ import numpy as np import colour -from colour.plotting import ( - colour_style, - plot_cvd_simulation_Machado2009, - plot_image, -) +from colour.plotting import colour_style, plot_cvd_simulation_Machado2009, plot_image from colour.utilities.verbose import message_box ROOT_RESOURCES = os.path.join(os.path.dirname(__file__), "resources") diff --git a/colour/examples/plotting/examples_characterisation_plots.py b/colour/examples/plotting/examples_characterisation_plots.py index 119125984..b3853723f 100644 --- a/colour/examples/plotting/examples_characterisation_plots.py +++ b/colour/examples/plotting/examples_characterisation_plots.py @@ -3,11 +3,7 @@ from pprint import pprint import colour -from colour.plotting import ( - colour_style, - plot_multi_sds, - plot_single_colour_checker, -) +from colour.plotting import colour_style, plot_multi_sds, plot_single_colour_checker from colour.utilities import message_box message_box("Characterisation Plots") diff --git a/colour/examples/plotting/examples_corresponding.py b/colour/examples/plotting/examples_corresponding.py index 6935db676..ef99f59c6 100644 --- a/colour/examples/plotting/examples_corresponding.py +++ b/colour/examples/plotting/examples_corresponding.py @@ -1,9 +1,6 @@ """Showcase corresponding chromaticities prediction plotting examples.""" -from colour.plotting import ( - colour_style, - plot_corresponding_chromaticities_prediction, -) +from colour.plotting import colour_style, plot_corresponding_chromaticities_prediction from colour.utilities import message_box message_box("Corresponding Chromaticities Prediction Plots") diff --git a/colour/examples/plotting/examples_tm3018.py b/colour/examples/plotting/examples_tm3018.py index 3c462ec5d..d7502524c 100644 --- a/colour/examples/plotting/examples_tm3018.py +++ b/colour/examples/plotting/examples_tm3018.py @@ -1,10 +1,7 @@ """Showcase *ANSI/IES TM-30-18 Colour Rendition Report* plotting examples.""" import colour -from colour.plotting import ( - colour_style, - plot_single_sd_colour_rendition_report, -) +from colour.plotting import colour_style, plot_single_sd_colour_rendition_report from colour.utilities import message_box message_box("ANSI/IES TM-30-18 Colour Rendition Report") diff --git a/colour/examples/plotting/examples_volume_plots.py b/colour/examples/plotting/examples_volume_plots.py index e2e66ff45..177423c77 100644 --- a/colour/examples/plotting/examples_volume_plots.py +++ b/colour/examples/plotting/examples_volume_plots.py @@ -2,11 +2,7 @@ import numpy as np -from colour.plotting import ( - colour_style, - plot_RGB_colourspaces_gamuts, - plot_RGB_scatter, -) +from colour.plotting import colour_style, plot_RGB_colourspaces_gamuts, plot_RGB_scatter from colour.utilities import message_box message_box("Colour Models Volume and Gamut Plots") diff --git a/colour/geometry/ellipse.py b/colour/geometry/ellipse.py index 48d752ca7..75c05c50e 100644 --- a/colour/geometry/ellipse.py +++ b/colour/geometry/ellipse.py @@ -29,13 +29,7 @@ from colour.hints import ArrayLike, Literal from colour.hints import NDArrayFloat, cast -from colour.utilities import ( - CanonicalMapping, - ones, - tsplit, - tstack, - validate_method, -) +from colour.utilities import CanonicalMapping, ones, tsplit, tstack, validate_method __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/geometry/primitives.py b/colour/geometry/primitives.py index 0308ab282..00ff2b0a4 100644 --- a/colour/geometry/primitives.py +++ b/colour/geometry/primitives.py @@ -36,10 +36,7 @@ Type, ) -from colour.hints import ( - NDArrayFloat, - cast, -) +from colour.hints import NDArrayFloat, cast from colour.utilities import ( CanonicalMapping, as_int_array, diff --git a/colour/geometry/section.py b/colour/geometry/section.py index c62419f69..81ce2128e 100644 --- a/colour/geometry/section.py +++ b/colour/geometry/section.py @@ -20,12 +20,7 @@ from colour.hints import ArrayLike, Literal, NDArrayFloat from colour.hints import List, cast -from colour.utilities import ( - as_float_array, - as_float_scalar, - required, - validate_method, -) +from colour.utilities import as_float_array, as_float_scalar, required, validate_method __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/geometry/tests/test_intersection.py b/colour/geometry/tests/test_intersection.py index 18a0ede76..b8660a17d 100644 --- a/colour/geometry/tests/test_intersection.py +++ b/colour/geometry/tests/test_intersection.py @@ -5,10 +5,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.geometry import ( - extend_line_segment, - intersect_line_segments, -) +from colour.geometry import extend_line_segment, intersect_line_segments __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/geometry/tests/test_primitives.py b/colour/geometry/tests/test_primitives.py index 749803670..1daaec6f4 100644 --- a/colour/geometry/tests/test_primitives.py +++ b/colour/geometry/tests/test_primitives.py @@ -5,11 +5,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.geometry import ( - MAPPING_PLANE_TO_AXIS, - primitive_cube, - primitive_grid, -) +from colour.geometry import MAPPING_PLANE_TO_AXIS, primitive_cube, primitive_grid __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/geometry/tests/test_section.py b/colour/geometry/tests/test_section.py index 67a30fbe1..6f7395a5e 100644 --- a/colour/geometry/tests/test_section.py +++ b/colour/geometry/tests/test_section.py @@ -7,11 +7,7 @@ from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.geometry import hull_section, primitive_cube -from colour.geometry.section import ( - close_chord, - edges_to_chord, - unique_vertices, -) +from colour.geometry.section import close_chord, edges_to_chord, unique_vertices from colour.utilities import is_trimesh_installed __author__ = "Colour Developers" diff --git a/colour/graph/conversion.py b/colour/graph/conversion.py index bfed2d44a..772839c23 100644 --- a/colour/graph/conversion.py +++ b/colour/graph/conversion.py @@ -76,10 +76,7 @@ Literal, ) -from colour.hints import ( - NDArrayFloat, - cast, -) +from colour.hints import NDArrayFloat, cast from colour.models import ( COLOURSPACE_MODELS_POLAR_CONVERSIONS, CAM02LCD_to_JMh_CIECAM02, diff --git a/colour/io/ctl.py b/colour/io/ctl.py index d472a0b17..0555be5c3 100644 --- a/colour/io/ctl.py +++ b/colour/io/ctl.py @@ -29,16 +29,9 @@ NDArrayFloat, ) -from colour.hints import ( - Sequence, -) +from colour.hints import Sequence from colour.io import as_3_channels_image, read_image, write_image -from colour.utilities import ( - as_float, - as_float_array, - optional, - required, -) +from colour.utilities import as_float, as_float_array, optional, required __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index 41532fb02..13c6f8bf1 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -40,12 +40,7 @@ Literal, ) -from colour.hints import ( - Dict, - NDArrayFloat, - Sequence, - Tuple, -) +from colour.hints import Dict, NDArrayFloat, Sequence, Tuple from colour.io.image import ( MAPPING_BIT_DEPTH, Image_Specification_Attribute, diff --git a/colour/io/image.py b/colour/io/image.py index 4597784bb..62fc377b7 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -25,10 +25,7 @@ Type, ) -from colour.hints import ( - NDArrayReal, - cast, -) +from colour.hints import NDArrayReal, cast from colour.utilities import ( CanonicalMapping, as_float_array, diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index a92197df2..c7373dffb 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -16,17 +16,7 @@ from abc import ABC, abstractmethod from copy import deepcopy from operator import pow # noqa: A004 -from operator import ( - add, - iadd, - imul, - ipow, - isub, - itruediv, - mul, - sub, - truediv, -) +from operator import add, iadd, imul, ipow, isub, itruediv, mul, sub, truediv import numpy as np from scipy.spatial import KDTree @@ -49,10 +39,7 @@ Type, ) -from colour.hints import ( - List, - cast, -) +from colour.hints import List, cast from colour.utilities import ( as_array, as_float_array, diff --git a/colour/io/luts/operator.py b/colour/io/luts/operator.py index eb0e51784..2f2e31494 100644 --- a/colour/io/luts/operator.py +++ b/colour/io/luts/operator.py @@ -26,14 +26,7 @@ Sequence, ) -from colour.utilities import ( - as_float_array, - attest, - is_iterable, - ones, - optional, - zeros, -) +from colour.utilities import as_float_array, attest, is_iterable, ones, optional, zeros __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/io/luts/sequence.py b/colour/io/luts/sequence.py index 853d77260..c980559da 100644 --- a/colour/io/luts/sequence.py +++ b/colour/io/luts/sequence.py @@ -23,9 +23,7 @@ Sequence, ) -from colour.hints import ( - ProtocolLUTSequenceItem, -) +from colour.hints import ProtocolLUTSequenceItem from colour.utilities import as_float_array, attest, is_iterable __author__ = "Colour Developers" diff --git a/colour/io/luts/tests/test_iridas_cube.py b/colour/io/luts/tests/test_iridas_cube.py index 28bdb53fd..ec050c571 100644 --- a/colour/io/luts/tests/test_iridas_cube.py +++ b/colour/io/luts/tests/test_iridas_cube.py @@ -10,12 +10,7 @@ from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.hints import cast -from colour.io import ( - LUT1D, - LUTSequence, - read_LUT_IridasCube, - write_LUT_IridasCube, -) +from colour.io import LUT1D, LUTSequence, read_LUT_IridasCube, write_LUT_IridasCube __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/io/luts/tests/test_sony_spi3d.py b/colour/io/luts/tests/test_sony_spi3d.py index d81dfed7e..d9dab110a 100644 --- a/colour/io/luts/tests/test_sony_spi3d.py +++ b/colour/io/luts/tests/test_sony_spi3d.py @@ -9,12 +9,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.io import ( - LUT3D, - LUTSequence, - read_LUT_SonySPI3D, - write_LUT_SonySPI3D, -) +from colour.io import LUT3D, LUTSequence, read_LUT_SonySPI3D, write_LUT_SonySPI3D from colour.utilities import as_int_array __author__ = "Colour Developers" diff --git a/colour/io/tests/test_uprtek_sekonic.py b/colour/io/tests/test_uprtek_sekonic.py index 27abd551a..0c6b9cff7 100644 --- a/colour/io/tests/test_uprtek_sekonic.py +++ b/colour/io/tests/test_uprtek_sekonic.py @@ -15,10 +15,7 @@ if typing.TYPE_CHECKING: from colour.hints import Any -from colour.io import ( - SpectralDistribution_Sekonic, - SpectralDistribution_UPRTek, -) +from colour.io import SpectralDistribution_Sekonic, SpectralDistribution_UPRTek __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/cie_luv.py b/colour/models/cie_luv.py index 062ca723a..4634a4cef 100644 --- a/colour/models/cie_luv.py +++ b/colour/models/cie_luv.py @@ -35,11 +35,7 @@ import numpy as np from colour.algebra import sdiv, sdiv_mode -from colour.colorimetry import ( - CCS_ILLUMINANTS, - lightness_CIE1976, - luminance_CIE1976, -) +from colour.colorimetry import CCS_ILLUMINANTS, lightness_CIE1976, luminance_CIE1976 if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat diff --git a/colour/models/cie_ucs.py b/colour/models/cie_ucs.py index 87dedb086..ed9713876 100644 --- a/colour/models/cie_ucs.py +++ b/colour/models/cie_ucs.py @@ -33,12 +33,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - from_range_1, - to_domain_1, - tsplit, - tstack, -) +from colour.utilities import from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/cie_uvw.py b/colour/models/cie_uvw.py index c830c0016..fb5e67082 100644 --- a/colour/models/cie_uvw.py +++ b/colour/models/cie_uvw.py @@ -24,13 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.models import ( - UCS_uv_to_xy, - XYZ_to_xy, - xy_to_UCS_uv, - xyY_to_xy, - xyY_to_XYZ, -) +from colour.models import UCS_uv_to_xy, XYZ_to_xy, xy_to_UCS_uv, xyY_to_xy, xyY_to_XYZ from colour.utilities import from_range_100, to_domain_100, tsplit, tstack __author__ = "Colour Developers" diff --git a/colour/models/common.py b/colour/models/common.py index ff30174f0..c2d8869ac 100644 --- a/colour/models/common.py +++ b/colour/models/common.py @@ -38,10 +38,7 @@ tsplit, tstack, ) -from colour.utilities.documentation import ( - DocstringTuple, - is_documentation_building, -) +from colour.utilities.documentation import DocstringTuple, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/hdr_cie_lab.py b/colour/models/hdr_cie_lab.py index 979b46ec3..15ad6dbbd 100644 --- a/colour/models/hdr_cie_lab.py +++ b/colour/models/hdr_cie_lab.py @@ -50,10 +50,7 @@ tstack, validate_method, ) -from colour.utilities.documentation import ( - DocstringTuple, - is_documentation_building, -) +from colour.utilities.documentation import DocstringTuple, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/hdr_ipt.py b/colour/models/hdr_ipt.py index 12565c32b..b7ef366ac 100644 --- a/colour/models/hdr_ipt.py +++ b/colour/models/hdr_ipt.py @@ -53,10 +53,7 @@ to_domain_100, validate_method, ) -from colour.utilities.documentation import ( - DocstringTuple, - is_documentation_building, -) +from colour.utilities.documentation import DocstringTuple, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/icacb.py b/colour/models/icacb.py index 2de78d6ea..272e4bcb4 100644 --- a/colour/models/icacb.py +++ b/colour/models/icacb.py @@ -23,10 +23,7 @@ from colour.hints import ArrayLike, NDArrayFloat from colour.models import Iab_to_XYZ, XYZ_to_Iab -from colour.models.rgb.transfer_functions import ( - eotf_inverse_ST2084, - eotf_ST2084, -) +from colour.models.rgb.transfer_functions import eotf_inverse_ST2084, eotf_ST2084 from colour.utilities import domain_range_scale __author__ = "Colour Developers" diff --git a/colour/models/jzazbz.py b/colour/models/jzazbz.py index aaf6e3a7d..c0e627f82 100644 --- a/colour/models/jzazbz.py +++ b/colour/models/jzazbz.py @@ -32,10 +32,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat -from colour.models.rgb.transfer_functions import ( - eotf_inverse_ST2084, - eotf_ST2084, -) +from colour.models.rgb.transfer_functions import eotf_inverse_ST2084, eotf_ST2084 from colour.models.rgb.transfer_functions.st_2084 import CONSTANTS_ST2084 from colour.utilities import ( Structure, @@ -46,10 +43,7 @@ tstack, validate_method, ) -from colour.utilities.documentation import ( - DocstringTuple, - is_documentation_building, -) +from colour.utilities.documentation import DocstringTuple, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/cmyk.py b/colour/models/rgb/cmyk.py index 057b1e696..3501b1400 100644 --- a/colour/models/rgb/cmyk.py +++ b/colour/models/rgb/cmyk.py @@ -30,13 +30,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float_array, - from_range_1, - to_domain_1, - tsplit, - tstack, -) +from colour.utilities import as_float_array, from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/cylindrical.py b/colour/models/rgb/cylindrical.py index 2c6a08f7e..e9959482f 100644 --- a/colour/models/rgb/cylindrical.py +++ b/colour/models/rgb/cylindrical.py @@ -57,13 +57,7 @@ from colour.hints import NDArrayFloat from colour.hints import ArrayLike, cast -from colour.utilities import ( - as_float_array, - from_range_1, - to_domain_1, - tsplit, - tstack, -) +from colour.utilities import as_float_array, from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py index 8f79116a2..16b86544e 100644 --- a/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py +++ b/colour/models/rgb/datasets/adobe_wide_gamut_rgb.py @@ -25,11 +25,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/apple_rgb.py b/colour/models/rgb/datasets/apple_rgb.py index e724953e6..aff4f5703 100644 --- a/colour/models/rgb/datasets/apple_rgb.py +++ b/colour/models/rgb/datasets/apple_rgb.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/best_rgb.py b/colour/models/rgb/datasets/best_rgb.py index 4153cf9c3..d9610009e 100644 --- a/colour/models/rgb/datasets/best_rgb.py +++ b/colour/models/rgb/datasets/best_rgb.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/beta_rgb.py b/colour/models/rgb/datasets/beta_rgb.py index 1c4b03e14..c38ef9039 100644 --- a/colour/models/rgb/datasets/beta_rgb.py +++ b/colour/models/rgb/datasets/beta_rgb.py @@ -25,11 +25,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/color_match_rgb.py b/colour/models/rgb/datasets/color_match_rgb.py index 6376ac821..ba39e2845 100644 --- a/colour/models/rgb/datasets/color_match_rgb.py +++ b/colour/models/rgb/datasets/color_match_rgb.py @@ -25,11 +25,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/dci_p3.py b/colour/models/rgb/datasets/dci_p3.py index 65f34c86e..5beffa61b 100644 --- a/colour/models/rgb/datasets/dci_p3.py +++ b/colour/models/rgb/datasets/dci_p3.py @@ -36,11 +36,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/don_rgb_4.py b/colour/models/rgb/datasets/don_rgb_4.py index a794335f6..d24df620d 100644 --- a/colour/models/rgb/datasets/don_rgb_4.py +++ b/colour/models/rgb/datasets/don_rgb_4.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/eci_rgb_v2.py b/colour/models/rgb/datasets/eci_rgb_v2.py index 97112489f..14147747c 100644 --- a/colour/models/rgb/datasets/eci_rgb_v2.py +++ b/colour/models/rgb/datasets/eci_rgb_v2.py @@ -20,11 +20,7 @@ import numpy as np -from colour.colorimetry import ( - CCS_ILLUMINANTS, - lightness_CIE1976, - luminance_CIE1976, -) +from colour.colorimetry import CCS_ILLUMINANTS, lightness_CIE1976, luminance_CIE1976 if typing.TYPE_CHECKING: from colour.hints import ( diff --git a/colour/models/rgb/datasets/ekta_space_ps5.py b/colour/models/rgb/datasets/ekta_space_ps5.py index 78c6fe6b4..0266c96d4 100644 --- a/colour/models/rgb/datasets/ekta_space_ps5.py +++ b/colour/models/rgb/datasets/ekta_space_ps5.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/itur_bt_470.py b/colour/models/rgb/datasets/itur_bt_470.py index 384abc2af..24a485a6f 100644 --- a/colour/models/rgb/datasets/itur_bt_470.py +++ b/colour/models/rgb/datasets/itur_bt_470.py @@ -28,11 +28,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/max_rgb.py b/colour/models/rgb/datasets/max_rgb.py index 935652db2..90bc96bfa 100644 --- a/colour/models/rgb/datasets/max_rgb.py +++ b/colour/models/rgb/datasets/max_rgb.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/nikon_n_gamut.py b/colour/models/rgb/datasets/nikon_n_gamut.py index 90e2efa97..618b97538 100644 --- a/colour/models/rgb/datasets/nikon_n_gamut.py +++ b/colour/models/rgb/datasets/nikon_n_gamut.py @@ -21,11 +21,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - log_decoding_NLog, - log_encoding_NLog, -) +from colour.models.rgb import RGB_Colourspace, log_decoding_NLog, log_encoding_NLog from colour.models.rgb.datasets.itur_bt_2020 import ( CCS_WHITEPOINT_BT2020, MATRIX_BT2020_TO_XYZ, diff --git a/colour/models/rgb/datasets/p3_d65.py b/colour/models/rgb/datasets/p3_d65.py index 319a4c1ef..d51f9c13d 100644 --- a/colour/models/rgb/datasets/p3_d65.py +++ b/colour/models/rgb/datasets/p3_d65.py @@ -19,11 +19,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/panasonic_v_gamut.py b/colour/models/rgb/datasets/panasonic_v_gamut.py index 171040680..917a9ddc5 100644 --- a/colour/models/rgb/datasets/panasonic_v_gamut.py +++ b/colour/models/rgb/datasets/panasonic_v_gamut.py @@ -23,11 +23,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - log_decoding_VLog, - log_encoding_VLog, -) +from colour.models.rgb import RGB_Colourspace, log_decoding_VLog, log_encoding_VLog __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/russell_rgb.py b/colour/models/rgb/datasets/russell_rgb.py index 32e538a13..5d1fc0d24 100644 --- a/colour/models/rgb/datasets/russell_rgb.py +++ b/colour/models/rgb/datasets/russell_rgb.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/smpte_c.py b/colour/models/rgb/datasets/smpte_c.py index 49751535a..e1b954b0a 100644 --- a/colour/models/rgb/datasets/smpte_c.py +++ b/colour/models/rgb/datasets/smpte_c.py @@ -26,11 +26,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/datasets/tests/test__init__.py b/colour/models/rgb/datasets/tests/test__init__.py index 96ec47bca..23781ff5c 100644 --- a/colour/models/rgb/datasets/tests/test__init__.py +++ b/colour/models/rgb/datasets/tests/test__init__.py @@ -8,10 +8,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models import ( - RGB_COLOURSPACES, - normalised_primary_matrix, -) +from colour.models import RGB_COLOURSPACES, normalised_primary_matrix from colour.utilities import ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/datasets/xtreme_rgb.py b/colour/models/rgb/datasets/xtreme_rgb.py index 09d6762a8..c13f25957 100644 --- a/colour/models/rgb/datasets/xtreme_rgb.py +++ b/colour/models/rgb/datasets/xtreme_rgb.py @@ -24,11 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import NDArrayFloat -from colour.models.rgb import ( - RGB_Colourspace, - gamma_function, - normalised_primary_matrix, -) +from colour.models.rgb import RGB_Colourspace, gamma_function, normalised_primary_matrix __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/hanbury2003.py b/colour/models/rgb/hanbury2003.py index d1da75f06..76993864d 100644 --- a/colour/models/rgb/hanbury2003.py +++ b/colour/models/rgb/hanbury2003.py @@ -26,13 +26,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - from_range_1, - to_domain_1, - tsplit, - tstack, - zeros, -) +from colour.utilities import from_range_1, to_domain_1, tsplit, tstack, zeros __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/ictcp.py b/colour/models/rgb/ictcp.py index 4c41b8c08..889dfc11e 100644 --- a/colour/models/rgb/ictcp.py +++ b/colour/models/rgb/ictcp.py @@ -49,11 +49,7 @@ oetf_BT2100_HLG, oetf_inverse_BT2100_HLG, ) -from colour.utilities import ( - as_float_array, - domain_range_scale, - validate_method, -) +from colour.utilities import as_float_array, domain_range_scale, validate_method __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/itut_h_273.py b/colour/models/rgb/itut_h_273.py index 82e1ecb99..470cb212f 100644 --- a/colour/models/rgb/itut_h_273.py +++ b/colour/models/rgb/itut_h_273.py @@ -148,10 +148,7 @@ oetf_SMPTE240M, ) from colour.utilities import message_box, multiline_str -from colour.utilities.documentation import ( - DocstringDict, - is_documentation_building, -) +from colour.utilities.documentation import DocstringDict, is_documentation_building __all__ = [ "COLOUR_PRIMARIES_ITUTH273", diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 017fde38d..86edaaf46 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -43,14 +43,9 @@ NDArrayFloat, ) -from colour.hints import ( - cast, -) +from colour.hints import cast from colour.models import xy_to_xyY, xy_to_XYZ, xyY_to_XYZ -from colour.models.rgb import ( - chromatically_adapted_primaries, - normalised_primary_matrix, -) +from colour.models.rgb import chromatically_adapted_primaries, normalised_primary_matrix from colour.utilities import ( as_float_array, attest, diff --git a/colour/models/rgb/tests/test_cmyk.py b/colour/models/rgb/tests/test_cmyk.py index eb0f6a8e2..7dbe8a5b5 100644 --- a/colour/models/rgb/tests/test_cmyk.py +++ b/colour/models/rgb/tests/test_cmyk.py @@ -7,12 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.cmyk import ( - CMY_to_CMYK, - CMY_to_RGB, - CMYK_to_CMY, - RGB_to_CMY, -) +from colour.models.rgb.cmyk import CMY_to_CMYK, CMY_to_RGB, CMYK_to_CMY, RGB_to_CMY from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/tests/test_ictcp.py b/colour/models/rgb/tests/test_ictcp.py index 926680bc7..572a8c043 100644 --- a/colour/models/rgb/tests/test_ictcp.py +++ b/colour/models/rgb/tests/test_ictcp.py @@ -7,12 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb import ( - ICtCp_to_RGB, - ICtCp_to_XYZ, - RGB_to_ICtCp, - XYZ_to_ICtCp, -) +from colour.models.rgb import ICtCp_to_RGB, ICtCp_to_XYZ, RGB_to_ICtCp, XYZ_to_ICtCp from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index d28c23a5f..4c5e25d00 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -56,13 +56,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat, NDArrayInt -from colour.utilities import ( - Structure, - as_float, - as_int, - from_range_1, - to_domain_1, -) +from colour.utilities import Structure, as_float, as_int, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/cineon.py b/colour/models/rgb/transfer_functions/cineon.py index 703c97548..c2e688789 100644 --- a/colour/models/rgb/transfer_functions/cineon.py +++ b/colour/models/rgb/transfer_functions/cineon.py @@ -24,12 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float, - as_float_array, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, as_float_array, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/dicom_gsdf.py b/colour/models/rgb/transfer_functions/dicom_gsdf.py index d82822b76..30f5bf61d 100644 --- a/colour/models/rgb/transfer_functions/dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/dicom_gsdf.py @@ -32,13 +32,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat, NDArrayReal -from colour.utilities import ( - Structure, - as_float, - as_int, - from_range_1, - to_domain_1, -) +from colour.utilities import Structure, as_float, as_int, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/exponent.py b/colour/models/rgb/transfer_functions/exponent.py index 6e584f39c..ebbf3666f 100644 --- a/colour/models/rgb/transfer_functions/exponent.py +++ b/colour/models/rgb/transfer_functions/exponent.py @@ -25,12 +25,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, Literal, NDArrayFloat -from colour.utilities import ( - as_float, - as_float_array, - validate_method, - zeros, -) +from colour.utilities import as_float, as_float_array, validate_method, zeros __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itur_bt_1361.py b/colour/models/rgb/transfer_functions/itur_bt_1361.py index d19afc817..f749059dd 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/itur_bt_1361.py @@ -29,12 +29,7 @@ from colour.hints import ArrayLike, NDArrayFloat from colour.models.rgb.transfer_functions import oetf_BT709, oetf_inverse_BT709 -from colour.utilities import ( - as_float, - domain_range_scale, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 63eda9e23..08dc87c91 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -72,9 +72,7 @@ oetf_inverse_ARIBSTDB67, oetf_inverse_BT709, ) -from colour.models.rgb.transfer_functions.arib_std_b67 import ( - CONSTANTS_ARIBSTDB67, -) +from colour.models.rgb.transfer_functions.arib_std_b67 import CONSTANTS_ARIBSTDB67 from colour.utilities import ( CanonicalMapping, Structure, diff --git a/colour/models/rgb/transfer_functions/itur_bt_601.py b/colour/models/rgb/transfer_functions/itur_bt_601.py index e1467e1a2..f46145b82 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_601.py +++ b/colour/models/rgb/transfer_functions/itur_bt_601.py @@ -29,12 +29,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float, - domain_range_scale, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/itut_h_273.py b/colour/models/rgb/transfer_functions/itut_h_273.py index f8cd4f307..da40bb4ad 100644 --- a/colour/models/rgb/transfer_functions/itut_h_273.py +++ b/colour/models/rgb/transfer_functions/itut_h_273.py @@ -42,12 +42,7 @@ eotf_inverse_sRGB, eotf_sRGB, ) -from colour.utilities import ( - as_float, - as_float_array, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, as_float_array, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index 6ee2a0c43..e3ad2616d 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -50,9 +50,7 @@ NDArrayFloat, ) -from colour.hints import ( - cast, -) +from colour.hints import cast from colour.utilities import ( as_float, as_float_array, diff --git a/colour/models/rgb/transfer_functions/panalog.py b/colour/models/rgb/transfer_functions/panalog.py index 878fd3148..9b1e18f01 100644 --- a/colour/models/rgb/transfer_functions/panalog.py +++ b/colour/models/rgb/transfer_functions/panalog.py @@ -24,12 +24,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float, - as_float_array, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, as_float_array, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/smpte_240m.py b/colour/models/rgb/transfer_functions/smpte_240m.py index 79ae66afd..3af8a3734 100644 --- a/colour/models/rgb/transfer_functions/smpte_240m.py +++ b/colour/models/rgb/transfer_functions/smpte_240m.py @@ -28,12 +28,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float, - domain_range_scale, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/srgb.py b/colour/models/rgb/transfer_functions/srgb.py index 3db8ffc5c..f8bb89dd6 100644 --- a/colour/models/rgb/transfer_functions/srgb.py +++ b/colour/models/rgb/transfer_functions/srgb.py @@ -34,12 +34,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - as_float, - domain_range_scale, - from_range_1, - to_domain_1, -) +from colour.utilities import as_float, domain_range_scale, from_range_1, to_domain_1 __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_common.py b/colour/models/rgb/transfer_functions/tests/test_common.py index a72b52206..18f68848b 100644 --- a/colour/models/rgb/transfer_functions/tests/test_common.py +++ b/colour/models/rgb/transfer_functions/tests/test_common.py @@ -6,11 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - CV_range, - full_to_legal, - legal_to_full, -) +from colour.models.rgb.transfer_functions import CV_range, full_to_legal, legal_to_full from colour.utilities import ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py index 854d7865f..7f97dd206 100644 --- a/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/tests/test_dicom_gsdf.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - eotf_DICOMGSDF, - eotf_inverse_DICOMGSDF, -) +from colour.models.rgb.transfer_functions import eotf_DICOMGSDF, eotf_inverse_DICOMGSDF from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py index d378c2e7e..99362056e 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1361.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - oetf_BT1361, - oetf_inverse_BT1361, -) +from colour.models.rgb.transfer_functions import oetf_BT1361, oetf_inverse_BT1361 from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py index 36d7ddbba..28b1d971c 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_1886.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - eotf_BT1886, - eotf_inverse_BT1886, -) +from colour.models.rgb.transfer_functions import eotf_BT1886, eotf_inverse_BT1886 from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py index 62253d167..e9f72d755 100644 --- a/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py +++ b/colour/models/rgb/transfer_functions/tests/test_itur_bt_2020.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - oetf_BT2020, - oetf_inverse_BT2020, -) +from colour.models.rgb.transfer_functions import oetf_BT2020, oetf_inverse_BT2020 from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py index 46ca315df..d74ffece3 100644 --- a/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_leica_l_log.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - log_decoding_LLog, - log_encoding_LLog, -) +from colour.models.rgb.transfer_functions import log_decoding_LLog, log_encoding_LLog from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py index 64e8f3434..797aa9da0 100644 --- a/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py +++ b/colour/models/rgb/transfer_functions/tests/test_nikon_n_log.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - log_decoding_NLog, - log_encoding_NLog, -) +from colour.models.rgb.transfer_functions import log_decoding_NLog, log_encoding_NLog from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py index 7e0e39617..73d8a88e1 100644 --- a/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py +++ b/colour/models/rgb/transfer_functions/tests/test_panasonic_vlog.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - log_decoding_VLog, - log_encoding_VLog, -) +from colour.models.rgb.transfer_functions import log_decoding_VLog, log_encoding_VLog from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/rgb/transfer_functions/tests/test_st_2084.py b/colour/models/rgb/transfer_functions/tests/test_st_2084.py index 4c052cb65..2af02a7f8 100644 --- a/colour/models/rgb/transfer_functions/tests/test_st_2084.py +++ b/colour/models/rgb/transfer_functions/tests/test_st_2084.py @@ -6,10 +6,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models.rgb.transfer_functions import ( - eotf_inverse_ST2084, - eotf_ST2084, -) +from colour.models.rgb.transfer_functions import eotf_inverse_ST2084, eotf_ST2084 from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/tests/test_din99.py b/colour/models/tests/test_din99.py index e870852e9..27af969da 100644 --- a/colour/models/tests/test_din99.py +++ b/colour/models/tests/test_din99.py @@ -7,12 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models import ( - DIN99_to_Lab, - DIN99_to_XYZ, - Lab_to_DIN99, - XYZ_to_DIN99, -) +from colour.models import DIN99_to_Lab, DIN99_to_XYZ, Lab_to_DIN99, XYZ_to_DIN99 from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/tests/test_jzazbz.py b/colour/models/tests/test_jzazbz.py index 9b2a2cc46..2493799a3 100644 --- a/colour/models/tests/test_jzazbz.py +++ b/colour/models/tests/test_jzazbz.py @@ -7,12 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models import ( - Izazbz_to_XYZ, - Jzazbz_to_XYZ, - XYZ_to_Izazbz, - XYZ_to_Jzazbz, -) +from colour.models import Izazbz_to_XYZ, Jzazbz_to_XYZ, XYZ_to_Izazbz, XYZ_to_Jzazbz from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/tests/test_yrg.py b/colour/models/tests/test_yrg.py index 3df1f5f53..bbab9c837 100644 --- a/colour/models/tests/test_yrg.py +++ b/colour/models/tests/test_yrg.py @@ -7,12 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.models import ( - LMS_to_Yrg, - XYZ_to_Yrg, - Yrg_to_LMS, - Yrg_to_XYZ, -) +from colour.models import LMS_to_Yrg, XYZ_to_Yrg, Yrg_to_LMS, Yrg_to_XYZ from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/models/yrg.py b/colour/models/yrg.py index c77e3ba0b..f022fda18 100644 --- a/colour/models/yrg.py +++ b/colour/models/yrg.py @@ -27,12 +27,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.utilities import ( - from_range_1, - to_domain_1, - tsplit, - tstack, -) +from colour.utilities import from_range_1, to_domain_1, tsplit, tstack __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index eb0341fd8..7c613f601 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -146,16 +146,9 @@ Tuple, ) -from colour.hints import ( - ArrayLike, - cast, -) +from colour.hints import ArrayLike, cast from colour.models import Lab_to_LCHab # pyright: ignore -from colour.models import ( - XYZ_to_Lab, - XYZ_to_xy, - xyY_to_XYZ, -) +from colour.models import XYZ_to_Lab, XYZ_to_xy, xyY_to_XYZ from colour.notation import MUNSELL_COLOURS_ALL from colour.utilities import ( CACHE_REGISTRY, diff --git a/colour/notation/tests/test_hexadecimal.py b/colour/notation/tests/test_hexadecimal.py index ca97f3867..a61ea7be8 100644 --- a/colour/notation/tests/test_hexadecimal.py +++ b/colour/notation/tests/test_hexadecimal.py @@ -7,10 +7,7 @@ import numpy as np from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.notation.hexadecimal import ( - HEX_to_RGB, - RGB_to_HEX, -) +from colour.notation.hexadecimal import HEX_to_RGB, RGB_to_HEX from colour.utilities import domain_range_scale, ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/plotting/colorimetry.py b/colour/plotting/colorimetry.py index 07826c5f4..774e39c5c 100644 --- a/colour/plotting/colorimetry.py +++ b/colour/plotting/colorimetry.py @@ -41,12 +41,7 @@ from matplotlib.figure import Figure from matplotlib.axes import Axes -from colour.algebra import ( - LinearInterpolator, - normalise_maximum, - sdiv, - sdiv_mode, -) +from colour.algebra import LinearInterpolator, normalise_maximum, sdiv, sdiv_mode from colour.colorimetry import ( CCS_ILLUMINANTS, LIGHTNESS_METHODS, @@ -71,10 +66,7 @@ Tuple, ) -from colour.hints import ( - List, - cast, -) +from colour.hints import List, cast from colour.plotting import ( CONSTANTS_COLOUR_STYLE, XYZ_to_plotting_colourspace, diff --git a/colour/plotting/common.py b/colour/plotting/common.py index ebe523632..ec822f65f 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -79,12 +79,7 @@ Tuple, ) -from colour.hints import ( - ArrayLike, - List, - TypedDict, - cast, -) +from colour.hints import ArrayLike, List, TypedDict, cast from colour.models import RGB_COLOURSPACES, RGB_Colourspace, XYZ_to_RGB from colour.utilities import ( CanonicalMapping, diff --git a/colour/plotting/diagrams.py b/colour/plotting/diagrams.py index ec8cb87d0..8f83058e8 100644 --- a/colour/plotting/diagrams.py +++ b/colour/plotting/diagrams.py @@ -55,10 +55,7 @@ Sequence, ) -from colour.hints import ( - Tuple, - cast, -) +from colour.hints import Tuple, cast from colour.models import ( Luv_to_uv, Luv_uv_to_xy, diff --git a/colour/plotting/graph.py b/colour/plotting/graph.py index 3e0a5d728..ef1de35aa 100644 --- a/colour/plotting/graph.py +++ b/colour/plotting/graph.py @@ -13,10 +13,7 @@ import typing import colour -from colour.graph import ( - CONVERSION_GRAPH_NODE_LABELS, - describe_conversion_path, -) +from colour.graph import CONVERSION_GRAPH_NODE_LABELS, describe_conversion_path if typing.TYPE_CHECKING: from colour.hints import Literal diff --git a/colour/plotting/models.py b/colour/plotting/models.py index 732535f12..b6c8b9a49 100644 --- a/colour/plotting/models.py +++ b/colour/plotting/models.py @@ -79,10 +79,7 @@ Tuple, ) -from colour.hints import ( - List, - cast, -) +from colour.hints import List, cast from colour.models import LCHab_to_Lab # pyright: ignore from colour.models import ( CCS_ILLUMINANT_POINTER_GAMUT, diff --git a/colour/plotting/notation.py b/colour/plotting/notation.py index fb0ad8230..417e8a3b9 100644 --- a/colour/plotting/notation.py +++ b/colour/plotting/notation.py @@ -22,11 +22,7 @@ from colour.hints import Any, Callable, Dict, Sequence, Tuple from colour.notation import MUNSELL_VALUE_METHODS -from colour.plotting import ( - filter_passthrough, - override_style, - plot_multi_functions, -) +from colour.plotting import filter_passthrough, override_style, plot_multi_functions __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/plotting/phenomena.py b/colour/plotting/phenomena.py index b71da1501..f419b69fa 100644 --- a/colour/plotting/phenomena.py +++ b/colour/plotting/phenomena.py @@ -19,10 +19,7 @@ from matplotlib.axes import Axes from colour.algebra import normalise_maximum -from colour.colorimetry import ( - MultiSpectralDistributions, - sd_to_XYZ, -) +from colour.colorimetry import MultiSpectralDistributions, sd_to_XYZ if typing.TYPE_CHECKING: from colour.hints import Any, ArrayLike, Dict, Sequence, Tuple diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index 3ad36d749..d03c65113 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -41,10 +41,7 @@ Tuple, ) -from colour.hints import ( - List, - cast, -) +from colour.hints import List, cast from colour.plotting import ( CONSTANTS_COLOUR_STYLE, XYZ_to_plotting_colourspace, diff --git a/colour/plotting/section.py b/colour/plotting/section.py index ffb182109..894c404df 100644 --- a/colour/plotting/section.py +++ b/colour/plotting/section.py @@ -47,10 +47,7 @@ Tuple, ) -from colour.hints import ( - Real, - cast, -) +from colour.hints import Real, cast from colour.models import ( COLOURSPACE_MODELS_AXIS_LABELS, COLOURSPACE_MODELS_DOMAIN_RANGE_SCALE_1_TO_REFERENCE, diff --git a/colour/plotting/temperature.py b/colour/plotting/temperature.py index b2022c3cd..17e151cdf 100644 --- a/colour/plotting/temperature.py +++ b/colour/plotting/temperature.py @@ -47,13 +47,8 @@ Tuple, ) -from colour.hints import ( - cast, -) -from colour.models import ( - UCS_uv_to_xy, - xy_to_XYZ, -) +from colour.hints import cast +from colour.models import UCS_uv_to_xy, xy_to_XYZ from colour.plotting import ( CONSTANTS_ARROW_STYLE, CONSTANTS_COLOUR_STYLE, diff --git a/colour/plotting/tests/test_characterisation.py b/colour/plotting/tests/test_characterisation.py index 5186bd32a..ce60b398c 100644 --- a/colour/plotting/tests/test_characterisation.py +++ b/colour/plotting/tests/test_characterisation.py @@ -5,10 +5,7 @@ from matplotlib.axes import Axes from matplotlib.figure import Figure -from colour.plotting import ( - plot_multi_colour_checkers, - plot_single_colour_checker, -) +from colour.plotting import plot_multi_colour_checkers, plot_single_colour_checker __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/plotting/tests/test_diagrams.py b/colour/plotting/tests/test_diagrams.py index 8dd77b54e..99b36f1e7 100644 --- a/colour/plotting/tests/test_diagrams.py +++ b/colour/plotting/tests/test_diagrams.py @@ -6,12 +6,7 @@ from matplotlib.axes import Axes from matplotlib.figure import Figure -from colour.colorimetry import ( - MSDS_CMFS, - SDS_ILLUMINANTS, - SpectralShape, - reshape_msds, -) +from colour.colorimetry import MSDS_CMFS, SDS_ILLUMINANTS, SpectralShape, reshape_msds from colour.plotting import ( lines_spectral_locus, plot_chromaticity_diagram_CIE1931, diff --git a/colour/plotting/tests/test_phenomena.py b/colour/plotting/tests/test_phenomena.py index d94268850..143eb4986 100644 --- a/colour/plotting/tests/test_phenomena.py +++ b/colour/plotting/tests/test_phenomena.py @@ -5,10 +5,7 @@ from matplotlib.axes import Axes from matplotlib.figure import Figure -from colour.plotting import ( - plot_single_sd_rayleigh_scattering, - plot_the_blue_sky, -) +from colour.plotting import plot_single_sd_rayleigh_scattering, plot_the_blue_sky __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/plotting/tests/test_section.py b/colour/plotting/tests/test_section.py index 8653bcae7..eb15b13e3 100644 --- a/colour/plotting/tests/test_section.py +++ b/colour/plotting/tests/test_section.py @@ -7,14 +7,8 @@ from colour.geometry import primitive_cube from colour.models import RGB_COLOURSPACE_sRGB, RGB_to_XYZ -from colour.plotting import ( - plot_RGB_colourspace_section, - plot_visible_spectrum_section, -) -from colour.plotting.section import ( - plot_hull_section_colours, - plot_hull_section_contour, -) +from colour.plotting import plot_RGB_colourspace_section, plot_visible_spectrum_section +from colour.plotting.section import plot_hull_section_colours, plot_hull_section_contour from colour.utilities import is_trimesh_installed __author__ = "Colour Developers" diff --git a/colour/plotting/volume.py b/colour/plotting/volume.py index 67e30c39e..e0a9fb006 100644 --- a/colour/plotting/volume.py +++ b/colour/plotting/volume.py @@ -20,10 +20,7 @@ from colour.colorimetry import MultiSpectralDistributions from colour.constants import EPSILON -from colour.geometry import ( - primitive_vertices_cube_mpl, - primitive_vertices_grid_mpl, -) +from colour.geometry import primitive_vertices_cube_mpl, primitive_vertices_grid_mpl from colour.graph import convert if typing.TYPE_CHECKING: @@ -36,12 +33,7 @@ NDArrayFloat, ) -from colour.hints import ( - List, - Sequence, - Tuple, - cast, -) +from colour.hints import List, Sequence, Tuple, cast from colour.models import RGB_Colourspace, RGB_to_XYZ from colour.models.common import COLOURSPACE_MODELS_AXIS_LABELS from colour.plotting import ( diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 597c73062..1625c7faa 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -52,29 +52,13 @@ Tuple, ) -from colour.hints import ( - cast, -) +from colour.hints import cast from colour.models import Lab_to_LCHab # pyright: ignore -from colour.models import ( - UCS_to_uv, - XYZ_to_Lab, - XYZ_to_UCS, - XYZ_to_xy, - xy_to_XYZ, -) +from colour.models import UCS_to_uv, XYZ_to_Lab, XYZ_to_UCS, XYZ_to_xy, xy_to_XYZ from colour.quality.datasets.vs import INDEXES_TO_NAMES_VS, SDS_VS from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Ohno2013 -from colour.utilities import ( - as_float_array, - domain_range_scale, - tsplit, - validate_method, -) -from colour.utilities.documentation import ( - DocstringTuple, - is_documentation_building, -) +from colour.utilities import as_float_array, domain_range_scale, tsplit, validate_method +from colour.utilities.documentation import DocstringTuple, is_documentation_building __author__ = "Colour Developers" __copyright__ = "Copyright 2013 Colour Developers" diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index fede00973..1cc4a21fb 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -7,10 +7,7 @@ from colour.colorimetry import SDS_ILLUMINANTS, SDS_LIGHT_SOURCES from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.hints import cast -from colour.quality import ( - ColourRendering_Specification_CQS, - colour_quality_scale, -) +from colour.quality import ColourRendering_Specification_CQS, colour_quality_scale from colour.quality.cqs import DataColorimetry_VS, DataColourQualityScale_VS __author__ = "Colour Developers" diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index 9349ee4ce..d671a0232 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -7,10 +7,7 @@ from colour.colorimetry import SDS_ILLUMINANTS, SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS from colour.hints import cast -from colour.quality import ( - ColourRendering_Specification_CRI, - colour_rendering_index, -) +from colour.quality import ColourRendering_Specification_CRI, colour_rendering_index from colour.quality.cri import DataColorimetry_TCS, DataColourQualityScale_TCS __author__ = "Colour Developers" diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index cd45113ce..f281013ab 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -41,9 +41,7 @@ Tuple, ) -from colour.hints import ( - cast, -) +from colour.hints import cast from colour.recovery import BASIS_FUNCTIONS_DYER2017 from colour.utilities import as_float_array, optional, runtime_warning, tsplit diff --git a/colour/recovery/smits1999.py b/colour/recovery/smits1999.py index d0ec14213..691ab73d8 100644 --- a/colour/recovery/smits1999.py +++ b/colour/recovery/smits1999.py @@ -20,11 +20,7 @@ if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat -from colour.models import ( - RGB_Colourspace, - RGB_COLOURSPACE_sRGB, - XYZ_to_RGB, -) +from colour.models import RGB_Colourspace, RGB_COLOURSPACE_sRGB, XYZ_to_RGB from colour.recovery import SDS_SMITS1999 from colour.utilities import to_domain_1 diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index cd3c0c0ce..e2e63a5c5 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -18,12 +18,7 @@ if typing.TYPE_CHECKING: from colour.hints import Type -from colour.models import ( - RGB_COLOURSPACE_sRGB, - RGB_to_XYZ, - XYZ_to_Lab, - XYZ_to_xy, -) +from colour.models import RGB_COLOURSPACE_sRGB, RGB_to_XYZ, XYZ_to_Lab, XYZ_to_xy from colour.recovery.jakob2019 import ( SPECTRAL_SHAPE_JAKOB2019, LUT3D_Jakob2019, diff --git a/colour/recovery/tests/test_jiang2013.py b/colour/recovery/tests/test_jiang2013.py index d08759c5a..301f36462 100644 --- a/colour/recovery/tests/test_jiang2013.py +++ b/colour/recovery/tests/test_jiang2013.py @@ -7,10 +7,7 @@ import numpy as np import pytest -from colour.characterisation import ( - MSDS_CAMERA_SENSITIVITIES, - SDS_COLOURCHECKERS, -) +from colour.characterisation import MSDS_CAMERA_SENSITIVITIES, SDS_COLOURCHECKERS from colour.colorimetry import ( SDS_ILLUMINANTS, SpectralDistribution, diff --git a/colour/temperature/ohno2013.py b/colour/temperature/ohno2013.py index 0a43ef5fb..a3f1ef52f 100644 --- a/colour/temperature/ohno2013.py +++ b/colour/temperature/ohno2013.py @@ -26,10 +26,7 @@ import numpy as np from colour.algebra import euclidean_distance, sdiv, sdiv_mode -from colour.colorimetry import ( - MultiSpectralDistributions, - handle_spectral_arguments, -) +from colour.colorimetry import MultiSpectralDistributions, handle_spectral_arguments if typing.TYPE_CHECKING: from colour.hints import ArrayLike, NDArrayFloat diff --git a/colour/temperature/tests/test_ohno2013.py b/colour/temperature/tests/test_ohno2013.py index 3315f7091..944020362 100644 --- a/colour/temperature/tests/test_ohno2013.py +++ b/colour/temperature/tests/test_ohno2013.py @@ -14,9 +14,7 @@ XYZ_to_CCT_Ohno2013, uv_to_CCT_Ohno2013, ) -from colour.temperature.ohno2013 import ( - planckian_table, -) +from colour.temperature.ohno2013 import planckian_table from colour.utilities import ignore_numpy_errors __author__ = "Colour Developers" diff --git a/colour/utilities/callback.py b/colour/utilities/callback.py index 8a3df821d..cfe8711a3 100644 --- a/colour/utilities/callback.py +++ b/colour/utilities/callback.py @@ -11,7 +11,7 @@ from collections import defaultdict from dataclasses import dataclass -if typing.TYPE_CHECKING: # pragma: no cover +if typing.TYPE_CHECKING: from colour.hints import Any, Callable, List __author__ = "Colour Developers" diff --git a/colour/utilities/tests/test_array.py b/colour/utilities/tests/test_array.py index 9d770ac88..8a2845563 100644 --- a/colour/utilities/tests/test_array.py +++ b/colour/utilities/tests/test_array.py @@ -206,7 +206,7 @@ def test__iter__(self) -> None: method. """ - assert {key: value for key, value in self._data} == ( # noqa: C416 + assert {key: value for key, value in self._data} == ( {"a": "Foo", "b": "Bar", "c": "Baz"} ) @@ -669,10 +669,7 @@ def test_set_default_float_dtype_enforcement(self) -> None: CAM_Specification_Kim2009, CAM_Specification_ZCAM, ) - from colour.graph.conversion import ( - CONVERSION_SPECIFICATIONS_DATA, - convert, - ) + from colour.graph.conversion import CONVERSION_SPECIFICATIONS_DATA, convert try: dtype = np.float32 diff --git a/colour/utilities/tests/test_deprecated.py b/colour/utilities/tests/test_deprecated.py index 32eebee9e..78b757611 100644 --- a/colour/utilities/tests/test_deprecated.py +++ b/colour/utilities/tests/test_deprecated.py @@ -9,11 +9,7 @@ if typing.TYPE_CHECKING: from colour.hints import Any -from colour.utilities.deprecation import ( - ModuleAPI, - ObjectRemoved, - ObjectRenamed, -) +from colour.utilities.deprecation import ModuleAPI, ObjectRemoved, ObjectRenamed class deprecated(ModuleAPI): diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index e4158f3bd..08b1023d6 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -18,11 +18,7 @@ from colour.hints import ArrayLike, Literal, NDArrayFloat from colour.models import xyY_to_XYZ -from colour.utilities import ( - CACHE_REGISTRY, - is_caching_enabled, - validate_method, -) +from colour.utilities import CACHE_REGISTRY, is_caching_enabled, validate_method from colour.volume import OPTIMAL_COLOUR_STIMULI_ILLUMINANTS __author__ = "Colour Developers" diff --git a/colour/volume/spectrum.py b/colour/volume/spectrum.py index 7b3a3c76d..c510e60bd 100644 --- a/colour/volume/spectrum.py +++ b/colour/volume/spectrum.py @@ -43,12 +43,7 @@ NDArrayFloat, ) -from colour.utilities import ( - CACHE_REGISTRY, - is_caching_enabled, - validate_method, - zeros, -) +from colour.utilities import CACHE_REGISTRY, is_caching_enabled, validate_method, zeros from colour.volume import is_within_mesh_volume __author__ = "Colour Developers" diff --git a/pyproject.toml b/pyproject.toml index 01134fcc7..c262fe9c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -148,68 +148,17 @@ filterwarnings = [ [tool.ruff] target-version = "py310" line-length = 88 -select = [ - "A", # flake8-builtins - "ARG", # flake8-unused-arguments - "ANN", # flake8-annotations - "ASYNC", # flake8-async - "B", # flake8-bugbear - # "C", # Pylint - Convention - "BLE", # flake8-blind-except - "C4", # flake8-comprehensions - # "C90", # mccabe - # "COM", # flake8-commas - "CPY", # flake8-copyright - "DTZ", # flake8-datetimez - "D", # pydocstyle - "DOC", # pydoclint - "E", # Pylint - Error - # "ERA", # eradicate - "EM", # flake8-errmsg - "EXE", # flake8-executable - "F", # flake8 - # "FIX", # flake8-fixme - "FA", # flake8-future-annotations - # "FBT", # flake8-boolean-trap - "FLY", # flynt - "FURB", # Refurb - "G", # flake8-logging-format - "I", # isort - "ICN", # flake8-import-conventions - "INP", # flake8-no-pep420 - "INT", # flake8-gettext - "ISC", # flake8-implicit-str-concat - "LOG", # flake8-logging - "N", # pep8-naming - "NPY", # Numpy - "PD", # pandas-vet - "PERF", # Perflint - "PIE", # flake8-pie - "PGH", # pygrep-hooks - "PL", # pylint - # "PT", # flake8-pytest-style - # "PTH", # flake8-use-pathlib [Enable] - "PYI", # flake8-pyi - "Q", # flake8-quotes - "R", # pylint-refactor - "RET", # flake8-return - "RSE", # flake8-raise - "RUF", # Ruff - "S", # flake8-bandit - "SLF", # flake8-self - "SLOT", # flake8-slots - "SIM", # flake8-simplify - "T10", # flake8-debugger - "T20", # flake8-print - "TC", # flake8-type-checking - # "TD", # flake8-todos - "TID", # flake8-tidy-imports - "TRY", # tryceratops - "UP", # pyupgrade - "W", # Pylint - Warning - "YTT", # flake8-2020 -] +select = ["ALL"] ignore = [ + "C", # Pylint - Convention + "C90", # mccabe + "COM", # flake8-commas + "ERA", # eradicate + "FBT", # flake8-boolean-trap + "FIX", # flake8-fixme + "PT", # flake8-pytest-style + "PTH", # flake8-use-pathlib [Enable] + "TD", # flake8-todos "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in `**kwargs` "D200", # One-line docstring should fit on one line "D202", # No blank lines allowed after function docstring diff --git a/utilities/generate_plots.py b/utilities/generate_plots.py index feda11eba..df0c2f4fb 100755 --- a/utilities/generate_plots.py +++ b/utilities/generate_plots.py @@ -115,20 +115,15 @@ plot_RGB_colourspaces_in_chromaticity_diagram, ) from colour.plotting.quality import plot_colour_quality_bars -from colour.plotting.section import ( - plot_hull_section_colours, - plot_hull_section_contour, -) +from colour.plotting.section import plot_hull_section_colours, plot_hull_section_contour from colour.plotting.temperature import ( plot_daylight_locus, plot_planckian_locus, plot_planckian_locus_in_chromaticity_diagram, ) from colour.quality import colour_quality_scale -from colour.utilities import ( # ; noqa: RUF100 - domain_range_scale, - filter_warnings, -) +from colour.utilities import domain_range_scale # ; noqa: RUF100 +from colour.utilities import filter_warnings __copyright__ = "Copyright 2013 Colour Developers" __license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" From 9cff811db3948a10dbbffe80be15cb79df5a60d4 Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 18:53:00 +1300 Subject: [PATCH 41/42] Use typing overload to improve typing annotations. --- colour/characterisation/aces_it.py | 45 ++++++++++++ colour/characterisation/tests/test_aces_it.py | 15 ++-- colour/io/fichet2021.py | 28 ++++++++ colour/io/image.py | 35 +++++++++ colour/io/tests/test_fichet2021.py | 34 ++++----- colour/io/tests/test_image.py | 71 +++++++++---------- colour/plotting/quality.py | 13 ++-- colour/plotting/tm3018/report.py | 23 ++---- .../plotting/tm3018/tests/test_components.py | 7 +- colour/quality/cfi2017.py | 20 +++++- colour/quality/cqs.py | 25 +++++++ colour/quality/cri.py | 20 +++++- colour/quality/tests/test_cfi2017.py | 17 ++--- colour/quality/tests/test_cqs.py | 58 ++++++--------- colour/quality/tests/test_cri.py | 16 ++--- colour/quality/tests/test_tm3018.py | 9 +-- colour/quality/tm3018.py | 33 +++++---- colour/recovery/jakob2019.py | 66 +++++++++++++++++ colour/recovery/jiang2013.py | 29 ++++++++ colour/recovery/tests/test_jakob2019.py | 6 +- colour/recovery/tests/test_jiang2013.py | 2 +- 21 files changed, 392 insertions(+), 180 deletions(-) diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index 0d81fbc4c..dfde6fb0b 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -87,6 +87,7 @@ Any, ArrayLike, Callable, + Literal, LiteralChromaticAdaptationTransform, Mapping, NDArrayFloat, @@ -941,6 +942,50 @@ def finaliser_function(M: ArrayLike) -> NDArrayFloat: ) +@typing.overload +def matrix_idt( + sensitivities: RGB_CameraSensitivities, + illuminant: SpectralDistribution, + training_data: MultiSpectralDistributions | None = ..., + cmfs: MultiSpectralDistributions | None = ..., + optimisation_factory: Callable = ..., + optimisation_kwargs: dict | None = ..., + chromatic_adaptation_transform: ( + LiteralChromaticAdaptationTransform | str | None + ) = ..., + additional_data: Literal[True] = True, +) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat]: ... + + +@typing.overload +def matrix_idt( + sensitivities: ..., + illuminant: ..., + training_data: MultiSpectralDistributions | None = ..., + cmfs: MultiSpectralDistributions | None = ..., + optimisation_factory: Callable = ..., + optimisation_kwargs: dict | None = ..., + chromatic_adaptation_transform: ( + LiteralChromaticAdaptationTransform | str | None + ) = ..., + *, + additional_data: Literal[False], +) -> Tuple[NDArrayFloat, NDArrayFloat]: ... + + +@typing.overload +def matrix_idt( + sensitivities: RGB_CameraSensitivities, + illuminant: SpectralDistribution, + training_data: MultiSpectralDistributions | None, + cmfs: MultiSpectralDistributions | None, + optimisation_factory: Callable, + optimisation_kwargs: dict | None, + chromatic_adaptation_transform: (LiteralChromaticAdaptationTransform | str | None), + additional_data: Literal[False], +) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat]: ... + + def matrix_idt( sensitivities: RGB_CameraSensitivities, illuminant: SpectralDistribution, diff --git a/colour/characterisation/tests/test_aces_it.py b/colour/characterisation/tests/test_aces_it.py index 3a541c097..31c659922 100644 --- a/colour/characterisation/tests/test_aces_it.py +++ b/colour/characterisation/tests/test_aces_it.py @@ -1017,10 +1017,11 @@ def test_matrix_idt(self) -> None: atol=0.0001, ) - M, RGB_w = matrix_idt( # pyright: ignore + M, RGB_w = matrix_idt( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_factory=optimisation_factory_Jzazbz, + additional_data=False, ) np.testing.assert_allclose( M, @@ -1038,10 +1039,11 @@ def test_matrix_idt(self) -> None: np.array([2.34141541, 1.00000000, 1.51633759]), atol=0.0001, ) - M, RGB_w = matrix_idt( # pyright: ignore + M, RGB_w = matrix_idt( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_factory=optimisation_factory_Oklab_15, + additional_data=False, ) np.testing.assert_allclose( M, @@ -1081,10 +1083,11 @@ def test_matrix_idt(self) -> None: atol=0.0001, ) - M, RGB_w = matrix_idt( # pyright: ignore + M, RGB_w = matrix_idt( MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], optimisation_kwargs={"method": "Nelder-Mead"}, + additional_data=False, ) np.testing.assert_allclose( M, @@ -1128,7 +1131,7 @@ def test_matrix_idt(self) -> None: np.testing.assert_allclose( matrix_idt( - MSDS_CANON_EOS_5DMARK_II, # pyright: ignore + MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], chromatic_adaptation_transform="Bradford", )[0], @@ -1142,8 +1145,8 @@ def test_matrix_idt(self) -> None: atol=0.0001, ) - _M, RGB_w, XYZ, RGB = matrix_idt( # pyright: ignore - MSDS_CANON_EOS_5DMARK_II, # pyright: ignore + _M, RGB_w, XYZ, RGB = matrix_idt( + MSDS_CANON_EOS_5DMARK_II, SDS_ILLUMINANTS["D55"], additional_data=True, ) diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index 13c6f8bf1..fe11b2163 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -425,6 +425,34 @@ def from_spectral_image(path: str | Path) -> Specification_Fichet2021: """ +@typing.overload +@required("OpenImageIO") +def read_spectral_image_Fichet2021( + path: str | Path, + bit_depth: Literal["float16", "float32"] = ..., + additional_data: Literal[True] = True, +) -> Tuple[ComponentsFichet2021, Specification_Fichet2021]: ... + + +@typing.overload +@required("OpenImageIO") +def read_spectral_image_Fichet2021( + path: str | Path, + bit_depth: Literal["float16", "float32"] = ..., + *, + additional_data: Literal[False], +) -> ComponentsFichet2021: ... + + +@typing.overload +@required("OpenImageIO") +def read_spectral_image_Fichet2021( + path: str | Path, + bit_depth: Literal["float16", "float32"], + additional_data: bool = False, +) -> ComponentsFichet2021: ... + + @required("OpenImageIO") def read_spectral_image_Fichet2021( path: str | Path, diff --git a/colour/io/image.py b/colour/io/image.py index 62fc377b7..e2acbd983 100644 --- a/colour/io/image.py +++ b/colour/io/image.py @@ -329,6 +329,41 @@ def convert_bit_depth( return a +@typing.overload +@required("OpenImageIO") +def read_image_OpenImageIO( + path: str | Path, + bit_depth: Literal[ + "uint8", "uint16", "float16", "float32", "float64", "float128" + ] = ..., + additional_data: Literal[True] = True, + **kwargs: Any, +) -> Tuple[NDArrayReal, Tuple[Image_Specification_Attribute, ...]]: ... + + +@typing.overload +@required("OpenImageIO") +def read_image_OpenImageIO( + path: str | Path, + bit_depth: Literal[ + "uint8", "uint16", "float16", "float32", "float64", "float128" + ] = ..., + *, + additional_data: Literal[False], + **kwargs: Any, +) -> NDArrayReal: ... + + +@typing.overload +@required("OpenImageIO") +def read_image_OpenImageIO( + path: str | Path, + bit_depth: Literal["uint8", "uint16", "float16", "float32", "float64", "float128"], + additional_data: Literal[False], + **kwargs: Any, +) -> NDArrayReal: ... + + @required("OpenImageIO") def read_image_OpenImageIO( path: str | Path, diff --git a/colour/io/tests/test_fichet2021.py b/colour/io/tests/test_fichet2021.py index 36a78e7c0..3752eb722 100644 --- a/colour/io/tests/test_fichet2021.py +++ b/colour/io/tests/test_fichet2021.py @@ -16,9 +16,8 @@ sds_and_msds_to_msds, ) from colour.constants import CONSTANT_LIGHT_SPEED, TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayFloat, Tuple, cast +from colour.hints import NDArrayFloat, cast from colour.io import ( - ComponentsFichet2021, Specification_Fichet2021, read_spectral_image_Fichet2021, sd_to_spectrum_attribute_Fichet2021, @@ -296,7 +295,7 @@ def test_components_to_sRGB_Fichet2021(self) -> None: def _test_spectral_image_D65(path: str) -> None: """Test the *D65* spectral image.""" - components = cast(ComponentsFichet2021, read_spectral_image_Fichet2021(path)) + components = read_spectral_image_Fichet2021(path, additional_data=False) assert "S0" in components @@ -312,11 +311,8 @@ def _test_spectral_image_D65(path: str) -> None: atol=0.05, ) - components, specification = cast( - Tuple[ComponentsFichet2021, Specification_Fichet2021], - read_spectral_image_Fichet2021( - os.path.join(ROOT_RESOURCES, "D65.exr"), additional_data=True - ), + components, specification = read_spectral_image_Fichet2021( + os.path.join(ROOT_RESOURCES, "D65.exr"), additional_data=True ) assert specification.is_emissive is True @@ -357,9 +353,8 @@ def _test_spectral_image_D65(path: str) -> None: def _test_spectral_image_Ohta1997(path: str) -> None: """Test the *Ohta (1997)* spectral image.""" - components, specification = cast( - Tuple[ComponentsFichet2021, Specification_Fichet2021], - read_spectral_image_Fichet2021(path, additional_data=True), + components, specification = read_spectral_image_Fichet2021( + path, additional_data=True ) assert "T" in components @@ -391,9 +386,8 @@ def _test_spectral_image_Ohta1997(path: str) -> None: def _test_spectral_image_Polarised(path: str) -> None: """Test the *Polarised* spectral image.""" - components, specification = cast( - Tuple[ComponentsFichet2021, Specification_Fichet2021], - read_spectral_image_Fichet2021(path, additional_data=True), + components, specification = read_spectral_image_Fichet2021( + path, additional_data=True ) assert list(components.keys()) == ["S0", "S1", "S2", "S3"] @@ -406,9 +400,8 @@ def _test_spectral_image_Polarised(path: str) -> None: def _test_spectral_image_BiSpectral(path: str) -> None: """Test the *Bi-Spectral* image.""" - components, specification = cast( - Tuple[ComponentsFichet2021, Specification_Fichet2021], - read_spectral_image_Fichet2021(path, additional_data=True), + components, specification = read_spectral_image_Fichet2021( + path, additional_data=True ) assert list(components.keys()) == [ @@ -531,11 +524,8 @@ def test_write_spectral_image_Fichet2021(self) -> None: ("Polarised.exr", _test_spectral_image_Polarised), ("BiSpectral.exr", _test_spectral_image_BiSpectral), ]: - components, specification = cast( - Tuple[ComponentsFichet2021, Specification_Fichet2021], - read_spectral_image_Fichet2021( - os.path.join(ROOT_RESOURCES, basename), additional_data=True - ), + components, specification = read_spectral_image_Fichet2021( + os.path.join(ROOT_RESOURCES, basename), additional_data=True ) path = os.path.join(self._temporary_directory, basename) write_spectral_image_Fichet2021(components, path, "float16", specification) diff --git a/colour/io/tests/test_image.py b/colour/io/tests/test_image.py index d45338455..1482a3523 100644 --- a/colour/io/tests/test_image.py +++ b/colour/io/tests/test_image.py @@ -11,7 +11,6 @@ import pytest from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import NDArrayReal, Tuple, cast from colour.io import ( Image_Specification_Attribute, as_3_channels_image, @@ -279,57 +278,48 @@ def test_read_image_OpenImageIO(self) -> None: # pragma: no cover if not is_openimageio_installed(): return - image = cast( - NDArrayReal, - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") - ), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), + additional_data=False, ) assert image.shape == (1267, 1274, 3) assert image.dtype is np.dtype("float32") - image = cast( - NDArrayReal, - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), - "float16", - ), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), + "float16", + additional_data=False, ) assert image.dtype is np.dtype("float16") - image, attributes = cast( - Tuple[NDArrayReal, Tuple[Image_Specification_Attribute]], - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), - additional_data=True, - ), + image, attributes = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr"), + additional_data=True, ) assert image.shape == (1267, 1274, 3) assert attributes[0].name == "oiio:ColorSpace" assert attributes[0].value in ("Linear", "lin_rec709") - image = cast( - NDArrayReal, - read_image_OpenImageIO(os.path.join(ROOT_RESOURCES, "Single_Channel.exr")), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Single_Channel.exr"), + additional_data=False, ) assert image.shape == (256, 256) - image = cast( - NDArrayReal, - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint8" - ), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), + "uint8", + additional_data=False, ) assert image.shape == (128, 256, 4) assert image.dtype is np.dtype("uint8") assert np.min(image) == 0 assert np.max(image) == 255 - image = cast( - NDArrayReal, - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "uint16" - ), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), + "uint16", + additional_data=False, ) assert image.shape == (128, 256, 4) assert image.dtype is np.dtype("uint16") @@ -343,11 +333,10 @@ def test_read_image_OpenImageIO(self) -> None: # pragma: no cover # self.assertEqual(np.min(image), 0.0) # self.assertEqual(np.max(image), 1.0) - image = cast( - NDArrayReal, - read_image_OpenImageIO( - os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), "float32" - ), + image = read_image_OpenImageIO( + os.path.join(ROOT_RESOURCES, "Colour_Logo.png"), + "float32", + additional_data=False, ) assert image.dtype is np.dtype("float32") assert np.min(image) == 0.0 @@ -401,9 +390,15 @@ def test_write_image_OpenImageIO(self) -> None: # pragma: no cover source_path = os.path.join(ROOT_RESOURCES, "CMS_Test_Pattern.exr") target_path = os.path.join(self._temporary_directory, "CMS_Test_Pattern.exr") - image = cast(NDArrayReal, read_image_OpenImageIO(source_path)) + image = read_image_OpenImageIO( + source_path, + additional_data=False, + ) write_image_OpenImageIO(image, target_path) - image = cast(NDArrayReal, read_image_OpenImageIO(target_path)) + image = read_image_OpenImageIO( + target_path, + additional_data=False, + ) assert image.shape == (1267, 1274, 3) assert image.dtype is np.dtype("float32") diff --git a/colour/plotting/quality.py b/colour/plotting/quality.py index d03c65113..95fe64b77 100644 --- a/colour/plotting/quality.py +++ b/colour/plotting/quality.py @@ -41,7 +41,6 @@ Tuple, ) -from colour.hints import List, cast from colour.plotting import ( CONSTANTS_COLOUR_STYLE, XYZ_to_plotting_colourspace, @@ -348,10 +347,9 @@ def plot_multi_sds_colour_rendering_indexes_bars( settings: Dict[str, Any] = dict(kwargs) settings.update({"show": False}) - specifications = cast( - List[ColourRendering_Specification_CRI], - [colour_rendering_index(sd, additional_data=True) for sd in sds_converted], - ) + specifications = [ + colour_rendering_index(sd, additional_data=True) for sd in sds_converted + ] # *colour rendering index* colorimetry data tristimulus values are # computed in [0, 100] domain however `plot_colour_quality_bars` expects @@ -487,10 +485,7 @@ def plot_multi_sds_colour_quality_scales_bars( settings: Dict[str, Any] = dict(kwargs) settings.update({"show": False}) - specifications = cast( - List[ColourRendering_Specification_CQS], - [colour_quality_scale(sd, True, method) for sd in sds_converted], - ) + specifications = [colour_quality_scale(sd, True, method) for sd in sds_converted] _figure, axes = plot_colour_quality_bars(specifications, **settings) diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index 47718e188..e0117da3b 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -27,7 +27,6 @@ if typing.TYPE_CHECKING: from colour.hints import Any, Dict, Literal, Tuple -from colour.hints import cast from colour.io import SpectralDistribution_IESTM2714 from colour.models import Luv_to_uv, XYZ_to_Luv, XYZ_to_xy from colour.plotting import CONSTANTS_COLOUR_STYLE, override_style, render @@ -40,8 +39,6 @@ plot_spectra_ANSIIESTM3018, ) from colour.quality import ( - ColourQuality_Specification_ANSIIESTM3018, - ColourRendering_Specification_CRI, colour_fidelity_index_ANSIIESTM3018, colour_rendering_index, ) @@ -306,10 +303,7 @@ def plot_single_sd_colour_rendition_report_full( report_box_padding = optional(report_box_padding, CONSTANT_REPORT_PADDING_FULL) - specification: ColourQuality_Specification_ANSIIESTM3018 = cast( - ColourQuality_Specification_ANSIIESTM3018, - colour_fidelity_index_ANSIIESTM3018(sd, True), - ) + specification = colour_fidelity_index_ANSIIESTM3018(sd, True) sd = ( SpectralDistribution_IESTM2714(data=sd, name=sd.name) @@ -483,10 +477,7 @@ def plot_single_sd_colour_rendition_report_full( gridspec_CRI = gridspec_chromaticities_CRI[1].subgridspec(1, 1) - CRI_spec: ColourRendering_Specification_CRI = cast( - ColourRendering_Specification_CRI, - colour_rendering_index(specification.sd_test, additional_data=True), - ) + CRI_spec = colour_rendering_index(specification.sd_test, additional_data=True) axes_CRI = figure.add_subplot(gridspec_CRI[0]) axes_CRI.set_xticks([]) @@ -597,10 +588,7 @@ def plot_single_sd_colour_rendition_report_intermediate( report_box_padding, CONSTANT_REPORT_PADDING_INTERMEDIATE ) - specification: ColourQuality_Specification_ANSIIESTM3018 = cast( - ColourQuality_Specification_ANSIIESTM3018, - colour_fidelity_index_ANSIIESTM3018(sd, True), - ) + specification = colour_fidelity_index_ANSIIESTM3018(sd, True) figure = plt.figure(figsize=report_size, constrained_layout=True) @@ -692,10 +680,7 @@ def plot_single_sd_colour_rendition_report_simple( report_box_padding = optional(report_box_padding, CONSTANT_REPORT_PADDING_SIMPLE) - specification: ColourQuality_Specification_ANSIIESTM3018 = cast( - ColourQuality_Specification_ANSIIESTM3018, - colour_fidelity_index_ANSIIESTM3018(sd, True), - ) + specification = colour_fidelity_index_ANSIIESTM3018(sd, True) figure = plt.figure(figsize=report_size, constrained_layout=True) diff --git a/colour/plotting/tm3018/tests/test_components.py b/colour/plotting/tm3018/tests/test_components.py index da36225d6..b356c66bb 100644 --- a/colour/plotting/tm3018/tests/test_components.py +++ b/colour/plotting/tm3018/tests/test_components.py @@ -6,7 +6,6 @@ from matplotlib.figure import Figure from colour.colorimetry import SDS_ILLUMINANTS -from colour.hints import cast from colour.plotting.tm3018.components import ( plot_16_bin_bars, plot_colour_fidelity_indexes, @@ -17,7 +16,6 @@ plot_spectra_ANSIIESTM3018, ) from colour.quality import ( - ColourQuality_Specification_ANSIIESTM3018, colour_fidelity_index_ANSIIESTM3018, ) @@ -38,9 +36,8 @@ "TestPlotColourFidelityIndexes", ] -SPECIFICATION_ANSIIESTM3018: ColourQuality_Specification_ANSIIESTM3018 = cast( - ColourQuality_Specification_ANSIIESTM3018, - colour_fidelity_index_ANSIIESTM3018(SDS_ILLUMINANTS["FL2"], True), +SPECIFICATION_ANSIIESTM3018 = colour_fidelity_index_ANSIIESTM3018( + SDS_ILLUMINANTS["FL2"], True ) diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index 6ad164c9f..f218462e0 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -40,7 +40,7 @@ ) if typing.TYPE_CHECKING: - from colour.hints import ArrayLike, List, Tuple + from colour.hints import ArrayLike, List, Literal, Tuple from colour.hints import NDArrayFloat, cast from colour.models import JMh_CIECAM02_to_CAM02UCS, UCS_to_uv, XYZ_to_UCS @@ -139,6 +139,24 @@ class ColourRendering_Specification_CIE2017: delta_E_s: NDArrayFloat +@typing.overload +def colour_fidelity_index_CIE2017( + sd_test: SpectralDistribution, additional_data: Literal[True] = True +) -> ColourRendering_Specification_CIE2017: ... + + +@typing.overload +def colour_fidelity_index_CIE2017( + sd_test: SpectralDistribution, *, additional_data: Literal[False] +) -> float: ... + + +@typing.overload +def colour_fidelity_index_CIE2017( + sd_test: SpectralDistribution, additional_data: Literal[False] +) -> float: ... + + def colour_fidelity_index_CIE2017( sd_test: SpectralDistribution, additional_data: bool = False ) -> float | ColourRendering_Specification_CIE2017: diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index 1625c7faa..cc8fddc88 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -174,6 +174,31 @@ class ColourRendering_Specification_CQS: """ +@typing.overload +def colour_quality_scale( + sd_test: SpectralDistribution, + *, + additional_data: Literal[False], + method: Literal["NIST CQS 7.4", "NIST CQS 9.0"] | str = ..., +) -> float: ... + + +@typing.overload +def colour_quality_scale( + sd_test: SpectralDistribution, + additional_data: Literal[True] = True, + method: Literal["NIST CQS 7.4", "NIST CQS 9.0"] | str = ..., +) -> ColourRendering_Specification_CQS: ... + + +@typing.overload +def colour_quality_scale( + sd_test: SpectralDistribution, + additional_data: Literal[False], + method: Literal["NIST CQS 7.4", "NIST CQS 9.0"] | str = ..., +) -> float: ... + + def colour_quality_scale( sd_test: SpectralDistribution, additional_data: bool = False, diff --git a/colour/quality/cri.py b/colour/quality/cri.py index ed66b8fc1..5d6adf7e1 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -36,7 +36,7 @@ ) if typing.TYPE_CHECKING: - from colour.hints import Dict, NDArrayFloat, Tuple + from colour.hints import Dict, Literal, NDArrayFloat, Tuple from colour.hints import cast from colour.models import UCS_to_uv, XYZ_to_UCS, XYZ_to_xyY @@ -110,6 +110,24 @@ class ColourRendering_Specification_CRI: ] +@typing.overload +def colour_rendering_index( + sd_test: SpectralDistribution, additional_data: Literal[True] = True +) -> ColourRendering_Specification_CRI: ... + + +@typing.overload +def colour_rendering_index( + sd_test: SpectralDistribution, *, additional_data: Literal[False] +) -> float: ... + + +@typing.overload +def colour_rendering_index( + sd_test: SpectralDistribution, additional_data: Literal[False] +) -> float: ... + + def colour_rendering_index( sd_test: SpectralDistribution, additional_data: bool = False ) -> float | ColourRendering_Specification_CRI: diff --git a/colour/quality/tests/test_cfi2017.py b/colour/quality/tests/test_cfi2017.py index 08c50cacf..347b458ae 100644 --- a/colour/quality/tests/test_cfi2017.py +++ b/colour/quality/tests/test_cfi2017.py @@ -19,10 +19,8 @@ reshape_sd, sd_blackbody, ) -from colour.hints import cast from colour.quality.cfi2017 import ( CCT_reference_illuminant, - ColourRendering_Specification_CIE2017, colour_fidelity_index_CIE2017, sd_reference_illuminant, ) @@ -561,10 +559,7 @@ def test_colour_fidelity_index_CIE2017(self) -> None: """ for sd in [SD_SAMPLE_5NM, SD_SAMPLE_1NM]: - specification = cast( - ColourRendering_Specification_CIE2017, - colour_fidelity_index_CIE2017(sd, additional_data=True), - ) + specification = colour_fidelity_index_CIE2017(sd, additional_data=True) np.testing.assert_allclose(specification.R_f, 81.6, atol=0.1) np.testing.assert_allclose( specification.R_s, @@ -672,9 +667,8 @@ def test_colour_fidelity_index_CIE2017(self) -> None: atol=0.1, ) - specification = cast( - ColourRendering_Specification_CIE2017, - colour_fidelity_index_CIE2017(SDS_ILLUMINANTS["FL1"], additional_data=True), + specification = colour_fidelity_index_CIE2017( + SDS_ILLUMINANTS["FL1"], additional_data=True ) np.testing.assert_allclose(specification.R_f, 80.6, atol=0.1) np.testing.assert_allclose( @@ -783,9 +777,8 @@ def test_colour_fidelity_index_CIE2017(self) -> None: atol=0.1, ) - specification = cast( - ColourRendering_Specification_CIE2017, - colour_fidelity_index_CIE2017(SDS_ILLUMINANTS["FL2"], additional_data=True), + specification = colour_fidelity_index_CIE2017( + SDS_ILLUMINANTS["FL2"], additional_data=True ) np.testing.assert_allclose(specification.R_f, 70.1, atol=0.1) np.testing.assert_allclose( diff --git a/colour/quality/tests/test_cqs.py b/colour/quality/tests/test_cqs.py index 1cc4a21fb..0cfdab32e 100644 --- a/colour/quality/tests/test_cqs.py +++ b/colour/quality/tests/test_cqs.py @@ -6,7 +6,6 @@ from colour.colorimetry import SDS_ILLUMINANTS, SDS_LIGHT_SOURCES from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import cast from colour.quality import ColourRendering_Specification_CQS, colour_quality_scale from colour.quality.cqs import DataColorimetry_VS, DataColourQualityScale_VS @@ -32,71 +31,64 @@ def test_colour_quality_scale(self) -> None: """Test :func:`colour.quality.cqs.colour_quality_scale` definition.""" np.testing.assert_allclose( - cast(float, colour_quality_scale(SDS_ILLUMINANTS["FL1"])), + colour_quality_scale(SDS_ILLUMINANTS["FL1"], additional_data=False), 74.982585798279914, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, - colour_quality_scale(SDS_ILLUMINANTS["FL1"], method="NIST CQS 7.4"), + colour_quality_scale( + SDS_ILLUMINANTS["FL1"], additional_data=False, method="NIST CQS 7.4" ), 75.377089740493361, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast(float, colour_quality_scale(SDS_ILLUMINANTS["FL2"])), + colour_quality_scale(SDS_ILLUMINANTS["FL2"], additional_data=False), 64.111822015662852, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, - colour_quality_scale(SDS_ILLUMINANTS["FL2"], method="NIST CQS 7.4"), + colour_quality_scale( + SDS_ILLUMINANTS["FL2"], additional_data=False, method="NIST CQS 7.4" ), 64.774586908581369, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, colour_quality_scale(SDS_LIGHT_SOURCES["Neodimium Incandescent"]) + colour_quality_scale( + SDS_LIGHT_SOURCES["Neodimium Incandescent"], additional_data=False ), 89.737456186836681, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, - colour_quality_scale( - SDS_LIGHT_SOURCES["Neodimium Incandescent"], - method="NIST CQS 7.4", - ), + colour_quality_scale( + SDS_LIGHT_SOURCES["Neodimium Incandescent"], + additional_data=False, + method="NIST CQS 7.4", ), 87.700300087538821, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, - colour_quality_scale(SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"]), + colour_quality_scale( + SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"], additional_data=False ), 84.934928463428903, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast( - float, - colour_quality_scale( - SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"], - method="NIST CQS 7.4", - ), + colour_quality_scale( + SDS_LIGHT_SOURCES["F32T8/TL841 (Triphosphor)"], + additional_data=False, + method="NIST CQS 7.4", ), 83.255457439460713, atol=TOLERANCE_ABSOLUTE_TESTS, @@ -404,11 +396,8 @@ def test_colour_quality_scale(self) -> None: ), ) - specification_t = cast( - ColourRendering_Specification_CQS, - colour_quality_scale( - SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 7.4" - ), + specification_t = colour_quality_scale( + SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 7.4" ) np.testing.assert_allclose( @@ -719,11 +708,8 @@ def test_colour_quality_scale(self) -> None: ), ) - specification_t = cast( - ColourRendering_Specification_CQS, - colour_quality_scale( - SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 9.0" - ), + specification_t = colour_quality_scale( + SDS_ILLUMINANTS["FL1"], additional_data=True, method="NIST CQS 9.0" ) np.testing.assert_allclose( diff --git a/colour/quality/tests/test_cri.py b/colour/quality/tests/test_cri.py index d671a0232..b18f79d3f 100644 --- a/colour/quality/tests/test_cri.py +++ b/colour/quality/tests/test_cri.py @@ -6,7 +6,6 @@ from colour.colorimetry import SDS_ILLUMINANTS, SpectralDistribution from colour.constants import TOLERANCE_ABSOLUTE_TESTS -from colour.hints import cast from colour.quality import ColourRendering_Specification_CRI, colour_rendering_index from colour.quality.cri import DataColorimetry_TCS, DataColourQualityScale_TCS @@ -116,25 +115,27 @@ def test_colour_rendering_index(self) -> None: """Test :func:`colour.quality.cri.colour_rendering_index` definition.""" np.testing.assert_allclose( - cast(float, colour_rendering_index(SDS_ILLUMINANTS["FL1"])), + colour_rendering_index(SDS_ILLUMINANTS["FL1"], additional_data=False), 75.852827992149358, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast(float, colour_rendering_index(SDS_ILLUMINANTS["FL2"])), + colour_rendering_index(SDS_ILLUMINANTS["FL2"], additional_data=False), 64.233724121664778, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast(float, colour_rendering_index(SDS_ILLUMINANTS["A"])), + colour_rendering_index(SDS_ILLUMINANTS["A"], additional_data=False), 99.996230290506887, atol=TOLERANCE_ABSOLUTE_TESTS, ) np.testing.assert_allclose( - cast(float, colour_rendering_index(SpectralDistribution(DATA_SAMPLE))), + colour_rendering_index( + SpectralDistribution(DATA_SAMPLE), additional_data=False + ), 70.815265381660197, atol=TOLERANCE_ABSOLUTE_TESTS, ) @@ -334,9 +335,8 @@ def test_colour_rendering_index(self) -> None: ), ) - specification_t = cast( - ColourRendering_Specification_CRI, - colour_rendering_index(SDS_ILLUMINANTS["FL1"], additional_data=True), + specification_t = colour_rendering_index( + SDS_ILLUMINANTS["FL1"], additional_data=True ) np.testing.assert_allclose( diff --git a/colour/quality/tests/test_tm3018.py b/colour/quality/tests/test_tm3018.py index b06249d97..248cb3708 100644 --- a/colour/quality/tests/test_tm3018.py +++ b/colour/quality/tests/test_tm3018.py @@ -13,9 +13,7 @@ import numpy as np from colour.colorimetry import SDS_ILLUMINANTS -from colour.hints import cast from colour.quality.tm3018 import ( - ColourQuality_Specification_ANSIIESTM3018, averages_area, colour_fidelity_index_ANSIIESTM3018, ) @@ -46,11 +44,8 @@ def test_colour_fidelity_index_ANSIIESTM3018(self) -> None: definition. """ - specification = cast( - ColourQuality_Specification_ANSIIESTM3018, - colour_fidelity_index_ANSIIESTM3018( - SDS_ILLUMINANTS["FL2"], additional_data=True - ), + specification = colour_fidelity_index_ANSIIESTM3018( + SDS_ILLUMINANTS["FL2"], additional_data=True ) np.testing.assert_allclose(specification.R_f, 70, atol=2e-1) diff --git a/colour/quality/tm3018.py b/colour/quality/tm3018.py index fcb5c2279..147ae14cd 100644 --- a/colour/quality/tm3018.py +++ b/colour/quality/tm3018.py @@ -26,12 +26,10 @@ if typing.TYPE_CHECKING: from colour.colorimetry import SpectralDistribution - from colour.hints import ArrayLike, NDArrayFloat, NDArrayInt, Tuple + from colour.hints import ArrayLike, Literal, NDArrayFloat, NDArrayInt, Tuple -from colour.hints import cast from colour.quality import colour_fidelity_index_CIE2017 from colour.quality.cfi2017 import ( - ColourRendering_Specification_CIE2017, DataColorimetry_TCS_CIE2017, delta_E_to_R_f, ) @@ -100,13 +98,27 @@ class ColourQuality_Specification_ANSIIESTM3018: R_hs: NDArrayFloat +@typing.overload +def colour_fidelity_index_ANSIIESTM3018( + sd_test: SpectralDistribution, additional_data: Literal[True] = True +) -> ColourQuality_Specification_ANSIIESTM3018: ... + + +@typing.overload +def colour_fidelity_index_ANSIIESTM3018( + sd_test: SpectralDistribution, *, additional_data: Literal[False] +) -> float: ... + + +@typing.overload +def colour_fidelity_index_ANSIIESTM3018( + sd_test: SpectralDistribution, additional_data: Literal[False] +) -> float: ... + + def colour_fidelity_index_ANSIIESTM3018( sd_test: SpectralDistribution, additional_data: bool = False -) -> ( - float - | ColourQuality_Specification_ANSIIESTM3018 - | ColourRendering_Specification_CIE2017 -): +) -> float | ColourQuality_Specification_ANSIIESTM3018: """ Return the *ANSI/IES TM-30-18 Colour Fidelity Index* (CFI) :math:`R_f` of given spectral distribution. @@ -139,10 +151,7 @@ def colour_fidelity_index_ANSIIESTM3018( if not additional_data: return colour_fidelity_index_CIE2017(sd_test, False) - specification = cast( - ColourRendering_Specification_CIE2017, - colour_fidelity_index_CIE2017(sd_test, True), - ) + specification = colour_fidelity_index_CIE2017(sd_test, True) # Setup bins based on where the reference a'b' points are located. bins = as_int_array(np.floor(specification.colorimetry_data[1].JMh[:, 2] / 22.5)) diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 4c61a44e1..08b311134 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -46,6 +46,7 @@ from colour.hints import ( ArrayLike, Callable, + Literal, NDArrayFloat, Tuple, ) @@ -202,6 +203,40 @@ def sd_Jakob2019( return SpectralDistribution(R, wl, name=name) +@typing.overload +def error_function( + coefficients: ArrayLike, + target: ArrayLike, + cmfs: MultiSpectralDistributions, + illuminant: SpectralDistribution, + max_error: float | None = ..., + additional_data: Literal[True] = True, +) -> Tuple[float, NDArrayFloat, NDArrayFloat, NDArrayFloat, NDArrayFloat]: ... + + +@typing.overload +def error_function( + coefficients: ArrayLike, + target: ArrayLike, + cmfs: MultiSpectralDistributions, + illuminant: SpectralDistribution, + max_error: float | None = ..., + *, + additional_data: Literal[False], +) -> Tuple[float, NDArrayFloat]: ... + + +@typing.overload +def error_function( + coefficients: ArrayLike, + target: ArrayLike, + cmfs: MultiSpectralDistributions, + illuminant: SpectralDistribution, + max_error: float | None, + additional_data: Literal[False], +) -> Tuple[float, NDArrayFloat]: ... + + def error_function( coefficients: ArrayLike, target: ArrayLike, @@ -489,6 +524,37 @@ def optimize( return coefficients, error +@typing.overload +def XYZ_to_sd_Jakob2019( + XYZ: ArrayLike, + cmfs: MultiSpectralDistributions | None = ..., + illuminant: SpectralDistribution | None = ..., + optimisation_kwargs: dict | None = ..., + additional_data: Literal[True] = True, +) -> Tuple[SpectralDistribution, float]: ... + + +@typing.overload +def XYZ_to_sd_Jakob2019( + XYZ: ArrayLike, + cmfs: MultiSpectralDistributions | None = ..., + illuminant: SpectralDistribution | None = ..., + optimisation_kwargs: dict | None = ..., + *, + additional_data: Literal[False], +) -> SpectralDistribution: ... + + +@typing.overload +def XYZ_to_sd_Jakob2019( + XYZ: ArrayLike, + cmfs: MultiSpectralDistributions | None, + illuminant: SpectralDistribution | None, + optimisation_kwargs: dict | None, + additional_data: Literal[False], +) -> SpectralDistribution: ... + + def XYZ_to_sd_Jakob2019( XYZ: ArrayLike, cmfs: MultiSpectralDistributions | None = None, diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index f281013ab..4fce467b1 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -37,6 +37,7 @@ from colour.hints import ( ArrayLike, Mapping, + Literal, NDArrayFloat, Tuple, ) @@ -59,6 +60,34 @@ ] +@typing.overload +def PCA_Jiang2013( + msds_camera_sensitivities: Mapping[str, MultiSpectralDistributions], + eigen_w_v_count: int | None = ..., + additional_data: Literal[True] = True, +) -> Tuple[ + Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat], + Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat], +]: ... + + +@typing.overload +def PCA_Jiang2013( + msds_camera_sensitivities: Mapping[str, MultiSpectralDistributions], + eigen_w_v_count: int | None = ..., + *, + additional_data: Literal[False], +) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat]: ... + + +@typing.overload +def PCA_Jiang2013( + msds_camera_sensitivities: Mapping[str, MultiSpectralDistributions], + eigen_w_v_count: int | None, + additional_data: Literal[False], +) -> Tuple[NDArrayFloat, NDArrayFloat, NDArrayFloat]: ... + + def PCA_Jiang2013( msds_camera_sensitivities: Mapping[str, MultiSpectralDistributions], eigen_w_v_count: int | None = None, diff --git a/colour/recovery/tests/test_jakob2019.py b/colour/recovery/tests/test_jakob2019.py index e2e63a5c5..a8f10cfe9 100644 --- a/colour/recovery/tests/test_jakob2019.py +++ b/colour/recovery/tests/test_jakob2019.py @@ -175,7 +175,7 @@ def test_domain_range_scale_XYZ_to_sd_Jakob2019(self) -> None: XYZ_i = np.array([0.20654008, 0.12197225, 0.05136952]) XYZ_o = sd_to_XYZ( - XYZ_to_sd_Jakob2019(XYZ_i, self._cmfs, self._sd_D65, additional_data=False), # pyright: ignore + XYZ_to_sd_Jakob2019(XYZ_i, self._cmfs, self._sd_D65, additional_data=False), self._cmfs, self._sd_D65, ) @@ -183,14 +183,14 @@ def test_domain_range_scale_XYZ_to_sd_Jakob2019(self) -> None: d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1)) for scale, factor_a, factor_b in d_r: with domain_range_scale(scale): - np.testing.assert_allclose( # pyright: ignore + np.testing.assert_allclose( sd_to_XYZ( XYZ_to_sd_Jakob2019( XYZ_i * factor_a, self._cmfs, self._sd_D65, additional_data=False, - ), # pyright: ignore + ), self._cmfs, self._sd_D65, ), diff --git a/colour/recovery/tests/test_jiang2013.py b/colour/recovery/tests/test_jiang2013.py index 301f36462..53ee4171c 100644 --- a/colour/recovery/tests/test_jiang2013.py +++ b/colour/recovery/tests/test_jiang2013.py @@ -60,7 +60,7 @@ def test_PCA_Jiang2013(self) -> None: camera: msds.copy().align(shape) for camera, msds in MSDS_CAMERA_SENSITIVITIES.items() } - w, v = PCA_Jiang2013( # pyright: ignore + w, v = PCA_Jiang2013( camera_sensitivities, 3, additional_data=True, From baf108eeccd51756f9f13d75f97d20c79073841d Mon Sep 17 00:00:00 2001 From: Thomas Mansencal Date: Sun, 22 Dec 2024 19:16:43 +1300 Subject: [PATCH 42/42] Code formatting. --- colour/adaptation/cmccat2000.py | 1 + colour/adaptation/fairchild1990.py | 1 + colour/adaptation/fairchild2020.py | 1 + colour/adaptation/vonkries.py | 1 + colour/algebra/interpolation.py | 2 ++ colour/appearance/ciecam02.py | 3 +++ colour/appearance/hunt.py | 2 ++ colour/blindness/machado2009.py | 1 + colour/characterisation/aces_it.py | 1 + colour/colorimetry/spectrum.py | 6 ++++++ colour/colorimetry/tristimulus_values.py | 2 ++ colour/continuous/multi_signals.py | 1 + colour/continuous/signal.py | 3 +++ colour/io/ctl.py | 2 ++ colour/io/fichet2021.py | 1 + colour/io/luts/__init__.py | 1 + colour/io/luts/lut.py | 3 +++ colour/io/ocio.py | 2 ++ colour/io/tm2714.py | 1 + colour/models/rgb/rgb_colourspace.py | 5 +++++ colour/models/rgb/transfer_functions/aces.py | 1 + colour/models/rgb/transfer_functions/common.py | 2 ++ colour/models/rgb/transfer_functions/dcdm.py | 1 + colour/models/rgb/transfer_functions/dicom_gsdf.py | 1 + colour/models/rgb/transfer_functions/gamma.py | 3 +++ colour/models/rgb/transfer_functions/itur_bt_2100.py | 4 ++++ colour/models/rgb/transfer_functions/log.py | 5 +++++ colour/models/rgb/transfer_functions/rimm_romm_rgb.py | 3 +++ colour/models/rgb/ycbcr.py | 2 ++ colour/notation/hexadecimal.py | 1 + colour/notation/munsell.py | 8 ++++++++ colour/plotting/common.py | 1 + colour/plotting/tm3018/report.py | 2 ++ colour/quality/cfi2017.py | 1 + colour/quality/cqs.py | 2 ++ colour/quality/cri.py | 1 + colour/recovery/jakob2019.py | 2 ++ colour/recovery/jiang2013.py | 1 + colour/recovery/meng2015.py | 1 + colour/recovery/otsu2018.py | 2 ++ colour/temperature/ohno2013.py | 1 + colour/utilities/array.py | 3 +++ colour/utilities/common.py | 1 + colour/utilities/network.py | 3 +++ colour/utilities/structures.py | 2 ++ colour/volume/macadam_limits.py | 1 + colour/volume/mesh.py | 1 + 47 files changed, 96 insertions(+) diff --git a/colour/adaptation/cmccat2000.py b/colour/adaptation/cmccat2000.py index 3831a3028..810d17aad 100644 --- a/colour/adaptation/cmccat2000.py +++ b/colour/adaptation/cmccat2000.py @@ -386,6 +386,7 @@ def chromatic_adaptation_CMCCAT2000( return chromatic_adaptation_forward_CMCCAT2000( XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround ) + return chromatic_adaptation_inverse_CMCCAT2000( XYZ, XYZ_w, XYZ_wr, L_A1, L_A2, surround ) diff --git a/colour/adaptation/fairchild1990.py b/colour/adaptation/fairchild1990.py index ff7b9717b..233af4b35 100644 --- a/colour/adaptation/fairchild1990.py +++ b/colour/adaptation/fairchild1990.py @@ -245,6 +245,7 @@ def degrees_of_adaptation( """ LMS = as_float_array(LMS) + if discount_illuminant: return ones(LMS.shape) diff --git a/colour/adaptation/fairchild2020.py b/colour/adaptation/fairchild2020.py index 0106382f1..24483a0e2 100644 --- a/colour/adaptation/fairchild2020.py +++ b/colour/adaptation/fairchild2020.py @@ -218,6 +218,7 @@ def matrix_chromatic_adaptation_vk20( D = row_as_diagonal(sdiv(1, (D_n * LMS_n + D_r * LMS_r + D_p * LMS_p))) M_CAT = np.matmul(np.linalg.inv(M), D) + return np.matmul(M_CAT, M) diff --git a/colour/adaptation/vonkries.py b/colour/adaptation/vonkries.py index 9564e40e1..988323946 100644 --- a/colour/adaptation/vonkries.py +++ b/colour/adaptation/vonkries.py @@ -131,6 +131,7 @@ def matrix_chromatic_adaptation_VonKries( D = row_as_diagonal(D) M_CAT = np.matmul(np.linalg.inv(M), D) + return np.matmul(M_CAT, M) diff --git a/colour/algebra/interpolation.py b/colour/algebra/interpolation.py index 40338eaea..72131d812 100644 --- a/colour/algebra/interpolation.py +++ b/colour/algebra/interpolation.py @@ -1220,8 +1220,10 @@ def _evaluate(self, x: NDArrayFloat) -> NDArrayFloat: # parts of the linear algebra. y = r[i] + (a.reshape(5, -1) * X ** np.arange(1, 6).reshape(-1, 1)).sum(axis=0) + if y.size == 1: return y[0] + return y def _validate_dimensions(self) -> None: diff --git a/colour/appearance/ciecam02.py b/colour/appearance/ciecam02.py index 71fd35c21..e2bab89a9 100644 --- a/colour/appearance/ciecam02.py +++ b/colour/appearance/ciecam02.py @@ -915,6 +915,7 @@ def post_adaptation_non_linear_response_compression_forward( F_L = as_float_array(F_L) F_L_RGB = spow(F_L[..., None] * np.absolute(RGB) / 100, 0.42) + return (400 * np.sign(RGB) * F_L_RGB) / (27.13 + F_L_RGB) + 0.1 @@ -1154,6 +1155,7 @@ def hue_quadrature(h: ArrayLike) -> NDArrayFloat: H_ii + ((85.9 * (h - h_ii) / e_ii) / ((h - h_ii) / e_ii + (360 - h) / 0.856)), H, ) + return as_float(H) @@ -1498,6 +1500,7 @@ def chroma_correlate( n = as_float_array(n) t = temporary_magnitude_quantity_forward(N_c, N_cb, e_t, a, b, RGB_a) + return spow(t, 0.9) * spow(J / 100, 0.5) * spow(1.64 - 0.29**n, 0.73) diff --git a/colour/appearance/hunt.py b/colour/appearance/hunt.py index fe6f52797..4f5105088 100644 --- a/colour/appearance/hunt.py +++ b/colour/appearance/hunt.py @@ -904,6 +904,7 @@ def hue_angle(C: ArrayLike) -> NDArrayFloat: C_1, C_2, C_3 = tsplit(C) hue = (180 * np.arctan2(0.5 * (C_2 - C_3) / 4.5, C_1 - (C_2 / 11)) / np.pi) % 360 + return as_float(hue) @@ -1284,6 +1285,7 @@ def lightness_correlate( Q_w = as_float_array(Q_w) Z = 1 + spow(Y_b / Y_w, 0.5) + return 100 * spow(Q / Q_w, Z) diff --git a/colour/blindness/machado2009.py b/colour/blindness/machado2009.py index ec986b91a..d9a137698 100644 --- a/colour/blindness/machado2009.py +++ b/colour/blindness/machado2009.py @@ -381,4 +381,5 @@ def matrix_cvd_Machado2009( if a == b: # 1.0 severity CVD matrix, returning directly. return m1 + return m1 + (severity - a) * ((m2 - m1) / (b - a)) diff --git a/colour/characterisation/aces_it.py b/colour/characterisation/aces_it.py index dfde6fb0b..8e4db2ca8 100644 --- a/colour/characterisation/aces_it.py +++ b/colour/characterisation/aces_it.py @@ -1142,6 +1142,7 @@ def matrix_idt( if additional_data: return M, RGB_w, XYZ, RGB + return M, RGB_w diff --git a/colour/colorimetry/spectrum.py b/colour/colorimetry/spectrum.py index 3c0faf390..04e4b7bcc 100644 --- a/colour/colorimetry/spectrum.py +++ b/colour/colorimetry/spectrum.py @@ -452,6 +452,7 @@ def __eq__(self, other: object) -> bool: if isinstance(other, SpectralShape): return np.array_equal(self.wavelengths, other.wavelengths) + return False def __ne__(self, other: object) -> bool: @@ -512,6 +513,7 @@ def range(self, dtype: Type[DTypeFloat] | None = None) -> NDArrayFloat: dtype = optional(dtype, DTYPE_FLOAT_DEFAULT) hash_key = hash((self, dtype)) + if is_caching_enabled() and hash_key in _CACHE_SHAPE_RANGE: return _CACHE_SHAPE_RANGE[hash_key].copy() @@ -2710,6 +2712,7 @@ def reshape_sd( if is_caching_enabled() and hash_key in _CACHE_RESHAPED_SDS_AND_MSDS: reshaped_sd = _CACHE_RESHAPED_SDS_AND_MSDS[hash_key] + return reshaped_sd.copy() if copy else reshaped_sd function = getattr(sd, method) @@ -2825,10 +2828,12 @@ def sds_and_msds_to_sds( if isinstance(sds, SpectralDistribution): return sds_and_msds_to_sds([sds]) + if isinstance(sds, MultiSpectralDistributions): sds_converted = sds.to_sds() else: sds_converted = [] + for sd in sds: sds_converted += ( sd.to_sds() if isinstance(sd, MultiSpectralDistributions) else [sd] @@ -2926,6 +2931,7 @@ def sds_and_msds_to_msds( if isinstance(sds, SpectralDistribution): return sds_and_msds_to_msds([sds]) + if isinstance(sds, MultiSpectralDistributions): msds_converted = sds else: diff --git a/colour/colorimetry/tristimulus_values.py b/colour/colorimetry/tristimulus_values.py index fa82e23ad..e9ac620aa 100644 --- a/colour/colorimetry/tristimulus_values.py +++ b/colour/colorimetry/tristimulus_values.py @@ -260,6 +260,7 @@ def lagrange_coefficients_ASTME2022( ) hash_key = hash((interval, interval_type)) + if is_caching_enabled() and hash_key in _CACHE_LAGRANGE_INTERPOLATING_COEFFICIENTS: return np.copy(_CACHE_LAGRANGE_INTERPOLATING_COEFFICIENTS[hash_key]) @@ -393,6 +394,7 @@ def tristimulus_weighting_factors_ASTME2022( global _CACHE_TRISTIMULUS_WEIGHTING_FACTORS # noqa: PLW0602 hash_key = hash((cmfs, illuminant, shape, k, get_domain_range_scale())) + if is_caching_enabled() and hash_key in _CACHE_TRISTIMULUS_WEIGHTING_FACTORS: return np.copy(_CACHE_TRISTIMULUS_WEIGHTING_FACTORS[hash_key]) diff --git a/colour/continuous/multi_signals.py b/colour/continuous/multi_signals.py index 484178d88..925c68699 100644 --- a/colour/continuous/multi_signals.py +++ b/colour/continuous/multi_signals.py @@ -1017,6 +1017,7 @@ def __eq__(self, other: object) -> bool: self.labels == other.labels, ] ) + return False def __ne__(self, other: object) -> bool: diff --git a/colour/continuous/signal.py b/colour/continuous/signal.py index 4f2c6d562..349cf3d79 100644 --- a/colour/continuous/signal.py +++ b/colour/continuous/signal.py @@ -707,6 +707,7 @@ def __getitem__(self, x: ArrayLike | slice) -> NDArrayFloat: if isinstance(x, slice): return self._range[x] + return self.function(x) def __setitem__(self, x: ArrayLike | slice, y: ArrayLike) -> None: @@ -886,6 +887,7 @@ def __eq__(self, other: object) -> bool: repr(self._extrapolator_kwargs) == repr(other.extrapolator_kwargs), ] ) + return False def __ne__(self, other: object) -> bool: @@ -1078,6 +1080,7 @@ def arithmetical_operation( self.range = ioperator(self._range, a) return self + return ioperator(self.copy(), a) @staticmethod diff --git a/colour/io/ctl.py b/colour/io/ctl.py index 0555be5c3..b190ecc03 100644 --- a/colour/io/ctl.py +++ b/colour/io/ctl.py @@ -297,8 +297,10 @@ def process_image_ctl( if len(shape) == 0: return as_float(np.squeeze(b)[0]) + if shape[-1] == 1: return np.reshape(b[..., 0], shape) + return np.reshape(b, shape) diff --git a/colour/io/fichet2021.py b/colour/io/fichet2021.py index fe11b2163..8ac30fc6f 100644 --- a/colour/io/fichet2021.py +++ b/colour/io/fichet2021.py @@ -536,6 +536,7 @@ def read_spectral_image_Fichet2021( if additional_data: return components, specification + return components diff --git a/colour/io/luts/__init__.py b/colour/io/luts/__init__.py index 72962d1f7..ba962118b 100644 --- a/colour/io/luts/__init__.py +++ b/colour/io/luts/__init__.py @@ -234,6 +234,7 @@ def read_LUT( if method == "iridas cube": function = LUT_READ_METHODS["Resolve Cube"] return function(path, **filter_kwargs(function, **kwargs)) + raise ValueError from error diff --git a/colour/io/luts/lut.py b/colour/io/luts/lut.py index c7373dffb..35a9b6329 100644 --- a/colour/io/luts/lut.py +++ b/colour/io/luts/lut.py @@ -603,6 +603,7 @@ def arithmetical_operation( self.table = operator(self.table, operand) return self + return ioperator(self.copy(), a) @abstractmethod @@ -993,6 +994,7 @@ def linear_table( if len(domain) != 2: return domain + attest(is_numeric(size), "Linear table size must be a numeric!") return np.linspace(domain[0], domain[1], as_int_scalar(size)) @@ -1358,6 +1360,7 @@ def linear_table( if domain.shape != (2, 3): return domain + size_array = np.tile(size, 3) if is_numeric(size) else as_int_array(size) R, G, B = tsplit(domain) diff --git a/colour/io/ocio.py b/colour/io/ocio.py index 0f9fbb2a0..de6354b40 100644 --- a/colour/io/ocio.py +++ b/colour/io/ocio.py @@ -156,6 +156,8 @@ def process_image_OpenColorIO(a: ArrayLike, *args: Any, **kwargs: Any) -> NDArra if len(shape) == 0: return as_float(np.squeeze(b)[0]) + if shape[-1] == 1: return np.reshape(b[..., 0], shape) + return np.reshape(b, shape) diff --git a/colour/io/tm2714.py b/colour/io/tm2714.py index 8d4def14d..db6d7c96f 100644 --- a/colour/io/tm2714.py +++ b/colour/io/tm2714.py @@ -729,6 +729,7 @@ def __eq__(self, other: object) -> bool: self._comments == other.comments, ] ) + return False def __ne__(self, other: object) -> bool: diff --git a/colour/models/rgb/rgb_colourspace.py b/colour/models/rgb/rgb_colourspace.py index 86edaaf46..32aab325f 100644 --- a/colour/models/rgb/rgb_colourspace.py +++ b/colour/models/rgb/rgb_colourspace.py @@ -429,7 +429,9 @@ def matrix_RGB_to_XYZ(self) -> NDArrayFloat: if self._matrix_RGB_to_XYZ is None or self._use_derived_matrix_RGB_to_XYZ: if self._derived_matrix_RGB_to_XYZ.size == 0: self._derive_transformation_matrices() + return self._derived_matrix_RGB_to_XYZ + return self._matrix_RGB_to_XYZ @matrix_RGB_to_XYZ.setter @@ -469,7 +471,9 @@ def matrix_XYZ_to_RGB(self) -> NDArrayFloat: if self._matrix_XYZ_to_RGB is None or self._use_derived_matrix_XYZ_to_RGB: if self._derived_matrix_XYZ_to_RGB.size == 0: self._derive_transformation_matrices() + return self._derived_matrix_XYZ_to_RGB + return self._matrix_XYZ_to_RGB @matrix_XYZ_to_RGB.setter @@ -688,6 +692,7 @@ def __str__(self) -> str: """ if self._derived_matrix_XYZ_to_RGB.size == 0: self._derive_transformation_matrices() + return multiline_str( self, [ diff --git a/colour/models/rgb/transfer_functions/aces.py b/colour/models/rgb/transfer_functions/aces.py index 4c5e25d00..fc46ebe59 100644 --- a/colour/models/rgb/transfer_functions/aces.py +++ b/colour/models/rgb/transfer_functions/aces.py @@ -193,6 +193,7 @@ def float_2_cv(x: float) -> float: if out_int: return as_int(np.round(ACESproxy)) + return as_float(from_range_1(ACESproxy / (2**bit_depth - 1))) diff --git a/colour/models/rgb/transfer_functions/common.py b/colour/models/rgb/transfer_functions/common.py index 91348c232..36d0a8e08 100644 --- a/colour/models/rgb/transfer_functions/common.py +++ b/colour/models/rgb/transfer_functions/common.py @@ -136,6 +136,7 @@ def legal_to_full( if out_int: return as_int(np.round(CV_full * MV)) + return as_float(CV_full) @@ -202,4 +203,5 @@ def full_to_legal( if out_int: return as_int(np.round(CV_legal)) + return as_float(CV_legal / MV) diff --git a/colour/models/rgb/transfer_functions/dcdm.py b/colour/models/rgb/transfer_functions/dcdm.py index b8ed2e9d7..ae32c5dab 100644 --- a/colour/models/rgb/transfer_functions/dcdm.py +++ b/colour/models/rgb/transfer_functions/dcdm.py @@ -105,6 +105,7 @@ def eotf_inverse_DCDM(XYZ: ArrayLike, out_int: bool = False) -> NDArrayReal: if out_int: return as_int(np.round(4095 * XYZ_p)) + return as_float(XYZ_p) diff --git a/colour/models/rgb/transfer_functions/dicom_gsdf.py b/colour/models/rgb/transfer_functions/dicom_gsdf.py index 30f5bf61d..a8ec9da1b 100644 --- a/colour/models/rgb/transfer_functions/dicom_gsdf.py +++ b/colour/models/rgb/transfer_functions/dicom_gsdf.py @@ -149,6 +149,7 @@ def eotf_inverse_DICOMGSDF( if out_int: return as_int(np.round(J)) + return as_float(from_range_1(J / 1023)) diff --git a/colour/models/rgb/transfer_functions/gamma.py b/colour/models/rgb/transfer_functions/gamma.py index 9438ad33b..a138c93cd 100644 --- a/colour/models/rgb/transfer_functions/gamma.py +++ b/colour/models/rgb/transfer_functions/gamma.py @@ -94,9 +94,12 @@ def gamma_function( if negative_number_handling == "indeterminate": return as_float(a**exponent) + if negative_number_handling == "mirror": return spow(a, exponent) + if negative_number_handling == "preserve": return as_float(np.where(a <= 0, a, a**exponent)) + # negative_number_handling == 'clamp': return as_float(np.where(a <= 0, 0, a**exponent)) diff --git a/colour/models/rgb/transfer_functions/itur_bt_2100.py b/colour/models/rgb/transfer_functions/itur_bt_2100.py index 08dc87c91..40ce0d3a0 100644 --- a/colour/models/rgb/transfer_functions/itur_bt_2100.py +++ b/colour/models/rgb/transfer_functions/itur_bt_2100.py @@ -1152,6 +1152,7 @@ def ootf_BT2100_HLG_1( if is_single_channel: return as_float(from_range_1(R_D)) + RGB_D = tstack([R_D, G_D, B_D]) return from_range_1(RGB_D) @@ -1238,6 +1239,7 @@ def ootf_BT2100_HLG_2( if is_single_channel: return as_float(from_range_1(R_D)) + RGB_D = tstack([R_D, G_D, B_D]) return from_range_1(RGB_D) @@ -1433,6 +1435,7 @@ def ootf_inverse_BT2100_HLG_1( if is_single_channel: return as_float(from_range_1(R_S)) + RGB_S = tstack([R_S, G_S, B_S]) return from_range_1(RGB_S) @@ -1531,6 +1534,7 @@ def ootf_inverse_BT2100_HLG_2( if is_single_channel: return as_float(from_range_1(R_S)) + RGB_S = tstack([R_S, G_S, B_S]) return from_range_1(RGB_S) diff --git a/colour/models/rgb/transfer_functions/log.py b/colour/models/rgb/transfer_functions/log.py index e3ad2616d..991b23514 100644 --- a/colour/models/rgb/transfer_functions/log.py +++ b/colour/models/rgb/transfer_functions/log.py @@ -144,14 +144,19 @@ def logarithmic_function_basic( if style == "log10": return as_float(np.where(x >= FLT_MIN, np.log10(x), np.log10(FLT_MIN))) + if style == "antilog10": return as_float(10**x) + if style == "log2": return as_float(np.where(x >= FLT_MIN, np.log2(x), np.log2(FLT_MIN))) + if style == "antilog2": return as_float(2**x) + if style == "logb": return as_float(np.log(x) / np.log(base)) + # style == 'antilogb' return as_float(base**x) diff --git a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py index 6f15079e4..6b7287309 100644 --- a/colour/models/rgb/transfer_functions/rimm_romm_rgb.py +++ b/colour/models/rgb/transfer_functions/rimm_romm_rgb.py @@ -124,6 +124,7 @@ def cctf_encoding_ROMMRGB( if out_int: return as_int(np.round(X_p)) + return as_float(from_range_1(X_p / I_max)) @@ -289,6 +290,7 @@ def cctf_encoding_RIMMRGB( if out_int: return as_int(np.round(X_p)) + return as_float(from_range_1(X_p / I_max)) @@ -454,6 +456,7 @@ def log_encoding_ERIMMRGB( if out_int: return as_int(np.round(X_p)) + return as_float(from_range_1(X_p / I_max)) diff --git a/colour/models/rgb/ycbcr.py b/colour/models/rgb/ycbcr.py index 31a69a659..aea232617 100644 --- a/colour/models/rgb/ycbcr.py +++ b/colour/models/rgb/ycbcr.py @@ -521,6 +521,7 @@ def RGB_to_YCbCr( return as_int_array( round_BT2100(np.clip(YCbCr, 0, 2**out_bits - 1) if clamp_int else YCbCr) ) + return from_range_1(YCbCr) @@ -768,6 +769,7 @@ def RGB_to_YcCbcCrc( if out_int: return as_int_array(np.round(YcCbcCrc)) + return from_range_1(YcCbcCrc) diff --git a/colour/notation/hexadecimal.py b/colour/notation/hexadecimal.py index 08106f7c1..47d8ce040 100644 --- a/colour/notation/hexadecimal.py +++ b/colour/notation/hexadecimal.py @@ -91,6 +91,7 @@ def RGB_to_HEX(RGB: ArrayLike) -> NDArrayStr: to_HEX = np.vectorize("{:02x}".format) HEX = to_HEX(as_int_array(RGB * 255, dtype=np.uint8)).astype(object) + return np.asarray("#") + HEX[..., 0] + HEX[..., 1] + HEX[..., 2] diff --git a/colour/notation/munsell.py b/colour/notation/munsell.py index 7c613f601..c774f787e 100644 --- a/colour/notation/munsell.py +++ b/colour/notation/munsell.py @@ -1078,6 +1078,7 @@ def _xyY_to_munsell_specification(xyY: ArrayLike) -> NDArrayFloat: phi_input = np.degrees(phi_input) grey_threshold = THRESHOLD_INTEGER + if rho_input < grey_threshold: return from_range_10(normalise_munsell_specification(value)) @@ -1575,6 +1576,7 @@ def normalise_munsell_specification(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return specification * np.array([np.nan, 1, np.nan, np.nan]) # pyright: ignore + hue, value, chroma, code = specification if hue == 0: @@ -1583,6 +1585,7 @@ def normalise_munsell_specification(specification: ArrayLike) -> NDArrayFloat: if chroma == 0: return tstack([np.nan, value, np.nan, np.nan]) + return tstack([hue, value, chroma, code]) @@ -1651,6 +1654,7 @@ def munsell_specification_to_munsell_colour( if is_grey_munsell_colour(specification): return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) + hue = round(hue, hue_decimals) attest( 0 <= hue <= 10, @@ -1681,6 +1685,7 @@ def munsell_specification_to_munsell_colour( if value == 0: return MUNSELL_GRAY_EXTENDED_FORMAT.format(value, value_decimals) + hue_letter = MUNSELL_HUE_LETTER_CODES.first_key_from_value(code) return MUNSELL_COLOUR_EXTENDED_FORMAT.format( @@ -1747,6 +1752,7 @@ def xyY_from_renotation( ) return MUNSELL_COLOURS_ALL[as_int_scalar(index[0])][1] + except Exception as exception: error = ( f'"{specification}" specification does not exists in ' @@ -2307,6 +2313,7 @@ def xy_from_renotation_ovoid(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return CCS_ILLUMINANT_MUNSELL + hue, value, chroma, code = specification attest( @@ -2603,6 +2610,7 @@ def munsell_specification_to_xy(specification: ArrayLike) -> NDArrayFloat: if is_grey_munsell_colour(specification): return CCS_ILLUMINANT_MUNSELL + hue, value, chroma, code = specification attest( diff --git a/colour/plotting/common.py b/colour/plotting/common.py index ec822f65f..640a1795d 100644 --- a/colour/plotting/common.py +++ b/colour/plotting/common.py @@ -540,6 +540,7 @@ def artist(**kwargs: KwargsArtist | Any) -> Tuple[Figure, Axes]: figure = plt.figure(figsize=figure_size) return figure, figure.gca() + axes = cast(Axes, axes) figure = axes.figure diff --git a/colour/plotting/tm3018/report.py b/colour/plotting/tm3018/report.py index e0117da3b..4ac35813f 100644 --- a/colour/plotting/tm3018/report.py +++ b/colour/plotting/tm3018/report.py @@ -781,7 +781,9 @@ def plot_single_sd_colour_rendition_report( if method == "full": return plot_single_sd_colour_rendition_report_full(sd, **kwargs) + if method == "intermediate": return plot_single_sd_colour_rendition_report_intermediate(sd, **kwargs) + # method == 'simple' return plot_single_sd_colour_rendition_report_simple(sd, **kwargs) diff --git a/colour/quality/cfi2017.py b/colour/quality/cfi2017.py index f218462e0..f9d271cea 100644 --- a/colour/quality/cfi2017.py +++ b/colour/quality/cfi2017.py @@ -260,6 +260,7 @@ def colour_fidelity_index_CIE2017( (test_tcs_colorimetry_data, reference_tcs_colorimetry_data), delta_E_s, ) + return R_f diff --git a/colour/quality/cqs.py b/colour/quality/cqs.py index cc8fddc88..0f514dabd 100644 --- a/colour/quality/cqs.py +++ b/colour/quality/cqs.py @@ -322,6 +322,7 @@ def colour_quality_scale( Q_as, (test_vs_colorimetry_data, reference_vs_colorimetry_data), ) + return Q_a @@ -473,6 +474,7 @@ def CCT_factor( ) G_r = gamut_area(Lab) / GAMUT_AREA_D65 + return min(G_r, 1) diff --git a/colour/quality/cri.py b/colour/quality/cri.py index 5d6adf7e1..813354ec2 100644 --- a/colour/quality/cri.py +++ b/colour/quality/cri.py @@ -207,6 +207,7 @@ def colour_rendering_index( Q_as, (test_tcs_colorimetry_data, reference_tcs_colorimetry_data), ) + return Q_a diff --git a/colour/recovery/jakob2019.py b/colour/recovery/jakob2019.py index 08b311134..ba4fb5407 100644 --- a/colour/recovery/jakob2019.py +++ b/colour/recovery/jakob2019.py @@ -341,6 +341,7 @@ def intermediate_XYZ_to_Lab( if additional_data: return error, derror, R, XYZ, Lab_i + return error, derror @@ -683,6 +684,7 @@ def XYZ_to_sd_Jakob2019( if additional_data: return sd, error + return sd diff --git a/colour/recovery/jiang2013.py b/colour/recovery/jiang2013.py index 4fce467b1..951877ba3 100644 --- a/colour/recovery/jiang2013.py +++ b/colour/recovery/jiang2013.py @@ -164,6 +164,7 @@ def normalised_sensitivity( (R_w_v[1], G_w_v[1], B_w_v[1]), (R_w_v[0], G_w_v[0], B_w_v[0]), ) + return R_w_v[1], G_w_v[1], B_w_v[1] diff --git a/colour/recovery/meng2015.py b/colour/recovery/meng2015.py index 89aefaf1e..807d16e6d 100644 --- a/colour/recovery/meng2015.py +++ b/colour/recovery/meng2015.py @@ -186,6 +186,7 @@ def constraint_function(a: ArrayLike) -> NDArrayFloat: """Define the constraint function.""" sd[:] = a + return sd_to_XYZ_integration(sd, cmfs=cmfs, illuminant=illuminant) - XYZ wavelengths = sd.wavelengths diff --git a/colour/recovery/otsu2018.py b/colour/recovery/otsu2018.py index a6a877d26..aebfb22c3 100644 --- a/colour/recovery/otsu2018.py +++ b/colour/recovery/otsu2018.py @@ -248,6 +248,7 @@ def __str__(self) -> str: f"{self.__class__.__name__}" f"({self._basis_functions.shape[0]} basis functions)" ) + return f"{self.__class__.__name__}()" def select(self, xy: ArrayLike) -> int: @@ -1201,6 +1202,7 @@ def branch_reconstruction_error(self) -> float: if self.is_leaf(): return self.leaf_reconstruction_error() + return as_float_scalar( np.sum([child.branch_reconstruction_error() for child in self.children]) ) diff --git a/colour/temperature/ohno2013.py b/colour/temperature/ohno2013.py index a3f1ef52f..3aea40f76 100644 --- a/colour/temperature/ohno2013.py +++ b/colour/temperature/ohno2013.py @@ -141,6 +141,7 @@ def planckian_table( [np.reshape(Ti, (-1, 1)), CCT_to_uv_Planck1900(Ti, cmfs)], axis=1 ) _CACHE_PLANCKIAN_TABLE[hash_key] = table.copy() + return table diff --git a/colour/utilities/array.py b/colour/utilities/array.py index 50e98e7bd..59210af5a 100644 --- a/colour/utilities/array.py +++ b/colour/utilities/array.py @@ -529,7 +529,9 @@ def arithmetical_operation( if in_place: for field in self.keys: setattr(self, field, getattr(dataclass, field)) + return self + return dataclass @@ -2018,6 +2020,7 @@ def interval(distribution: ArrayLike, unique: bool = True) -> NDArray: unique, ) ) + if is_caching_enabled() and hash_key in _CACHE_DISTRIBUTION_INTERVAL: return np.copy(_CACHE_DISTRIBUTION_INTERVAL[hash_key]) diff --git a/colour/utilities/common.py b/colour/utilities/common.py index e84612446..8fcedb880 100644 --- a/colour/utilities/common.py +++ b/colour/utilities/common.py @@ -1043,6 +1043,7 @@ def optional(value: T | None, default: T) -> T: if value is None: return default + return value diff --git a/colour/utilities/network.py b/colour/utilities/network.py index c8e4199de..1d9c0b84f 100644 --- a/colour/utilities/network.py +++ b/colour/utilities/network.py @@ -297,6 +297,7 @@ def root(self) -> Self: if self.is_root(): return self + return list(self.walk_hierarchy(ascendants=True))[-1] @property @@ -312,6 +313,7 @@ def leaves(self) -> Generator: if self.is_leaf(): return (node for node in (self,)) + return (node for node in self.walk_hierarchy() if node.is_leaf()) @property @@ -327,6 +329,7 @@ def siblings(self) -> Generator: if self.parent is None: return (sibling for sibling in ()) + return (sibling for sibling in self.parent.children if sibling is not self) @property diff --git a/colour/utilities/structures.py b/colour/utilities/structures.py index 05977c3a2..090ef6db6 100644 --- a/colour/utilities/structures.py +++ b/colour/utilities/structures.py @@ -338,7 +338,9 @@ def __repr__(self) -> str: representation = repr( dict(zip(self.keys(), ["..."] * len(self), strict=True)) ).replace("'...'", "...") + return f"{self.__class__.__name__}({representation})" + return f"{self.__class__.__name__}({dict(self.items())})" def __setitem__(self, item: str | Any, value: Any) -> None: diff --git a/colour/volume/macadam_limits.py b/colour/volume/macadam_limits.py index 08b1023d6..f7c55d62d 100644 --- a/colour/volume/macadam_limits.py +++ b/colour/volume/macadam_limits.py @@ -128,4 +128,5 @@ def is_within_macadam_limits( ) simplex = triangulation.find_simplex(xyY_to_XYZ(xyY), tol=tolerance) + return np.where(simplex >= 0, True, False) diff --git a/colour/volume/mesh.py b/colour/volume/mesh.py index 1c508839e..b2954c8a0 100644 --- a/colour/volume/mesh.py +++ b/colour/volume/mesh.py @@ -71,4 +71,5 @@ def is_within_mesh_volume( triangulation = Delaunay(mesh) simplex = triangulation.find_simplex(points, tol=tolerance) + return np.where(simplex >= 0, True, False)