diff --git a/.coveragerc b/.coveragerc index 366a5ea..171cfe5 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,5 +1,6 @@ [run] source = colour_datasets +sigterm = True [report] exclude_lines = pragma: no cover diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 8dd399a..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length = 88 -extend-ignore = E203 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 21ad42b..32e3642 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,11 +15,11 @@ is available to guide the process: https://www.colour-science.org/contributing/. **Code Style and Quality** - [ ] Unit tests have been implemented and passed. -- [ ] Mypy static checking has been run and passed. +- [ ] Pyright static checking has been run and passed. - [ ] Pre-commit hooks have been run and passed. - + **Documentation** diff --git a/.github/workflows/continuous-integration-documentation.yml b/.github/workflows/continuous-integration-documentation.yml index 2165290..cc10aa0 100644 --- a/.github/workflows/continuous-integration-documentation.yml +++ b/.github/workflows/continuous-integration-documentation.yml @@ -30,6 +30,8 @@ jobs: sudo apt-get update sudo apt-get --yes install latexmk texlive-full - name: Install Poetry + env: + POETRY_VERSION: 1.4.0 run: | curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - echo "$HOME/.poetry/bin" >> $GITHUB_PATH @@ -37,7 +39,7 @@ jobs: - name: Install Package Dependencies run: | poetry run python -m pip install --upgrade pip - poetry install --extras "read-the-docs" + poetry install poetry run python -c "import imageio;imageio.plugins.freeimage.download()" shell: bash - name: Build Documentation diff --git a/.github/workflows/continuous-integration-quality-unit-tests.yml b/.github/workflows/continuous-integration-quality-unit-tests.yml index f7e514a..3e20fce 100644 --- a/.github/workflows/continuous-integration-quality-unit-tests.yml +++ b/.github/workflows/continuous-integration-quality-unit-tests.yml @@ -29,6 +29,8 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install Poetry + env: + POETRY_VERSION: 1.4.0 run: | curl -sSL https://install.python-poetry.org | POETRY_HOME=$HOME/.poetry python3 - echo "$HOME/.poetry/bin" >> $GITHUB_PATH @@ -48,7 +50,7 @@ jobs: shell: bash - name: Test with Pytest run: | - poetry run python -W ignore -m pytest --disable-warnings --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE + poetry run python -W ignore -m pytest --doctest-modules --ignore=$CI_PACKAGE/examples --cov=$CI_PACKAGE $CI_PACKAGE shell: bash - name: Upload Coverage to coveralls.io run: | diff --git a/.github/workflows/continuous-integration-static-type-checking.yml b/.github/workflows/continuous-integration-static-type-checking.yml index 6b834da..7cba9b6 100644 --- a/.github/workflows/continuous-integration-static-type-checking.yml +++ b/.github/workflows/continuous-integration-static-type-checking.yml @@ -26,4 +26,4 @@ jobs: pip install -r requirements.txt - name: Static Type Checking run: | - mypy --install-types --non-interactive --show-error-codes --warn-unused-ignores --warn-redundant-casts $CI_PACKAGE + pyright --skipunannotated diff --git a/.gitignore b/.gitignore index 2088310..8c55073 100644 --- a/.gitignore +++ b/.gitignore @@ -2,12 +2,10 @@ *.pyc *.pyo .DS_Store -.coverage -.dmypy.json +.coverage* .fleet .idea .ipynb_checkpoints -.mypy_cache .sandbox .vs .vscode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3743cf6..b527df6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,14 @@ repos: -- repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 - hooks: - - id: pyupgrade - args: [--py39-plus] - repo: https://github.com/ikamensh/flynt/ - rev: '0.77' + rev: '1.0.1' hooks: - id: flynt +- repo: https://github.com/charliermarsh/ruff-pre-commit + rev: 'v0.0.285' + hooks: + - id: ruff - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.7.0 hooks: - id: black language_version: python3.9 @@ -18,14 +17,3 @@ repos: hooks: - id: blackdoc language_version: python3.9 -- repo: https://github.com/PyCQA/flake8 - rev: 6.0.0 - hooks: - - id: flake8 -- repo: https://github.com/pycqa/pydocstyle - rev: 6.1.1 - hooks: - - id: pydocstyle - args: - - --convention=numpy - - --add-ignore=D104,D200,D202,D205,D301,D400 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 2834365..c93eb8a 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -13,8 +13,5 @@ formats: - pdf python: - install: - - method: pip - path: . - extra_requirements: - - read-the-docs \ No newline at end of file + install: + - requirements: docs/requirements.txt \ No newline at end of file diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index e7c90b9..33a5b49 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -13,5 +13,5 @@ About | **Colour - Datasets** by Colour Developers | Copyright 2019 Colour Developers – `colour-developers@colour-science.org `__ -| This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause +| This software is released under terms of BSD-3-Clause: https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-datasets `__ diff --git a/LICENSE b/LICENSE index b03bcb9..49605b2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,27 +1,11 @@ Copyright 2019 Colour Developers -All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of the Colour Developers nor the - names of its contributors may be used to endorse or promote products - derived from this software without specific prior written permission. +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL COLOUR DEVELOPERS BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. -Copyright for portions of project openpyxl are held by Openpyxl Developers, -2010 as part of project openpyxl distributed under the MIT Licence. +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE diff --git a/README.rst b/README.rst index d1847bd..d6d6be2 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Colour - Datasets |actions| |coveralls| |codacy| |version| -.. |actions| image:: https://img.shields.io/github/workflow/status/colour-science/colour-datasets/Continuous%20Integration%20-%20Quality%20&%20Unit%20Tests?label=actions&logo=github&style=flat-square +.. |actions| image:: https://img.shields.io/github/actions/workflow/status/colour-science/colour-datasets/.github/workflows/continuous-integration-quality-unit-tests.yml?branch=develop&style=flat-square :target: https://github.com/colour-science/colour-datasets/actions :alt: Develop Build Status .. |coveralls| image:: http://img.shields.io/coveralls/colour-science/colour-datasets/develop.svg?style=flat-square @@ -24,11 +24,11 @@ Colour science datasets for use with `Colour `__ or any Python package manipulating colours. The datasets are hosted in `Zenodo `__ under the -`Colour Science - Datasets `__ +`Colour Science - Datasets `__ community. It is open source and freely available under the -`New BSD License `__ terms. +`BSD-3-Clause `__ terms. .. contents:: **Table of Contents** :backlinks: none @@ -50,7 +50,7 @@ when trying to access or use colour science datasets: **Colour - Datasets** offers all the above: it allows users to ingest and load colour science datasets with a single function call. The datasets information -is hosted on `Zenodo `__ +is hosted on `Zenodo `__ where the record for a dataset typically contain: - An *urls.txt* file describing the urls to source the dataset files from. @@ -156,14 +156,14 @@ Primary Dependencies **Colour - Datasets** requires various dependencies in order to run: -- `python >= 3.8, < 4 `__ -- `cachetools `__ -- `colour-science >= 4 `__ -- `imageio >= 2, < 3 `__ -- `numpy >= 1.19, < 2 `__ -- `scipy >= 1.5, < 2 `__ -- `tqdm `__ -- `xlrd `__ +- `python >= 3.9, < 4 `__ +- `cachetools `__ +- `colour-science >= 4.3 `__ +- `imageio >= 2, < 3 `__ +- `numpy >= 1.22, < 2 `__ +- `scipy >= 1.8, < 2 `__ +- `tqdm `__ +- `xlrd `__ Pypi ~~~~ @@ -182,7 +182,7 @@ Contributing ^^^^^^^^^^^^ If you would like to contribute to `Colour - Datasets `__, -please refer to the following `Contributing `__ +please refer to the following `Contributing `__ guide for `Colour `__. Bibliography @@ -202,7 +202,7 @@ Code of Conduct --------------- The *Code of Conduct*, adapted from the `Contributor Covenant 1.4 `__, -is available on the `Code of Conduct `__ page. +is available on the `Code of Conduct `__ page. Contact & Social ---------------- @@ -220,5 +220,5 @@ About | **Colour - Datasets** by Colour Developers | Copyright 2019 Colour Developers – `colour-developers@colour-science.org `__ -| This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause +| This software is released under terms of BSD-3-Clause: https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-datasets `__ diff --git a/TODO.rst b/TODO.rst index 9e502a0..fbcc4ac 100644 --- a/TODO.rst +++ b/TODO.rst @@ -10,6 +10,6 @@ About ----- | **Colour - Datasets** by Colour Developers -| Copyright 2019 Colour Developers – `colour-developers@colour-science.org `__ -| This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause +| Copyright 2019 Colour Developers - `colour-developers@colour-science.org `__ +| This software is released under terms of BSD-3-Clause: https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-datasets `__ diff --git a/colour_datasets/__init__.py b/colour_datasets/__init__.py index 90b4b20..c41c55d 100644 --- a/colour_datasets/__init__.py +++ b/colour_datasets/__init__.py @@ -6,7 +6,7 @@ `Colour `__ or any Python package manipulating colours. The datasets are hosted in `Zenodo `__ under the `Colour Science - Datasets \ -`__ community. +`__ community. Subpackages ----------- @@ -15,9 +15,10 @@ - utilities: Various utilities. """ +import contextlib import numpy as np import os -import subprocess # nosec +import subprocess import colour @@ -28,7 +29,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -52,15 +53,15 @@ __major_version__ = "0" __minor_version__ = "2" -__change_version__ = "1" +__change_version__ = "2" __version__ = ".".join( (__major_version__, __minor_version__, __change_version__) ) try: _version = ( - subprocess.check_output( # nosec - ["git", "describe"], + subprocess.check_output( + ["git", "describe"], # noqa: S603, S607 cwd=os.path.dirname(__file__), stderr=subprocess.STDOUT, ) @@ -70,14 +71,12 @@ except Exception: _version = __version__ -colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES[ +colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES[ # pyright: ignore "colour-datasets" ] = _version del _version # TODO: Remove legacy printing support when deemed appropriate. -try: +with contextlib.suppress(TypeError): np.set_printoptions(legacy="1.13") -except TypeError: - pass diff --git a/colour_datasets/loaders/__init__.py b/colour_datasets/loaders/__init__.py index b535144..b28c0a9 100644 --- a/colour_datasets/loaders/__init__.py +++ b/colour_datasets/loaders/__init__.py @@ -2,7 +2,7 @@ import sys -from colour.hints import Any, Boolean, Integer, Union +from colour.hints import Any from colour.utilities import CanonicalMapping, warning from colour_datasets.records import datasets @@ -105,26 +105,23 @@ Dataset loaders ids and callables. """ -from .kuopio import DATASET_LOADERS_KUOPIO_UNIVERSITY # noqa +from .kuopio import DATASET_LOADERS_KUOPIO_UNIVERSITY # noqa: E402 DATASET_LOADERS.update(DATASET_LOADERS_KUOPIO_UNIVERSITY) -from . import kuopio # noqa +from . import kuopio # noqa: E402 _module = sys.modules["colour_datasets.loaders"] for _export in kuopio.__all__: - if _export.startswith("DatasetLoader_") or _export.startswith("build_"): - + if _export.startswith(("DatasetLoader_", "build_")): setattr(_module, _export, getattr(kuopio, _export)) - __all__ += [ - _export, - ] + __all__ += [_export] # noqa: PLE0604 del _module, _export -_HAS_TITLE_KEYS: Boolean = False +_HAS_TITLE_KEYS: bool = False """ Whether the :attr:`colour_datasets.loaders.DATASET_LOADERS` attribute has been updated with dataset titles. This variable is used in the one time @@ -133,7 +130,7 @@ """ -def load(dataset: Union[Integer, str]) -> Any: +def load(dataset: int | str) -> Any: """ Load given dataset: The dataset is pulled locally, i.e. synced if required and then its data is loaded. @@ -161,7 +158,7 @@ def load(dataset: Union[Integer, str]) -> Any: 28 """ - global _HAS_TITLE_KEYS + global _HAS_TITLE_KEYS # noqa: PLW0603 if not _HAS_TITLE_KEYS: for key in list(DATASET_LOADERS.keys())[:]: diff --git a/colour_datasets/loaders/abstract.py b/colour_datasets/loaders/abstract.py index e800a21..61c2215 100644 --- a/colour_datasets/loaders/abstract.py +++ b/colour_datasets/loaders/abstract.py @@ -11,13 +11,13 @@ from abc import ABC, abstractmethod -from colour.hints import Any, Optional +from colour.hints import Any from colour_datasets.records import Record __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -63,7 +63,7 @@ class AbstractDatasetLoader(ABC): def __init__(self, record: Record) -> None: self._record: Record = record - self._content: Optional[Any] = None + self._content: Any | None = None @property def record(self) -> Record: @@ -79,7 +79,7 @@ def record(self) -> Record: return self._record @property - def id(self) -> str: + def id(self) -> str: # noqa: A003 """ Getter property for the dataset id. @@ -122,8 +122,6 @@ def load(self) -> Any: when they implement it, e.g. ``super().sync()``. """ - pass - def sync(self): """ Sync the dataset content, i.e. checks whether it is synced and pulls diff --git a/colour_datasets/loaders/asano2015.py b/colour_datasets/loaders/asano2015.py index cd08dbb..50376f8 100644 --- a/colour_datasets/loaders/asano2015.py +++ b/colour_datasets/loaders/asano2015.py @@ -26,7 +26,7 @@ XYZ_ColourMatchingFunctions, LMS_ConeFundamentals, ) -from colour.hints import Boolean, Dict, NDArray, Optional, Tuple +from colour.hints import Dict, NDArrayFloat from colour.utilities import as_float_array, tstack from colour_datasets.loaders import AbstractDatasetLoader @@ -35,7 +35,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -52,7 +52,7 @@ class Specification_Asano2015( "Specification_Asano2015", ("XYZ_2", "XYZ_10", "LMS_2", "LMS_10", "parameters", "others"), ) -): # noqa: D405,D407,D410,D411 +): """ Define the *Asano (2015)* specification for an observer. @@ -74,7 +74,7 @@ class Specification_Asano2015( References ---------- :cite:`Asano2015` - """ + """ # noqa: D405, D407, D410, D411 def __new__( cls, @@ -82,8 +82,8 @@ def __new__( XYZ_10: XYZ_ColourMatchingFunctions, LMS_2: LMS_ConeFundamentals, LMS_10: LMS_ConeFundamentals, - parameters: NDArray, - others: Optional[Dict] = None, + parameters: NDArrayFloat, + others: Dict | None = None, ): """ Return a new instance of the @@ -122,7 +122,7 @@ class DatasetLoader_Asano2015(AbstractDatasetLoader): def __init__(self) -> None: super().__init__(datasets()[DatasetLoader_Asano2015.ID]) - def load(self) -> Dict[str, Specification_Asano2015]: + def load(self) -> Dict[str, Dict[int, Specification_Asano2015]]: """ Sync, parse, convert and return the *Asano (2015)* *Observer Function Database* dataset content. @@ -145,12 +145,10 @@ def load(self) -> Dict[str, Specification_Asano2015]: super().sync() - self._content = dict( - [ - ("Categorical Observers", dict()), - ("Colour Normal Observers", dict()), - ] - ) + self._content = { + "Categorical Observers": {}, + "Colour Normal Observers": {}, + } # Categorical Observers workbook_path = os.path.join( @@ -217,7 +215,7 @@ def load(self) -> Dict[str, Specification_Asano2015]: @staticmethod def parse_workbook_Asano2015( - workbook: str, template: str, observers: Tuple = (1, 10) + workbook: str, template: str, observers: tuple = (1, 10) ) -> Dict[str, Dict]: """ Parse given *Asano (2015)* *Observer Function Database* workbook. @@ -247,7 +245,7 @@ def parse_workbook_Asano2015( shape = SpectralShape(390, 780, 5) wavelengths = shape.range() - data: Dict = dict() + data: Dict = {} for i, cmfs in enumerate( [ @@ -255,11 +253,9 @@ def parse_workbook_Asano2015( (LMS_ConeFundamentals, "LMS"), ] ): - for j, degree in enumerate( [(2, "2$^\\circ$"), (10, "10$^\\circ$")] ): - sheet = book.sheet_by_index(j + (i * 2)) x = np.transpose( @@ -276,7 +272,7 @@ def parse_workbook_Asano2015( observer = k + 1 rgb = tstack([x[k], y[k], z[k]]) if data.get(observer) is None: - data[observer] = dict() + data[observer] = {} key = f"{cmfs[1]}_{degree[0]}" data[observer][key] = cmfs[0]( @@ -310,14 +306,14 @@ def parse_workbook_Asano2015( return data -_DATASET_LOADER_ASANO2015: Optional[DatasetLoader_Asano2015] = None +_DATASET_LOADER_ASANO2015: DatasetLoader_Asano2015 | None = None """ Singleton instance of the *Asano (2015)* *Observer Function Database* dataset loader. """ -def build_Asano2015(load: Boolean = True) -> DatasetLoader_Asano2015: +def build_Asano2015(load: bool = True) -> DatasetLoader_Asano2015: """ Singleton factory that the builds *Asano (2015)* *Observer Function Database* dataset loader. @@ -338,7 +334,7 @@ def build_Asano2015(load: Boolean = True) -> DatasetLoader_Asano2015: :cite:`Asano2015` """ - global _DATASET_LOADER_ASANO2015 + global _DATASET_LOADER_ASANO2015 # noqa: PLW0603 if _DATASET_LOADER_ASANO2015 is None: _DATASET_LOADER_ASANO2015 = DatasetLoader_Asano2015() diff --git a/colour_datasets/loaders/brendel2020.py b/colour_datasets/loaders/brendel2020.py index 8421704..3528974 100644 --- a/colour_datasets/loaders/brendel2020.py +++ b/colour_datasets/loaders/brendel2020.py @@ -21,7 +21,7 @@ import os from colour import LinearInterpolator, SpectralShape, SpectralDistribution -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour.utilities import as_int from colour_datasets.loaders import AbstractDatasetLoader @@ -29,7 +29,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -87,7 +87,7 @@ def load(self) -> Dict[str, SpectralDistribution]: super().sync() - self._content = dict() + self._content = {} wavelengths = SpectralShape(350, 700, 2).range() @@ -108,14 +108,14 @@ def load(self) -> Dict[str, SpectralDistribution]: return self._content -_DATASET_LOADER_BRENDEL2020: Optional[DatasetLoader_Brendel2020] = None +_DATASET_LOADER_BRENDEL2020: DatasetLoader_Brendel2020 | None = None """ Singleton instance of the *Brendel (2020)* *Measured Commercial LED Spectra* dataset loader. """ -def build_Brendel2020(load: Boolean = True) -> DatasetLoader_Brendel2020: +def build_Brendel2020(load: bool = True) -> DatasetLoader_Brendel2020: """ Singleton factory that builds the *Brendel (2020)* *Measured Commercial LED Spectra* dataset loader. @@ -136,7 +136,7 @@ def build_Brendel2020(load: Boolean = True) -> DatasetLoader_Brendel2020: :cite:`Brendel2020` """ - global _DATASET_LOADER_BRENDEL2020 + global _DATASET_LOADER_BRENDEL2020 # noqa: PLW0603 if _DATASET_LOADER_BRENDEL2020 is None: _DATASET_LOADER_BRENDEL2020 = DatasetLoader_Brendel2020() diff --git a/colour_datasets/loaders/dyer2017.py b/colour_datasets/loaders/dyer2017.py index 5055ab0..9cadfba 100644 --- a/colour_datasets/loaders/dyer2017.py +++ b/colour_datasets/loaders/dyer2017.py @@ -22,17 +22,7 @@ from colour import MultiSpectralDistributions, SpectralDistribution from colour.continuous import MultiSignals, Signal -from colour.hints import ( - Any, - Boolean, - Dict, - Floating, - Literal, - Optional, - Type, - Union, - cast, -) +from colour.hints import Any, Dict, Literal from colour.utilities import attest, is_numeric, is_string, optional from colour_datasets.loaders import AbstractDatasetLoader @@ -40,7 +30,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -115,38 +105,37 @@ class SpectralDataHeader_AMPAS: def __init__( self, - schema_version: Optional[str] = None, - catalog_number: Optional[str] = None, - description: Optional[str] = None, - document_creator: Optional[str] = None, - unique_identifier: Optional[str] = None, - measurement_equipment: Optional[str] = None, - laboratory: Optional[str] = None, - document_creation_date: Optional[str] = None, - comments: Optional[str] = None, - license: Optional[str] = None, + schema_version: str | None = None, + catalog_number: str | None = None, + description: str | None = None, + document_creator: str | None = None, + unique_identifier: str | None = None, + measurement_equipment: str | None = None, + laboratory: str | None = None, + document_creation_date: str | None = None, + comments: str | None = None, + license: str | None = None, # noqa: A002 **kwargs: Any, ) -> None: - - self._schema_version: Optional[str] = None + self._schema_version: str | None = None self.schema_version = schema_version - self._catalog_number: Optional[str] = None + self._catalog_number: str | None = None self.catalog_number = catalog_number - self._description: Optional[str] = None + self._description: str | None = None self.description = description - self._document_creator: Optional[str] = None + self._document_creator: str | None = None self.document_creator = document_creator - self._unique_identifier: Optional[str] = None + self._unique_identifier: str | None = None self.unique_identifier = unique_identifier - self._measurement_equipment: Optional[str] = None + self._measurement_equipment: str | None = None self.measurement_equipment = measurement_equipment - self._laboratory: Optional[str] = None + self._laboratory: str | None = None self.laboratory = laboratory - self._document_creation_date: Optional[str] = None + self._document_creation_date: str | None = None self.document_creation_date = document_creation_date - self._comments: Optional[str] = None + self._comments: str | None = None self.comments = comments - self._license: Optional[str] = None + self._license: str | None = None self.license = license # TODO: Re-instate "manufacturer", "model", "illuminant" and "type" @@ -156,7 +145,7 @@ def __init__( self._kwargs: Any = kwargs @property - def schema_version(self) -> Optional[str]: + def schema_version(self) -> str | None: """ Getter and setter property for the schema version. @@ -174,7 +163,7 @@ def schema_version(self) -> Optional[str]: return self._schema_version @schema_version.setter - def schema_version(self, value: Optional[str]): + def schema_version(self, value: str | None): """Setter for the **self.schema_version** property.""" if value is not None: @@ -186,7 +175,7 @@ def schema_version(self, value: Optional[str]): self._schema_version = value @property - def catalog_number(self) -> Optional[str]: + def catalog_number(self) -> str | None: """ Getter and setter property for the catalog number. @@ -204,7 +193,7 @@ def catalog_number(self) -> Optional[str]: return self._catalog_number @catalog_number.setter - def catalog_number(self, value: Optional[str]): + def catalog_number(self, value: str | None): """Setter for the **self.catalog_number** property.""" if value is not None: @@ -216,7 +205,7 @@ def catalog_number(self, value: Optional[str]): self._catalog_number = value @property - def description(self) -> Optional[str]: + def description(self) -> str | None: """ Getter and setter property for the description. @@ -234,7 +223,7 @@ def description(self) -> Optional[str]: return self._description @description.setter - def description(self, value: Optional[str]): + def description(self, value: str | None): """Setter for the **self.description** property.""" if value is not None: @@ -246,7 +235,7 @@ def description(self, value: Optional[str]): self._description = value @property - def document_creator(self) -> Optional[str]: + def document_creator(self) -> str | None: """ Getter and setter property for the document creator. @@ -264,7 +253,7 @@ def document_creator(self) -> Optional[str]: return self._document_creator @document_creator.setter - def document_creator(self, value: Optional[str]): + def document_creator(self, value: str | None): """Setter for the **self.document_creator** property.""" if value is not None: @@ -276,7 +265,7 @@ def document_creator(self, value: Optional[str]): self._document_creator = value @property - def unique_identifier(self) -> Optional[str]: + def unique_identifier(self) -> str | None: """ Getter and setter property for the unique identifier. @@ -294,7 +283,7 @@ def unique_identifier(self) -> Optional[str]: return self._unique_identifier @unique_identifier.setter - def unique_identifier(self, value: Optional[str]): + def unique_identifier(self, value: str | None): """Setter for the **self.unique_identifier** property.""" if value is not None: @@ -306,7 +295,7 @@ def unique_identifier(self, value: Optional[str]): self._unique_identifier = value @property - def measurement_equipment(self) -> Optional[str]: + def measurement_equipment(self) -> str | None: """ Getter and setter property for the measurement equipment. @@ -324,7 +313,7 @@ def measurement_equipment(self) -> Optional[str]: return self._measurement_equipment @measurement_equipment.setter - def measurement_equipment(self, value: Optional[str]): + def measurement_equipment(self, value: str | None): """Setter for the **self.measurement_equipment** property.""" if value is not None: @@ -337,7 +326,7 @@ def measurement_equipment(self, value: Optional[str]): self._measurement_equipment = value @property - def laboratory(self) -> Optional[str]: + def laboratory(self) -> str | None: """ Getter and setter property for the laboratory. @@ -355,7 +344,7 @@ def laboratory(self) -> Optional[str]: return self._laboratory @laboratory.setter - def laboratory(self, value: Optional[str]): + def laboratory(self, value: str | None): """Setter for the **self.measurement_equipment** property.""" if value is not None: @@ -367,7 +356,7 @@ def laboratory(self, value: Optional[str]): self._laboratory = value @property - def document_creation_date(self) -> Optional[str]: + def document_creation_date(self) -> str | None: """ Getter and setter property for the document creation date. @@ -385,7 +374,7 @@ def document_creation_date(self) -> Optional[str]: return self._document_creation_date @document_creation_date.setter - def document_creation_date(self, value: Optional[str]): + def document_creation_date(self, value: str | None): """Setter for the **self.document_creation_date** property.""" if value is not None: @@ -398,7 +387,7 @@ def document_creation_date(self, value: Optional[str]): self._document_creation_date = value @property - def comments(self) -> Optional[str]: + def comments(self) -> str | None: """ Getter and setter property for the comments. @@ -416,7 +405,7 @@ def comments(self) -> Optional[str]: return self._comments @comments.setter - def comments(self, value: Optional[str]): + def comments(self, value: str | None): """Setter for the **self.comments** property.""" if value is not None: @@ -428,7 +417,7 @@ def comments(self, value: Optional[str]): self._comments = value @property - def license(self) -> Optional[str]: + def license(self) -> str | None: # noqa: A003 """ Getter and setter property for the license. @@ -446,7 +435,7 @@ def license(self) -> Optional[str]: return self._license @license.setter - def license(self, value: Optional[str]): + def license(self, value: str | None): # noqa: A003 """Setter for the **self.license** property.""" if value is not None: @@ -532,97 +521,92 @@ class SpectralDistribution_AMPAS(SpectralDistribution): def __init__( self, - path: Optional[str] = None, - header: Optional[SpectralDataHeader_AMPAS] = None, - units: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ] = None, - reflection_geometry: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ] = None, - transmission_geometry: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ] = None, - bandwidth_FWHM: Optional[Floating] = None, - bandwidth_corrected: Optional[Boolean] = None, + path: str | None = None, + header: SpectralDataHeader_AMPAS | None = None, + units: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None = None, + reflection_geometry: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None = None, + transmission_geometry: Literal[ + "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" + ] + | None = None, + bandwidth_FWHM: float | None = None, + bandwidth_corrected: bool | None = None, ) -> None: super().__init__() - self._path: Optional[str] = None + self._path: str | None = None self.path = path self._header: SpectralDataHeader_AMPAS = SpectralDataHeader_AMPAS() self.header = optional(header, self._header) - self._units: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ] = None + self._units: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] | None = None self.units = units - self._reflection_geometry: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ] = None + self._reflection_geometry: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] | None = None self.reflection_geometry = reflection_geometry - self._transmission_geometry: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ] = None + self._transmission_geometry: Literal[ + "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" + ] | None = None self.transmission_geometry = transmission_geometry - self._bandwidth_FWHM: Optional[Floating] = None + self._bandwidth_FWHM: float | None = None self.bandwidth_FWHM = bandwidth_FWHM - self._bandwidth_corrected: Optional[Boolean] = None + self._bandwidth_corrected: bool | None = None self.bandwidth_corrected = bandwidth_corrected @property - def path(self) -> Optional[str]: + def path(self) -> str | None: """ Getter and setter property for the path. @@ -640,7 +624,7 @@ def path(self) -> Optional[str]: return self._path @path.setter - def path(self, value: Optional[str]): + def path(self, value: str | None): """Setter for the **self.path** property.""" if value is not None: @@ -681,7 +665,7 @@ def header(self, value: SpectralDataHeader_AMPAS): @property def units( self, - ) -> Optional[ + ) -> ( Literal[ "absorptance", "exitance", @@ -696,7 +680,8 @@ def units( "T-Factor", "other", ] - ]: + | None + ): """ Getter and setter property for the units. @@ -716,22 +701,21 @@ def units( @units.setter def units( self, - value: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ], + value: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None, ): """Setter for the **self.units** property.""" @@ -746,7 +730,7 @@ def units( @property def reflection_geometry( self, - ) -> Optional[ + ) -> ( Literal[ "di:8", "de:8", @@ -761,7 +745,8 @@ def reflection_geometry( "0:45x", "other", ] - ]: + | None + ): """ Getter and setter property for the reflection geometry. @@ -781,22 +766,21 @@ def reflection_geometry( @reflection_geometry.setter def reflection_geometry( self, - value: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ], + value: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None, ): """Setter for the **self.reflection_geometry** property.""" @@ -811,9 +795,7 @@ def reflection_geometry( @property def transmission_geometry( self, - ) -> Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ]: + ) -> Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] | None: """ Getter and setter property for the transmission geometry. @@ -833,21 +815,21 @@ def transmission_geometry( @transmission_geometry.setter def transmission_geometry( self, - value: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ], + value: Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] + | None, ): """Setter for the **self.transmission_geometry** property.""" if value is not None: - assert is_string(value), ( + attest( + is_string(value), f'"transmission_geometry" property: "{value}" type is not "str"!', ) self._transmission_geometry = value @property - def bandwidth_FWHM(self) -> Optional[Floating]: + def bandwidth_FWHM(self) -> float | None: """ Getter and setter property for the full-width half-maximum bandwidth. @@ -865,7 +847,7 @@ def bandwidth_FWHM(self) -> Optional[Floating]: return self._bandwidth_FWHM @bandwidth_FWHM.setter - def bandwidth_FWHM(self, value: Optional[Floating]): + def bandwidth_FWHM(self, value: float | None): """Setter for the **self.bandwidth_FWHM** property.""" if value is not None: @@ -877,7 +859,7 @@ def bandwidth_FWHM(self, value: Optional[Floating]): self._bandwidth_FWHM = value @property - def bandwidth_corrected(self) -> Optional[Boolean]: + def bandwidth_corrected(self) -> bool | None: """ Getter and setter property for whether bandwidth correction has been applied to the measured data. @@ -896,7 +878,7 @@ def bandwidth_corrected(self) -> Optional[Boolean]: return self._bandwidth_corrected @bandwidth_corrected.setter - def bandwidth_corrected(self, value: Optional[Boolean]): + def bandwidth_corrected(self, value: bool | None): """Setter for the **self.bandwidth_corrected** property.""" if value is not None: @@ -1040,97 +1022,92 @@ class MultiSpectralDistributions_AMPAS(MultiSpectralDistributions): def __init__( self, - path: Optional[str] = None, - header: Optional[SpectralDataHeader_AMPAS] = None, - units: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ] = None, - reflection_geometry: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ] = None, - transmission_geometry: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ] = None, - bandwidth_FWHM: Optional[Floating] = None, - bandwidth_corrected: Optional[Boolean] = None, + path: str | None = None, + header: SpectralDataHeader_AMPAS | None = None, + units: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None = None, + reflection_geometry: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None = None, + transmission_geometry: Literal[ + "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" + ] + | None = None, + bandwidth_FWHM: float | None = None, + bandwidth_corrected: bool | None = None, ) -> None: super().__init__() - self._path: Optional[str] = None + self._path: str | None = None self.path = path self._header: SpectralDataHeader_AMPAS = SpectralDataHeader_AMPAS() self.header = optional(header, self._header) - self._units: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ] = None + self._units: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] | None = None self.units = units - self._reflection_geometry: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ] = None + self._reflection_geometry: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] | None = None self.reflection_geometry = reflection_geometry - self._transmission_geometry: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ] = None + self._transmission_geometry: Literal[ + "0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other" + ] | None = None self.transmission_geometry = transmission_geometry - self._bandwidth_FWHM: Optional[Floating] = None + self._bandwidth_FWHM: float | None = None self.bandwidth_FWHM = bandwidth_FWHM - self._bandwidth_corrected: Optional[Boolean] = None + self._bandwidth_corrected: bool | None = None self.bandwidth_corrected = bandwidth_corrected @property - def path(self) -> Optional[str]: + def path(self) -> str | None: """ Getter and setter property for the path. @@ -1148,7 +1125,7 @@ def path(self) -> Optional[str]: return self._path @path.setter - def path(self, value: Optional[str]): + def path(self, value: str | None): """Setter for the **self.path** property.""" if value is not None: @@ -1189,7 +1166,7 @@ def header(self, value: SpectralDataHeader_AMPAS): @property def units( self, - ) -> Optional[ + ) -> ( Literal[ "absorptance", "exitance", @@ -1204,7 +1181,8 @@ def units( "T-Factor", "other", ] - ]: + | None + ): """ Getter and setter property for the units. @@ -1224,22 +1202,21 @@ def units( @units.setter def units( self, - value: Optional[ - Literal[ - "absorptance", - "exitance", - "flux", - "intensity", - "irradiance", - "radiance", - "reflectance", - "relative", - "transmittance", - "R-Factor", - "T-Factor", - "other", - ] - ], + value: Literal[ + "absorptance", + "exitance", + "flux", + "intensity", + "irradiance", + "radiance", + "reflectance", + "relative", + "transmittance", + "R-Factor", + "T-Factor", + "other", + ] + | None, ): """Setter for the **self.units** property.""" @@ -1254,7 +1231,7 @@ def units( @property def reflection_geometry( self, - ) -> Optional[ + ) -> ( Literal[ "di:8", "de:8", @@ -1269,7 +1246,8 @@ def reflection_geometry( "0:45x", "other", ] - ]: + | None + ): """ Getter and setter property for the reflection geometry. @@ -1289,22 +1267,21 @@ def reflection_geometry( @reflection_geometry.setter def reflection_geometry( self, - value: Optional[ - Literal[ - "di:8", - "de:8", - "8:di", - "8:de", - "d:d", - "d:0", - "45a:0", - "45c:0", - "0:45a", - "45x:0", - "0:45x", - "other", - ] - ], + value: Literal[ + "di:8", + "de:8", + "8:di", + "8:de", + "d:d", + "d:0", + "45a:0", + "45c:0", + "0:45a", + "45x:0", + "0:45x", + "other", + ] + | None, ): """Setter for the **self.reflection_geometry** property.""" @@ -1319,9 +1296,7 @@ def reflection_geometry( @property def transmission_geometry( self, - ) -> Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ]: + ) -> Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] | None: """ Getter and setter property for the transmission geometry. @@ -1341,21 +1316,21 @@ def transmission_geometry( @transmission_geometry.setter def transmission_geometry( self, - value: Optional[ - Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] - ], + value: Literal["0:0", "di:0", "de:0", "0:di", "0:de", "d:d", "other"] + | None, ): """Setter for the **self.transmission_geometry** property.""" if value is not None: - assert is_string(value), ( + attest( + is_string(value), f'"transmission_geometry" property: "{value}" type is not "str"!', ) self._transmission_geometry = value @property - def bandwidth_FWHM(self) -> Optional[Floating]: + def bandwidth_FWHM(self) -> float | None: """ Getter and setter property for the full-width half-maximum bandwidth. @@ -1373,7 +1348,7 @@ def bandwidth_FWHM(self) -> Optional[Floating]: return self._bandwidth_FWHM @bandwidth_FWHM.setter - def bandwidth_FWHM(self, value: Optional[Floating]): + def bandwidth_FWHM(self, value: float | None): """Setter for the **self.bandwidth_FWHM** property.""" if value is not None: @@ -1385,7 +1360,7 @@ def bandwidth_FWHM(self, value: Optional[Floating]): self._bandwidth_FWHM = value @property - def bandwidth_corrected(self) -> Optional[Boolean]: + def bandwidth_corrected(self) -> bool | None: """ Getter and setter property for whether bandwidth correction has been applied to the measured data. @@ -1404,7 +1379,7 @@ def bandwidth_corrected(self) -> Optional[Boolean]: return self._bandwidth_corrected @bandwidth_corrected.setter - def bandwidth_corrected(self, value: Optional[Boolean]): + def bandwidth_corrected(self, value: bool | None): """Setter for the **self.bandwidth_corrected** property.""" if value is not None: @@ -1509,9 +1484,7 @@ def load( str, Dict[ str, - Union[ - SpectralDistribution_AMPAS, MultiSpectralDistributions_AMPAS - ], + SpectralDistribution_AMPAS | MultiSpectralDistributions_AMPAS, ], ]: """ @@ -1536,18 +1509,14 @@ def load( super().sync() - self._content = dict() + self._content = {} for directory in ("camera", "cmf", "illuminant", "training"): - self._content[directory] = dict() - factory = cast( - Union[ - Type[SpectralDistribution_AMPAS], - Type[MultiSpectralDistributions_AMPAS], - ], + self._content[directory] = {} + factory = ( SpectralDistribution_AMPAS if directory == "illuminant" - else MultiSpectralDistributions_AMPAS, + else MultiSpectralDistributions_AMPAS ) glob_pattern = os.path.join( self.record.repository, "dataset", "data", directory, "*.json" @@ -1559,14 +1528,14 @@ def load( return self._content -_DATASET_LOADER_DYER2017: Optional[DatasetLoader_Dyer2017] = None +_DATASET_LOADER_DYER2017: DatasetLoader_Dyer2017 | None = None """ Singleton instance of the *Dyer et al. (2017)* *RAW to ACES Utility Data* dataset loader. """ -def build_Dyer2017(load: Boolean = True) -> DatasetLoader_Dyer2017: +def build_Dyer2017(load: bool = True) -> DatasetLoader_Dyer2017: """ Singleton factory that builds the *Dyer et al. (2017)* *RAW to ACES Utility Data* dataset loader. @@ -1587,7 +1556,7 @@ def build_Dyer2017(load: Boolean = True) -> DatasetLoader_Dyer2017: :cite:`Dyer2017` """ - global _DATASET_LOADER_DYER2017 + global _DATASET_LOADER_DYER2017 # noqa: PLW0603 if _DATASET_LOADER_DYER2017 is None: _DATASET_LOADER_DYER2017 = DatasetLoader_Dyer2017() diff --git a/colour_datasets/loaders/ebner1998.py b/colour_datasets/loaders/ebner1998.py index bb2f85c..db5a2dc 100644 --- a/colour_datasets/loaders/ebner1998.py +++ b/colour_datasets/loaders/ebner1998.py @@ -23,7 +23,7 @@ import os from collections import namedtuple -from colour.hints import Boolean, Dict, Integer, NDArray, Optional +from colour.hints import Dict, NDArrayFloat from colour.utilities import as_float_array from colour_datasets.loaders import AbstractDatasetLoader @@ -31,7 +31,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -98,7 +98,7 @@ def __init__(self) -> None: def load( self, - ) -> Dict[str, Dict[Integer, ConstantPerceivedHueColourMatches_Ebner1998]]: + ) -> Dict[str, Dict[int, ConstantPerceivedHueColourMatches_Ebner1998]]: """ Sync, parse, convert and return the *Ebner and Fairchild (1998)* *Constant Perceived-Hue Data* dataset content. @@ -122,13 +122,13 @@ def load( super().sync() - self._content = dict([("Constant Perceived-Hue Data", dict())]) + self._content = {"Constant Perceived-Hue Data": {}} datafile_path = os.path.join( self.record.repository, "dataset", "Ebner_Constant_Hue_Data.txt" ) - def _parse_float_values(data: str) -> NDArray: + def _parse_float_values(data: str) -> NDArrayFloat: """Parse float values from given data.""" values = np.reshape( @@ -149,7 +149,7 @@ def _parse_float_values(data: str) -> NDArray: if line.startswith("White Point"): XYZ_r = _parse_float_values(line.split(":")[-1]) elif line.startswith("reference hue"): - line = line.replace("reference hue ", "") + line = line.replace("reference hue ", "") # noqa: PLW2901 attribute, value = line.split("\t", 1) hue, data = int(attribute), _parse_float_values(value) @@ -166,14 +166,14 @@ def _parse_float_values(data: str) -> NDArray: return self._content -_DATASET_LOADER_EBNER1998: Optional[DatasetLoader_Ebner1998] = None +_DATASET_LOADER_EBNER1998: DatasetLoader_Ebner1998 | None = None """ Singleton instance of the *Ebner and Fairchild (1998)* *Constant Perceived-Hue Data* dataset loader. """ -def build_Ebner1998(load: Boolean = True) -> DatasetLoader_Ebner1998: +def build_Ebner1998(load: bool = True) -> DatasetLoader_Ebner1998: """ Singleton factory that builds the *Ebner and Fairchild (1998)* *Constant Perceived-Hue Data* dataset loader. @@ -194,7 +194,7 @@ def build_Ebner1998(load: Boolean = True) -> DatasetLoader_Ebner1998: :cite:`Ebner1998` """ - global _DATASET_LOADER_EBNER1998 + global _DATASET_LOADER_EBNER1998 # noqa: PLW0603 if _DATASET_LOADER_EBNER1998 is None: _DATASET_LOADER_EBNER1998 = DatasetLoader_Ebner1998() diff --git a/colour_datasets/loaders/hung1995.py b/colour_datasets/loaders/hung1995.py index 7c512de..210367a 100644 --- a/colour_datasets/loaders/hung1995.py +++ b/colour_datasets/loaders/hung1995.py @@ -23,14 +23,14 @@ from collections import namedtuple from colour import CCS_ILLUMINANTS, xy_to_XYZ, xyY_to_XYZ -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour_datasets.loaders import AbstractDatasetLoader from colour_datasets.records import datasets __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -120,29 +120,18 @@ def load( super().sync() - self._content = dict() - - filenames = dict( - [ - ("Table I.csv", "Reference colors."), - ( - "Table II.csv", - "Intra- and interobserver variances for each " - "reference hue expressed in circumferential " - "hue-angle difference.", - ), - ( - "Table III.csv", - "Weight-averaged constant hue loci for the CL " - "experiment.", - ), - ( - "Table IV.csv", - "Weight-averaged constant hue loci for the VL " - "experiment.", - ), - ] - ) + self._content = {} + + filenames = { + "Table I.csv": "Reference colors.", + "Table II.csv": "Intra- and interobserver variances for each " + "reference hue expressed in circumferential " + "hue-angle difference.", + "Table III.csv": "Weight-averaged constant hue loci for the CL " + "experiment.", + "Table IV.csv": "Weight-averaged constant hue loci for the VL " + "experiment.", + } for filename in filenames: datafile_path = os.path.join( @@ -178,10 +167,10 @@ def load( for table, experiment in [("Table III", "CL"), ("Table IV", "VL")]: key = f"Constant Hue Loci Data - {experiment}" - self._content[key] = dict() + self._content[key] = {} for hue in hues: for sample_r in self._content["Table I"]: - sample_r = sample_r.tolist() + sample_r = sample_r.tolist() # noqa: PLW2901 if sample_r[0] == hue: XYZ_cr = xyY_to_XYZ(sample_r[1:4]) / 100 break @@ -192,8 +181,8 @@ def load( "C*uv": [], } for sample_t in self._content[table]: - sample_t = sample_t.tolist() - if not sample_t[0] == hue: + sample_t = sample_t.tolist() # noqa: PLW2901 + if sample_t[0] != hue: continue XYZ_ct.append(sample_t[2:]) @@ -209,14 +198,14 @@ def load( return self._content -_DATASET_LOADER_HUNG1995: Optional[DatasetLoader_Hung1995] = None +_DATASET_LOADER_HUNG1995: DatasetLoader_Hung1995 | None = None """ Singleton instance of the *Hung and Berns (1995)* *Constant Hue Loci Data* dataset loader. """ -def build_Hung1995(load: Boolean = True) -> DatasetLoader_Hung1995: +def build_Hung1995(load: bool = True) -> DatasetLoader_Hung1995: """ Singleton factory that builds the *Hung and Berns (1995)* *Constant Hue Loci Data* dataset loader. @@ -237,7 +226,7 @@ def build_Hung1995(load: Boolean = True) -> DatasetLoader_Hung1995: :cite:`Hung1995` """ - global _DATASET_LOADER_HUNG1995 + global _DATASET_LOADER_HUNG1995 # noqa: PLW0603 if _DATASET_LOADER_HUNG1995 is None: _DATASET_LOADER_HUNG1995 = DatasetLoader_Hung1995() diff --git a/colour_datasets/loaders/jakob2019.py b/colour_datasets/loaders/jakob2019.py index f0bad7e..ead0169 100644 --- a/colour_datasets/loaders/jakob2019.py +++ b/colour_datasets/loaders/jakob2019.py @@ -10,7 +10,7 @@ References ---------- -- :cite:`Jakob2019` : Jakob, W., & Hanika, J. (2019). A Low‐Dimensional +- :cite:`Jakob2019` : Jakob, W., & Hanika, J. (2019). A Low-Dimensional Function Space for Efficient Spectral Upsampling. Computer Graphics Forum, 38(2), 147-155. doi:10.1111/cgf.13626 """ @@ -20,7 +20,7 @@ import glob import os -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour.recovery import LUT3D_Jakob2019 from colour_datasets.loaders import AbstractDatasetLoader @@ -28,7 +28,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -88,7 +88,7 @@ def load(self) -> Dict[str, LUT3D_Jakob2019]: super().sync() - self._content = dict() + self._content = {} tables_path = os.path.join( self.record.repository, @@ -117,14 +117,14 @@ def load(self) -> Dict[str, LUT3D_Jakob2019]: return self._content -_DATASET_LOADER_JAKOB2019: Optional[DatasetLoader_Jakob2019] = None +_DATASET_LOADER_JAKOB2019: DatasetLoader_Jakob2019 | None = None """ Singleton instance of the *Jakob and Hanika (2019)* *Spectral Upsampling Coefficient Tables* dataset loader. """ -def build_Jakob2019(load: Boolean = True) -> DatasetLoader_Jakob2019: +def build_Jakob2019(load: bool = True) -> DatasetLoader_Jakob2019: """ Singleton factory that builds the *Jakob and Hanika (2019)* *Spectral Upsampling Coefficient Tables* dataset loader. @@ -145,7 +145,7 @@ def build_Jakob2019(load: Boolean = True) -> DatasetLoader_Jakob2019: :cite:`Jakob2019` """ - global _DATASET_LOADER_JAKOB2019 + global _DATASET_LOADER_JAKOB2019 # noqa: PLW0603 if _DATASET_LOADER_JAKOB2019 is None: _DATASET_LOADER_JAKOB2019 = DatasetLoader_Jakob2019() diff --git a/colour_datasets/loaders/jiang2013.py b/colour_datasets/loaders/jiang2013.py index bff0fd2..ee90134 100644 --- a/colour_datasets/loaders/jiang2013.py +++ b/colour_datasets/loaders/jiang2013.py @@ -25,7 +25,7 @@ from colour import SpectralShape from colour.characterisation import RGB_CameraSensitivities -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour.utilities import as_float_array from colour_datasets.loaders import AbstractDatasetLoader @@ -33,7 +33,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -95,7 +95,7 @@ def load(self) -> Dict[str, RGB_CameraSensitivities]: shape = SpectralShape(400, 720, 10) - self._content = dict() + self._content = {} database_path = os.path.join( self.record.repository, "dataset", "camspec_database.txt" ) @@ -124,14 +124,14 @@ def load(self) -> Dict[str, RGB_CameraSensitivities]: return self._content -_DATASET_LOADER_JIANG2013: Optional[DatasetLoader_Jiang2013] = None +_DATASET_LOADER_JIANG2013: DatasetLoader_Jiang2013 | None = None """ Singleton instance of the *Jiang et al. (2013)* *Camera Spectral Sensitivity Database* dataset loader. """ -def build_Jiang2013(load: Boolean = True) -> DatasetLoader_Jiang2013: +def build_Jiang2013(load: bool = True) -> DatasetLoader_Jiang2013: """ Singleton factory that builds the *Jiang et al. (2013)* *Camera Spectral Sensitivity Database* dataset loader. @@ -152,7 +152,7 @@ def build_Jiang2013(load: Boolean = True) -> DatasetLoader_Jiang2013: :cite:`Jiang2013` """ - global _DATASET_LOADER_JIANG2013 + global _DATASET_LOADER_JIANG2013 # noqa: PLW0603 if _DATASET_LOADER_JIANG2013 is None: _DATASET_LOADER_JIANG2013 = DatasetLoader_Jiang2013() diff --git a/colour_datasets/loaders/karge2015.py b/colour_datasets/loaders/karge2015.py index 8832dee..5b7cca1 100644 --- a/colour_datasets/loaders/karge2015.py +++ b/colour_datasets/loaders/karge2015.py @@ -23,7 +23,7 @@ from collections import defaultdict from colour.algebra import LinearInterpolator -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour.io import read_sds_from_csv_file from colour_datasets.loaders import AbstractDatasetLoader @@ -31,7 +31,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -107,9 +107,9 @@ def load(self) -> Dict[str, Dict[str, Dict]]: .replace("_", " ") ) category = "Normalised" if "normalized" in path else "Raw" - path = os.path.join(database_root, path) + path = os.path.join(database_root, path) # noqa: PLW2901 - sds = dict() + sds = {} for name, sd in read_sds_from_csv_file( path, transpose=True, delimiter=";" ).items(): @@ -124,14 +124,14 @@ def load(self) -> Dict[str, Dict[str, Dict]]: return dict(self._content) -_DATASET_LOADER_KARGE2015: Optional[DatasetLoader_Karge2015] = None +_DATASET_LOADER_KARGE2015: DatasetLoader_Karge2015 | None = None """ Singleton instance of the *Karge et al. (2015)* *Spectral Database of Commonly Used Cine Lighting* dataset loader. """ -def build_Karge2015(load: Boolean = True) -> DatasetLoader_Karge2015: +def build_Karge2015(load: bool = True) -> DatasetLoader_Karge2015: """ Singleton factory that builds the *Karge et al. (2015)* *Spectral Database of Commonly Used Cine Lighting* dataset loader. @@ -152,7 +152,7 @@ def build_Karge2015(load: Boolean = True) -> DatasetLoader_Karge2015: :cite:`Karge2015` """ - global _DATASET_LOADER_KARGE2015 + global _DATASET_LOADER_KARGE2015 # noqa: PLW0603 if _DATASET_LOADER_KARGE2015 is None: _DATASET_LOADER_KARGE2015 = DatasetLoader_Karge2015() diff --git a/colour_datasets/loaders/kuopio.py b/colour_datasets/loaders/kuopio.py index 42d7010..12f4431 100644 --- a/colour_datasets/loaders/kuopio.py +++ b/colour_datasets/loaders/kuopio.py @@ -35,6 +35,7 @@ from __future__ import annotations +import contextlib import functools import numpy as np import os @@ -42,16 +43,17 @@ import scipy.io import sys from collections import namedtuple +from typing import ClassVar from colour import SpectralDistribution, SpectralShape -from colour.hints import Any, Boolean, Dict, Tuple, Type, cast +from colour.hints import Any, Dict, Tuple, Type, cast from colour_datasets.loaders import AbstractDatasetLoader from colour_datasets.records import datasets __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -112,7 +114,7 @@ def read_sds_from_mat_file_KuopioUniversity( matlab_data = scipy.io.loadmat(mat_file) - sds = dict() + sds = {} table = matlab_data[metadata.key] wavelengths = metadata.shape.range() @@ -154,7 +156,7 @@ class DatasetLoader_KuopioUniversity(AbstractDatasetLoader): ID: str = "Undefined" """Dataset record id, i.e. the *Zenodo* record number.""" - METADATA: Dict = {} + METADATA: ClassVar[Dict] = {} """ Mapping of paths and :class:`colour_datasets.loaders.kuopio.MatFileMetadata_KuopioUniversity` @@ -177,7 +179,7 @@ def load(self) -> Dict[str, Dict[str, SpectralDistribution]]: super().sync() - self._content = dict() + self._content = {} for path, metadata in self.METADATA.items(): mat_path = os.path.join(self.record.repository, "dataset", *path) @@ -263,10 +265,8 @@ class instances. ) dataset_loader_class.__doc__ = class_docstring - try: + with contextlib.suppress(AttributeError): dataset_loader_class.load.__doc__ = load_method_docstring - except AttributeError: - pass setattr(module, class_attribute, dataset_loader_class) @@ -275,7 +275,7 @@ class instances. def build_KuopioUniversity( dataset_loader_class: Type[DatasetLoader_KuopioUniversity], - load: Boolean = True, + load: bool = True, ) -> DatasetLoader_KuopioUniversity: """ Singleton factory that builds a *University of Kuopio* dataset loader. @@ -516,7 +516,7 @@ def build_KuopioUniversity( DATASET_LOADERS_KUOPIO_UNIVERSITY[_id] = _partial_function - __all__ += [ + __all__ += [ # noqa: PLE0604 _dataset_loader_class.__name__, _build_function_name, ] diff --git a/colour_datasets/loaders/labsphere2019.py b/colour_datasets/loaders/labsphere2019.py index 541006a..3cf6396 100644 --- a/colour_datasets/loaders/labsphere2019.py +++ b/colour_datasets/loaders/labsphere2019.py @@ -18,7 +18,7 @@ import os from colour import SpectralDistribution -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict, Optional from colour.utilities import tsplit from colour_datasets.loaders import AbstractDatasetLoader @@ -26,7 +26,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -89,16 +89,11 @@ def load(self) -> Dict[str, SpectralDistribution]: ) values = tsplit(np.loadtxt(sd_path, delimiter="\t", skiprows=2)) - self._content = dict( - [ - ( - "Labsphere SRS-99-020", - SpectralDistribution( - values[1], values[0], name="Labsphere SRS-99-020" - ), - ), - ] - ) + self._content = { + "Labsphere SRS-99-020": SpectralDistribution( + values[1], values[0], name="Labsphere SRS-99-020" + ), + } return self._content @@ -110,7 +105,7 @@ def load(self) -> Dict[str, SpectralDistribution]: """ -def build_Labsphere2019(load: Boolean = True) -> DatasetLoader_Labsphere2019: +def build_Labsphere2019(load: bool = True) -> DatasetLoader_Labsphere2019: """ Singleton factory that builds the *Labsphere (2019)* *Labsphere SRS-99-020* dataset loader. @@ -131,7 +126,7 @@ def build_Labsphere2019(load: Boolean = True) -> DatasetLoader_Labsphere2019: :cite:`Labsphere2019` """ - global _DATASET_LOADER_LABSPHERE2019 + global _DATASET_LOADER_LABSPHERE2019 # noqa: PLW0603 if _DATASET_LOADER_LABSPHERE2019 is None: _DATASET_LOADER_LABSPHERE2019 = DatasetLoader_Labsphere2019() diff --git a/colour_datasets/loaders/luo1997.py b/colour_datasets/loaders/luo1997.py index 7b27d3d..39c2f00 100644 --- a/colour_datasets/loaders/luo1997.py +++ b/colour_datasets/loaders/luo1997.py @@ -13,16 +13,16 @@ - :cite:`Luo1991` : Luo, M. R., Clarke, A. A., Rhodes, P. A., Schappo, A., Scrivener, S. A. R., & Tait, C. J. (1991b). Quantifying colour appearance. Part I. Lutchi colour appearance data. Color Research & Application, 16(3), - 166–180. doi:10.1002/col.5080160307 + 166-180. doi:10.1002/col.5080160307 - :cite:`Luo1991a` : Luo, M. R., Clarke, A. A., Rhodes, P. A., Schappo, A., Scrivener, S. A. R., & Tait, C. J. (1991a). Quantifying colour appearance. Part II. Testing colour models performance using lutchi colour appearance - data. Color Research & Application, 16(3), 181–197. + data. Color Research & Application, 16(3), 181-197. doi:10.1002/col.5080160308 - :cite:`Luo1993` : Luo, M. R., Gao, X. W., Rhodes, P. A., Xin, H. J., Clarke, A. A., & Scrivener, S. A. R. (1993). Quantifying colour appearance. part III. Supplementary LUTCHI colour appearance data. Color Research & - Application, 18(2), 98–113. doi:10.1002/col.5080180207 + Application, 18(2), 98-113. doi:10.1002/col.5080180207 - :cite:`Luo1997` : Luo, M. R., & Rhodes, P. A. (1997). Using the LUTCHI Colour Appearance Data. Retrieved September 10, 2019, from https://web.archive.org/web/20040212195937/\ @@ -35,7 +35,7 @@ import os from collections import namedtuple -from colour.hints import Boolean, Dict, Optional, Tuple +from colour.hints import Dict, Tuple from colour.utilities import as_float_array, usage_warning from colour_datasets.loaders import AbstractDatasetLoader @@ -43,7 +43,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright (C) 2019 - Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-science@googlegroups.com" __status__ = "Production" @@ -209,835 +209,783 @@ def load(self) -> Dict[str, ExperimentalGroupLuo1997]: "Neutrals", ) - experimental_groups_summary: Dict[str, Tuple] = dict( - [ + experimental_groups_summary: Dict[str, Tuple] = { + "R-HL": ( + 6, + "Reflective media with luminances ranging 364-232 cd/m2", + 1, + ), + "R-LL": ( + 6, + "Reflective media with luminances ranging 44-41 cd/m2", + 1, + ), + "R-VL": ( + 12, + "Reflective media with luminances ranging 843-0.4 cd/m2", + 2, + ), + "R-textile": ( + 3, + "Large textile samples with luminances ranging 730-340 cd/m2", + 4, + ), + "CRT": ( + 11, + "Monitor colours with luminances ranging 45-20 cd/m2", + 1, + ), + "35mm": ( + 6, + "35mm transparency with luminances ranging 113-45 cd/m2", + 3, + ), + "LT": ( + 10, ( - "R-HL", - ( - 6, - "Reflective media with luminances ranging 364-232 cd/m2", - 1, - ), + "Cut-sheet transparency with luminances ranging " + "2100-320 cd/m2" ), + 3, + ), + "BIT": ( + 5, + "Isolated viewing field with luminances ranging 90-3.6 cd/m2", + 5, + ), + } + + experimental_groups: Dict[str, Tuple] = { + "R-HL": ( ( - "R-LL", - ( - 6, - "Reflective media with luminances ranging 44-41 cd/m2", - 1, - ), + 1, + "nlmean.wh", + "cold50wnl", + 105, + 41, + 46, + 0.88, + 100, + 264, + np.array([97.13, 100, 76.62]), ), ( - "R-VL", - ( - 12, - "Reflective media with luminances ranging 843-0.4 cd/m2", - 2, - ), + 2, + "nlmean.bh", + "cold50gb", + 105, + 41, + 46, + 0.84, + 6.2, + 252, + np.array([97.09, 100, 83.1]), ), ( - "R-textile", - ( - 3, - "Large textile samples with luminances ranging 730-340 cd/m2", - 4, - ), + 3, + "nlmean.gh", + "cold50gb", + 105, + 41, + 46, + 0.84, + 21.5, + 252, + np.array([97.09, 100, 83.1]), ), ( - "CRT", - ( - 11, - "Monitor colours with luminances ranging 45-20 cd/m2", - 1, - ), + 4, + "nld65.gh", + "cold65", + 105, + 41, + 46, + 0.81, + 21.5, + 243, + np.array([94.52, 100, 114.98]), ), ( - "35mm", - ( - 6, - "35mm transparency with luminances ranging 113-45 cd/m2", - 3, - ), + 5, + "nlwf.gh", + "colwf", + 105, + 41, + 46, + 0.84, + 21.5, + 252, + np.array([102.5, 100, 47.93]), ), ( - "LT", - ( - 10, - ( - "Cut-sheet transparency with luminances ranging " - "2100-320 cd/m2" - ), - 3, - ), + 6, + "nla.gh", + "colah", + 105, + 41, + 46, + 0.84, + 21.5, + 232, + np.array([112.92, 100, 28.62]), ), + ), + "R-LL": ( ( - "BIT", - ( - 5, - "Isolated viewing field with luminances ranging 90-3.6 cd/m2", - 5, - ), + 1, + "nlmean.wl", + "cold50wnl", + 105, + 41, + 46, + 0.88, + 100, + 44, + np.array([97.13, 100, 76.62]), ), - ] - ) - - experimental_groups: Dict[str, Tuple] = dict( - [ ( - "R-HL", - ( - ( - 1, - "nlmean.wh", - "cold50wnl", - 105, - 41, - 46, - 0.88, - 100, - 264, - np.array([97.13, 100, 76.62]), - ), - ( - 2, - "nlmean.bh", - "cold50gb", - 105, - 41, - 46, - 0.84, - 6.2, - 252, - np.array([97.09, 100, 83.1]), - ), - ( - 3, - "nlmean.gh", - "cold50gb", - 105, - 41, - 46, - 0.84, - 21.5, - 252, - np.array([97.09, 100, 83.1]), - ), - ( - 4, - "nld65.gh", - "cold65", - 105, - 41, - 46, - 0.81, - 21.5, - 243, - np.array([94.52, 100, 114.98]), - ), - ( - 5, - "nlwf.gh", - "colwf", - 105, - 41, - 46, - 0.84, - 21.5, - 252, - np.array([102.5, 100, 47.93]), - ), - ( - 6, - "nla.gh", - "colah", - 105, - 41, - 46, - 0.84, - 21.5, - 232, - np.array([112.92, 100, 28.62]), - ), - ), + 2, + "nlmean.bl", + "cold50gb", + 105, + 41, + 46, + 0.84, + 6.2, + 42, + np.array([97.09, 100, 83.1]), ), ( - "R-LL", - ( - ( - 1, - "nlmean.wl", - "cold50wnl", - 105, - 41, - 46, - 0.88, - 100, - 44, - np.array([97.13, 100, 76.62]), - ), - ( - 2, - "nlmean.bl", - "cold50gb", - 105, - 41, - 46, - 0.84, - 6.2, - 42, - np.array([97.09, 100, 83.1]), - ), - ( - 3, - "nlmean.gl", - "cold50gb", - 105, - 41, - 46, - 0.84, - 21.5, - 42, - np.array([97.09, 100, 83.1]), - ), - ( - 4, - "nld65.gl", - "cold65", - 105, - 41, - 46, - 0.81, - 21.5, - 40.5, - np.array([94.52, 100, 114.98]), - ), - ( - 5, - "nlwf.gl", - "colwf", - 105, - 41, - 46, - 0.84, - 21.5, - 42, - np.array([102.5, 100, 47.93]), - ), - ( - 6, - "nla.gl", - "colal", - 105, - 41, - 46, - 0.84, - 21.4, - 42, - np.array([117.26, 100, 22.44]), - ), - ), + 3, + "nlmean.gl", + "cold50gb", + 105, + 41, + 46, + 0.84, + 21.5, + 42, + np.array([97.09, 100, 83.1]), ), ( - "R-VL", - ( - ( - 1, - "mean4.p1", - "col.rf.p1", - 40, - 37, - 40, - 1, - 21.5, - 843, - np.array([94.04, 100, 76.29]), - ), - ( - 2, - "mean4.p2", - "col.rf.p2", - 40, - 37, - 40, - 1, - 21.5, - 200, - np.array([93.04, 100, 72.24]), - ), - ( - 3, - "mean4.p3", - "col.rf.p3", - 40, - 37, - 40, - 1, - 21.5, - 62, - np.array([93.94, 100, 73.51]), - ), - ( - 4, - "mean4.p4", - "col.rf.p4", - 40, - 37, - 40, - 1, - 21.5, - 17, - np.array([93.44, 100, 72.49]), - ), - ( - 5, - "mean4.p5", - "col.rf.p5", - 40, - 37, - 40, - 1, - 21.5, - 6, - np.array([92.22, 100, 70.12]), - ), - ( - 6, - "mean4.p6", - "col.rf.p6", - 40, - 37, - 40, - 1, - 21.5, - 0.4, - np.array([90.56, 100, 58.59]), - ), - ( - 7, - "mean4.p7", - "col.rf.p1", - 40, - 37, - 40, - 1, - 21.5, - 843, - np.array([94.04, 100, 76.29]), - ), - ( - 8, - "mean4.p8", - "col.rf.p2", - 40, - 37, - 40, - 1, - 21.5, - 200, - np.array([93.04, 100, 72.24]), - ), - ( - 9, - "mean4.p9", - "col.rf.p3", - 40, - 37, - 40, - 1, - 21.5, - 62, - np.array([93.94, 100, 73.51]), - ), - ( - 10, - "mean4.p10", - "col.rf.p4", - 40, - 37, - 40, - 1, - 21.5, - 17, - np.array([93.44, 100, 72.49]), - ), - ( - 11, - "mean4.p11", - "col.rf.p5", - 40, - 37, - 40, - 1, - 21.5, - 6, - np.array([92.22, 100, 70.12]), - ), - ( - 12, - "mean4.p12", - "col.rf.p6", - 40, - 37, - 40, - 1, - 21.5, - 0.4, - np.array([90.56, 100, 58.59]), - ), - ), + 4, + "nld65.gl", + "cold65", + 105, + 41, + 46, + 0.81, + 21.5, + 40.5, + np.array([94.52, 100, 114.98]), ), ( - "R-textile", - ( - ( - 1, - "kuo.d65.vis", - "kuo.d65.col", - 240, - 1, - 12, - 0.74, - 16, - 250, - np.array([96.46, 100, 108.62]), - ), - ( - 2, - "kuo.tl84.vis", - "kuo.tl84.col", - 239, - 1, - 10, - 0.74, - 16, - 540, - np.array([103.07, 100, 64.29]), - ), - ( - 3, - "kuo.a.vis", - "kuo.a.col", - 239, - 1, - 11, - 0.74, - 16, - 250, - np.array([115.19, 100, 23.75]), - ), - ), + 5, + "nlwf.gl", + "colwf", + 105, + 41, + 46, + 0.84, + 21.5, + 42, + np.array([102.5, 100, 47.93]), ), ( - "CRT", - ( - ( - 1, - "lmean.ww", - "cold50wl", - 94, - 39, - 44, - 0.89, - 100, - 40, - np.array([97.13, 100, 76.62]), - ), - ( - 2, - "lmean.bb", - "cold50gbl", - 100, - 39, - 44, - 0.89, - 5, - 44.5, - np.array([97.13, 100, 76.62]), - ), - ( - 3, - "lmean.gg", - "cold50gbl", - 100, - 39, - 44, - 0.89, - 20, - 44.5, - np.array([97.13, 100, 76.62]), - ), - ( - 4, - "lmean.gw", - "cold50gbl", - 100, - 39, - 44, - 0.89, - 20, - 44.5, - np.array([97.13, 100, 76.62]), - ), - ( - 5, - "lmean.gb", - "cold50gbl", - 100, - 39, - 44, - 0.89, - 20, - 44.5, - np.array([97.13, 100, 76.62]), - ), - ( - 6, - "ld65.gg", - "cold65.l", - 103, - 39, - 44, - 0.81, - 21.5, - 40.5, - np.array([94.52, 100, 114.98]), - ), - ( - 7, - "ld65.gw", - "cold65.l", - 103, - 39, - 44, - 0.81, - 21.5, - 40.5, - np.array([94.52, 100, 114.98]), - ), - ( - 8, - "lwf.gg", - "colwf.l", - 103, - 39, - 44, - 0.84, - 21.5, - 28.4, - np.array([102.5, 100, 47.93]), - ), - ( - 9, - "lwf.gw", - "colwf.l", - 103, - 39, - 44, - 0.84, - 21.5, - 28.4, - np.array([102.5, 100, 47.93]), - ), - ( - 10, - "la.gg", - "colal.l", - 61, - 29, - 34, - 0.84, - 21.5, - 20.3, - np.array([117.26, 100, 22.44]), - ), - ( - 11, - "la.gw", - "colal.l", - 61, - 29, - 34, - 0.84, - 21.5, - 20.3, - np.array([117.26, 100, 22.44]), - ), - ), + 6, + "nla.gl", + "colal", + 105, + 41, + 46, + 0.84, + 21.4, + 42, + np.array([117.26, 100, 22.44]), ), + ), + "R-VL": ( ( - "35mm", - ( - ( - 1, - "mean.35.p1", - "col.35.p1", - 99, - 93, - 99, - 1, - 15.6, - 75, - np.array([92.9, 100, 46.1]), - ), - ( - 2, - "mean.35.p2", - "col.35.p2", - 99, - 93, - 98, - 1, - 14.7, - 75, - np.array([86.71, 100, 75.49]), - ), - ( - 3, - "mean.35.p3", - "col.35.p3", - 99, - 93, - 99, - 1, - 18.9, - 113, - np.array([92.57, 100, 45.47]), - ), - ( - 4, - "mean.35.p4", - "col.35.p1", - 99, - 93, - 99, - 1, - 18.9, - 45, - np.array([92.9, 100, 46.1]), - ), - ( - 5, - "mean.35.p5", - "col.35.p5", - 95, - 89, - 95, - 1, - 19.2, - 47, - np.array([93.8, 100, 52.39]), - ), - ( - 6, - "mean.35.p6", - "col.35.p6", - 36, - 26, - 30, - 1, - 18.9, - 113, - np.array([95.32, 100, 53.37]), - ), - ), + 1, + "mean4.p1", + "col.rf.p1", + 40, + 37, + 40, + 1, + 21.5, + 843, + np.array([94.04, 100, 76.29]), ), ( - "LT", - ( - ( - 1, - "mean.p1", - "col.p1", - 98, - 94, - 98, - 1, - 15.9, - 2259, - np.array([93.09, 100, 62.02]), - ), - ( - 2, - "mean.p2", - "col.p2", - 98, - 94, - 98, - 1, - 17.1, - 689, - np.array([93.23, 100, 61.15]), - ), - ( - 3, - "mean.p3", - "col.p3", - 98, - 94, - 98, - 1, - 16.9, - 325, - np.array([92.36, 100, 59.91]), - ), - ( - 4, - "mean.p4", - "col.p4", - 98, - 94, - 98, - 1, - 17.4, - 670, - np.array([93.05, 100, 58.58]), - ), - ( - 5, - "mean.p5t", - "col.p5t", - 97, - 93, - 97, - 1, - 9.6, - 1954, - np.array([93.3, 100, 59.54]), - ), - ( - 6, - "mean.p6t", - "col.p6t", - 94, - 90, - 94, - 1, - 9.5, - 619, - np.array([93.2, 100, 60.48]), - ), - ( - 7, - "mean.p7t", - "col.p7t", - 93, - 89, - 93, - 1, - 9.8, - 319, - np.array([92.43, 100, 59.21]), - ), - ( - 8, - "mean.p8", - "col.p8", - 98, - 94, - 98, - 1, - 9.4, - 642, - np.array([93.34, 100, 57.98]), - ), - ( - 9, - "mean.p10", - "col.p10", - 98, - 94, - 98, - 1, - 9.6, - 658, - np.array([93.34, 100, 57.98]), - ), - ( - 10, - "mean.p1t", - "col.p1t", - 94, - 90, - 94, - 1, - 17.5, - 680, - np.array([93.34, 100, 57.98]), - ), - ), + 2, + "mean4.p2", + "col.rf.p2", + 40, + 37, + 40, + 1, + 21.5, + 200, + np.array([93.04, 100, 72.24]), ), ( - "BIT", - ( - ( - 1, - "bit_p1.vis", - "bit_p1.col", - 120, - 1, - 16, - 1, - 0.6, - 90, - np.array([100.6, 100, 113.2]), - ), - ( - 2, - "bit_p2.vis", - "bit_p2.col", - 120, - 1, - 18, - 1, - 0.6, - 3.6, - np.array([100.6, 100, 113.2]), - ), - ( - 3, - "bit_p3.vis", - "bit_p3.col", - 120, - 1, - 15, - 1, - 0.6, - 90, - np.array([100.6, 100, 113.2]), - ), - ( - 4, - "bit_p4.vis", - "bit_p4.col", - 90, - 1, - 18, - 1, - 0.6, - 90, - np.array([100.6, 100, 113.2]), - ), - ( - 5, - "bit_p5.vis", - "bit_p5.col", - 90, - 1, - 12, - 1, - 0.6, - 3.6, - np.array([100.6, 100, 113.2]), - ), - ), + 3, + "mean4.p3", + "col.rf.p3", + 40, + 37, + 40, + 1, + 21.5, + 62, + np.array([93.94, 100, 73.51]), ), - ] - ) + ( + 4, + "mean4.p4", + "col.rf.p4", + 40, + 37, + 40, + 1, + 21.5, + 17, + np.array([93.44, 100, 72.49]), + ), + ( + 5, + "mean4.p5", + "col.rf.p5", + 40, + 37, + 40, + 1, + 21.5, + 6, + np.array([92.22, 100, 70.12]), + ), + ( + 6, + "mean4.p6", + "col.rf.p6", + 40, + 37, + 40, + 1, + 21.5, + 0.4, + np.array([90.56, 100, 58.59]), + ), + ( + 7, + "mean4.p7", + "col.rf.p1", + 40, + 37, + 40, + 1, + 21.5, + 843, + np.array([94.04, 100, 76.29]), + ), + ( + 8, + "mean4.p8", + "col.rf.p2", + 40, + 37, + 40, + 1, + 21.5, + 200, + np.array([93.04, 100, 72.24]), + ), + ( + 9, + "mean4.p9", + "col.rf.p3", + 40, + 37, + 40, + 1, + 21.5, + 62, + np.array([93.94, 100, 73.51]), + ), + ( + 10, + "mean4.p10", + "col.rf.p4", + 40, + 37, + 40, + 1, + 21.5, + 17, + np.array([93.44, 100, 72.49]), + ), + ( + 11, + "mean4.p11", + "col.rf.p5", + 40, + 37, + 40, + 1, + 21.5, + 6, + np.array([92.22, 100, 70.12]), + ), + ( + 12, + "mean4.p12", + "col.rf.p6", + 40, + 37, + 40, + 1, + 21.5, + 0.4, + np.array([90.56, 100, 58.59]), + ), + ), + "R-textile": ( + ( + 1, + "kuo.d65.vis", + "kuo.d65.col", + 240, + 1, + 12, + 0.74, + 16, + 250, + np.array([96.46, 100, 108.62]), + ), + ( + 2, + "kuo.tl84.vis", + "kuo.tl84.col", + 239, + 1, + 10, + 0.74, + 16, + 540, + np.array([103.07, 100, 64.29]), + ), + ( + 3, + "kuo.a.vis", + "kuo.a.col", + 239, + 1, + 11, + 0.74, + 16, + 250, + np.array([115.19, 100, 23.75]), + ), + ), + "CRT": ( + ( + 1, + "lmean.ww", + "cold50wl", + 94, + 39, + 44, + 0.89, + 100, + 40, + np.array([97.13, 100, 76.62]), + ), + ( + 2, + "lmean.bb", + "cold50gbl", + 100, + 39, + 44, + 0.89, + 5, + 44.5, + np.array([97.13, 100, 76.62]), + ), + ( + 3, + "lmean.gg", + "cold50gbl", + 100, + 39, + 44, + 0.89, + 20, + 44.5, + np.array([97.13, 100, 76.62]), + ), + ( + 4, + "lmean.gw", + "cold50gbl", + 100, + 39, + 44, + 0.89, + 20, + 44.5, + np.array([97.13, 100, 76.62]), + ), + ( + 5, + "lmean.gb", + "cold50gbl", + 100, + 39, + 44, + 0.89, + 20, + 44.5, + np.array([97.13, 100, 76.62]), + ), + ( + 6, + "ld65.gg", + "cold65.l", + 103, + 39, + 44, + 0.81, + 21.5, + 40.5, + np.array([94.52, 100, 114.98]), + ), + ( + 7, + "ld65.gw", + "cold65.l", + 103, + 39, + 44, + 0.81, + 21.5, + 40.5, + np.array([94.52, 100, 114.98]), + ), + ( + 8, + "lwf.gg", + "colwf.l", + 103, + 39, + 44, + 0.84, + 21.5, + 28.4, + np.array([102.5, 100, 47.93]), + ), + ( + 9, + "lwf.gw", + "colwf.l", + 103, + 39, + 44, + 0.84, + 21.5, + 28.4, + np.array([102.5, 100, 47.93]), + ), + ( + 10, + "la.gg", + "colal.l", + 61, + 29, + 34, + 0.84, + 21.5, + 20.3, + np.array([117.26, 100, 22.44]), + ), + ( + 11, + "la.gw", + "colal.l", + 61, + 29, + 34, + 0.84, + 21.5, + 20.3, + np.array([117.26, 100, 22.44]), + ), + ), + "35mm": ( + ( + 1, + "mean.35.p1", + "col.35.p1", + 99, + 93, + 99, + 1, + 15.6, + 75, + np.array([92.9, 100, 46.1]), + ), + ( + 2, + "mean.35.p2", + "col.35.p2", + 99, + 93, + 98, + 1, + 14.7, + 75, + np.array([86.71, 100, 75.49]), + ), + ( + 3, + "mean.35.p3", + "col.35.p3", + 99, + 93, + 99, + 1, + 18.9, + 113, + np.array([92.57, 100, 45.47]), + ), + ( + 4, + "mean.35.p4", + "col.35.p1", + 99, + 93, + 99, + 1, + 18.9, + 45, + np.array([92.9, 100, 46.1]), + ), + ( + 5, + "mean.35.p5", + "col.35.p5", + 95, + 89, + 95, + 1, + 19.2, + 47, + np.array([93.8, 100, 52.39]), + ), + ( + 6, + "mean.35.p6", + "col.35.p6", + 36, + 26, + 30, + 1, + 18.9, + 113, + np.array([95.32, 100, 53.37]), + ), + ), + "LT": ( + ( + 1, + "mean.p1", + "col.p1", + 98, + 94, + 98, + 1, + 15.9, + 2259, + np.array([93.09, 100, 62.02]), + ), + ( + 2, + "mean.p2", + "col.p2", + 98, + 94, + 98, + 1, + 17.1, + 689, + np.array([93.23, 100, 61.15]), + ), + ( + 3, + "mean.p3", + "col.p3", + 98, + 94, + 98, + 1, + 16.9, + 325, + np.array([92.36, 100, 59.91]), + ), + ( + 4, + "mean.p4", + "col.p4", + 98, + 94, + 98, + 1, + 17.4, + 670, + np.array([93.05, 100, 58.58]), + ), + ( + 5, + "mean.p5t", + "col.p5t", + 97, + 93, + 97, + 1, + 9.6, + 1954, + np.array([93.3, 100, 59.54]), + ), + ( + 6, + "mean.p6t", + "col.p6t", + 94, + 90, + 94, + 1, + 9.5, + 619, + np.array([93.2, 100, 60.48]), + ), + ( + 7, + "mean.p7t", + "col.p7t", + 93, + 89, + 93, + 1, + 9.8, + 319, + np.array([92.43, 100, 59.21]), + ), + ( + 8, + "mean.p8", + "col.p8", + 98, + 94, + 98, + 1, + 9.4, + 642, + np.array([93.34, 100, 57.98]), + ), + ( + 9, + "mean.p10", + "col.p10", + 98, + 94, + 98, + 1, + 9.6, + 658, + np.array([93.34, 100, 57.98]), + ), + ( + 10, + "mean.p1t", + "col.p1t", + 94, + 90, + 94, + 1, + 17.5, + 680, + np.array([93.34, 100, 57.98]), + ), + ), + "BIT": ( + ( + 1, + "bit_p1.vis", + "bit_p1.col", + 120, + 1, + 16, + 1, + 0.6, + 90, + np.array([100.6, 100, 113.2]), + ), + ( + 2, + "bit_p2.vis", + "bit_p2.col", + 120, + 1, + 18, + 1, + 0.6, + 3.6, + np.array([100.6, 100, 113.2]), + ), + ( + 3, + "bit_p3.vis", + "bit_p3.col", + 120, + 1, + 15, + 1, + 0.6, + 90, + np.array([100.6, 100, 113.2]), + ), + ( + 4, + "bit_p4.vis", + "bit_p4.col", + 90, + 1, + 18, + 1, + 0.6, + 90, + np.array([100.6, 100, 113.2]), + ), + ( + 5, + "bit_p5.vis", + "bit_p5.col", + 90, + 1, + 12, + 1, + 0.6, + 3.6, + np.array([100.6, 100, 113.2]), + ), + ), + } filenames = set() - self._content = dict() + self._content = {} for group, phases in experimental_groups.items(): - experimental_phases = dict() + experimental_phases = {} for ( phase, visual_filename, @@ -1052,7 +1000,7 @@ def load(self) -> Dict[str, ExperimentalGroupLuo1997]: ) in phases: filenames.add(visual_filename) filenames.add(colorimetric_filename) - phase = str(phase) + phase = str(phase) # noqa: PLW2901 visual_path = os.path.join( self.record.repository, "dataset", visual_filename ) @@ -1105,14 +1053,14 @@ def load(self) -> Dict[str, ExperimentalGroupLuo1997]: return self._content -_DATASET_LOADER_LUO1997: Optional[DatasetLoader_Luo1997] = None +_DATASET_LOADER_LUO1997: DatasetLoader_Luo1997 | None = None """ Singleton instance of the *Luo and Rhodes (1997)* *LUTCHI Colour Appearance Data* dataset loader. """ -def build_Luo1997(load: Boolean = True) -> DatasetLoader_Luo1997: +def build_Luo1997(load: bool = True) -> DatasetLoader_Luo1997: """ Singleton factory that the builds *Luo and Rhodes (1997)* *LUTCHI Colour Appearance Data* dataset loader. @@ -1133,7 +1081,7 @@ def build_Luo1997(load: Boolean = True) -> DatasetLoader_Luo1997: :cite:`Luo1991`, :cite:`Luo1991a`, :cite:`Luo1993`, :cite:`Luo1997` """ - global _DATASET_LOADER_LUO1997 + global _DATASET_LOADER_LUO1997 # noqa: PLW0603 if _DATASET_LOADER_LUO1997 is None: _DATASET_LOADER_LUO1997 = DatasetLoader_Luo1997() diff --git a/colour_datasets/loaders/luo1999.py b/colour_datasets/loaders/luo1999.py index 5dc50ae..ad75aa7 100644 --- a/colour_datasets/loaders/luo1999.py +++ b/colour_datasets/loaders/luo1999.py @@ -30,7 +30,7 @@ import os from collections import namedtuple -from colour.hints import Boolean, Dict, Optional, Tuple +from colour.hints import Dict, Tuple, cast from colour.utilities import as_float_array from colour_datasets.loaders import AbstractDatasetLoader @@ -38,7 +38,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -173,306 +173,258 @@ def load(self) -> Dict[str, CorrespondingColourDataset_Luo1999]: "Experimental Method", ) - corresponding_colour_datasets: Dict[str, Tuple] = dict( - [ + corresponding_colour_datasets: Dict[str, Tuple] = { + "CSAJ-C": ( + ("CSAJ.da.dat",), ( - "CSAJ-C", - ( - ("CSAJ.da.dat",), - ( - 1, - 87, - "D65", - "A", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Haploscopic", - ), - ), + 1, + 87, + "D65", + "A", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Haploscopic", ), + ), + "CSAJ-Hunt": ( ( - "CSAJ-Hunt", - ( - ( - "CSAJ.10.dat", - "CSAJ.50.dat", - "CSAJ.1000.dat", - "CSAJ.3000.dat", - ), - ( - 4, - 20, - "D65", - "D65", - np.repeat([10, 50, 1000, 3000], 2, -1).reshape( - -1, 2 - ), - np.tile(20, [4, 2]), - "S", - "Refl.", - "Haploscopic", - ), - ), + "CSAJ.10.dat", + "CSAJ.50.dat", + "CSAJ.1000.dat", + "CSAJ.3000.dat", ), ( - "CSAJ-Stevens", - ( - ( - "Steve.10.dat", - "Steve.50.dat", - "Steve.1000.dat", - "Steve.3000.dat", - ), - ( - 4, - 19, - "D65", - "D65", - np.repeat([10, 50, 1000, 3000], 2, -1).reshape( - -1, 2 - ), - np.tile(20, [4, 2]), - "S", - "Refl.", - "Haploscopic", - ), - ), + 4, + 20, + "D65", + "D65", + np.repeat([10, 50, 1000, 3000], 2, -1).reshape(-1, 2), + np.tile(20, [4, 2]), + "S", + "Refl.", + "Haploscopic", ), + ), + "CSAJ-Stevens": ( ( - "Helson", - ( - ("helson.ca.dat",), - ( - 1, - 59, - "D65", - "A", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Memory", - ), - ), + "Steve.10.dat", + "Steve.50.dat", + "Steve.1000.dat", + "Steve.3000.dat", ), ( - "Lam & Rigg", - ( - ("lam.da.dat",), - ( - 1, - 58, - "D65", - "A", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "L", - "Refl.", - "Memory", - ), - ), + 4, + 19, + "D65", + "D65", + np.repeat([10, 50, 1000, 3000], 2, -1).reshape(-1, 2), + np.tile(20, [4, 2]), + "S", + "Refl.", + "Haploscopic", ), + ), + "Helson": ( + ("helson.ca.dat",), ( - "Lutchi (A)", - ( - ("lutchi.da.dat",), - ( - 1, - 43, - "D65", - "A", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Magnitude", - ), - ), + 1, + 59, + "D65", + "A", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Memory", ), + ), + "Lam & Rigg": ( + ("lam.da.dat",), ( - "Lutchi (D50)", - ( - ("lutchi.dd.dat",), - ( - 1, - 44, - "D65", - "D50", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Magnitude", - ), - ), + 1, + 58, + "D65", + "A", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "L", + "Refl.", + "Memory", ), + ), + "Lutchi (A)": ( + ("lutchi.da.dat",), ( - "Lutchi (WF)", - ( - ("lutchi.dw.dat",), - ( - 1, - 41, - "D65", - "WF", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Magnitude", - ), - ), + 1, + 43, + "D65", + "A", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Magnitude", ), + ), + "Lutchi (D50)": ( + ("lutchi.dd.dat",), ( - "Kuo & Luo (A)", - ( - ("Kuo.da.dat",), - ( - 1, - 40, - "D65", - "A", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "L", - "Refl.", - "Magnitude", - ), - ), + 1, + 44, + "D65", + "D50", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Magnitude", ), + ), + "Lutchi (WF)": ( + ("lutchi.dw.dat",), ( - "Kuo & Luo (TL84)", - ( - ("Kuo.dt.dat",), - ( - 1, - 41, - "D65", - "TL84", - np.tile(1000, [1, 2]), - np.tile(20, [1, 2]), - "S", - "Refl.", - "Magnitude", - ), - ), + 1, + 41, + "D65", + "WF", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Magnitude", ), + ), + "Kuo & Luo (A)": ( + ("Kuo.da.dat",), ( - "Breneman-C", - ( - ( - "Brene.p1.dat", - "Brene.p2.dat", - "Brene.p3.dat", - "Brene.p4.dat", - "Brene.p6.dat", - "Brene.p8.dat", - "Brene.p9.dat", - "Brene.p11.dat", - "Brene.p12.dat", - ), - ( - 9, - 107, - "D65, 55", - "A, P, G", - np.reshape( - np.repeat( - [ - 1500, - 1500, - 75, - 75, - 11100, - 350, - 15, - 1560, - 75, - ], - 2, - -1, - ), - (-1, 2), - ), - np.tile(30, [9, 2]), - "S", - "Trans.", - "Magnitude", - ), - ), + 1, + 40, + "D65", + "A", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "L", + "Refl.", + "Magnitude", ), + ), + "Kuo & Luo (TL84)": ( + ("Kuo.dt.dat",), ( - "Breneman-L", - ( - ( - "Brene.p5.dat", - "Brene.p7.dat", - "Brene.p10.dat", - ), - ( - 3, - 36, - "D55", - "D55", - np.array([[130, 2120], [850, 11100], [15, 270]]), - np.tile(30, [3, 2]), - "S", - "Trans.", - "Haploscopic", - ), - ), + 1, + 41, + "D65", + "TL84", + np.tile(1000, [1, 2]), + np.tile(20, [1, 2]), + "S", + "Refl.", + "Magnitude", ), + ), + "Breneman-C": ( ( - "Braun & Fairchild", - ( - ( - "RIT.1.dat", - "RIT.2.dat", - "RIT.3.dat", - "RIT.4.dat", - ), - ( - 4, - 66, - "D65", - "D30, 65, 95", - np.tile(129, [4, 2]), - np.tile(20, [4, 2]), - "S", - "Mon., Refl.", - "Matching", - ), - ), + "Brene.p1.dat", + "Brene.p2.dat", + "Brene.p3.dat", + "Brene.p4.dat", + "Brene.p6.dat", + "Brene.p8.dat", + "Brene.p9.dat", + "Brene.p11.dat", + "Brene.p12.dat", ), ( - "McCann", - ( - ( - "mcan.b.dat", - "mcan.g.dat", - "mcan.grey.dat", - "mcan.r.dat", - "mcan.y.dat", - ), - ( - 5, - 85, - "D65", - "R, Y, G, B", - np.tile((14 + 40) / 2, [5, 2]), - np.tile(30, [5, 2]), - "S", - "Refl.", - "Haploscopic", + 9, + 107, + "D65, 55", + "A, P, G", + np.reshape( + np.repeat( + [ + 1500, + 1500, + 75, + 75, + 11100, + 350, + 15, + 1560, + 75, + ], + 2, + -1, ), + (-1, 2), ), + np.tile(30, [9, 2]), + "S", + "Trans.", + "Magnitude", ), - ] - ) + ), + "Breneman-L": ( + ( + "Brene.p5.dat", + "Brene.p7.dat", + "Brene.p10.dat", + ), + ( + 3, + 36, + "D55", + "D55", + np.array([[130, 2120], [850, 11100], [15, 270]]), + np.tile(30, [3, 2]), + "S", + "Trans.", + "Haploscopic", + ), + ), + "Braun & Fairchild": ( + ( + "RIT.1.dat", + "RIT.2.dat", + "RIT.3.dat", + "RIT.4.dat", + ), + ( + 4, + 66, + "D65", + "D30, 65, 95", + np.tile(129, [4, 2]), + np.tile(20, [4, 2]), + "S", + "Mon., Refl.", + "Matching", + ), + ), + "McCann": ( + ( + "mcan.b.dat", + "mcan.g.dat", + "mcan.grey.dat", + "mcan.r.dat", + "mcan.y.dat", + ), + ( + 5, + 85, + "D65", + "R, Y, G, B", + np.tile((14 + 40) / 2, [5, 2]), + np.tile(30, [5, 2]), + "S", + "Refl.", + "Haploscopic", + ), + ), + } - self._content = dict() + self._content = {} for key, ( filenames, metadata, @@ -521,8 +473,8 @@ def load(self) -> Dict[str, CorrespondingColourDataset_Luo1999]: as_float_array(XYZ_t) / 100, as_float_array(XYZ_cr) / 100, as_float_array(XYZ_ct) / 100, - Y_r * np.pi, - Y_t * np.pi, + cast(float, Y_r) * np.pi, + cast(float, Y_t) * np.pi, B_r, B_t, dataset_metadata, @@ -531,14 +483,14 @@ def load(self) -> Dict[str, CorrespondingColourDataset_Luo1999]: return self._content -_DATASET_LOADER_LUO1999: Optional[DatasetLoader_Luo1999] = None +_DATASET_LOADER_LUO1999: DatasetLoader_Luo1999 | None = None """ Singleton instance of the *Luo and Rhodes (1999)* *Corresponding-Colour Datasets* dataset loader. """ -def build_Luo1999(load: Boolean = True) -> DatasetLoader_Luo1999: +def build_Luo1999(load: bool = True) -> DatasetLoader_Luo1999: """ Singleton factory that the builds *Luo and Rhodes (1999)* *Corresponding-Colour Datasets* dataset loader. @@ -559,7 +511,7 @@ def build_Luo1999(load: Boolean = True) -> DatasetLoader_Luo1999: :cite:`Breneman1987b`, :cite:`Luo1999`, :cite:`McCann1976` """ - global _DATASET_LOADER_LUO1999 + global _DATASET_LOADER_LUO1999 # noqa: PLW0603 if _DATASET_LOADER_LUO1999 is None: _DATASET_LOADER_LUO1999 = DatasetLoader_Luo1999() diff --git a/colour_datasets/loaders/tests/test_abstract.py b/colour_datasets/loaders/tests/test_abstract.py index 20a8bcb..ea028b8 100644 --- a/colour_datasets/loaders/tests/test_abstract.py +++ b/colour_datasets/loaders/tests/test_abstract.py @@ -7,7 +7,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_asano2015.py b/colour_datasets/loaders/tests/test_asano2015.py index 0c75810..8a4bebc 100644 --- a/colour_datasets/loaders/tests/test_asano2015.py +++ b/colour_datasets/loaders/tests/test_asano2015.py @@ -10,7 +10,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_brendel2020.py b/colour_datasets/loaders/tests/test_brendel2020.py index 8f09b6a..aeaeefd 100644 --- a/colour_datasets/loaders/tests/test_brendel2020.py +++ b/colour_datasets/loaders/tests/test_brendel2020.py @@ -14,7 +14,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_dyer2017.py b/colour_datasets/loaders/tests/test_dyer2017.py index 2486392..5773cf8 100644 --- a/colour_datasets/loaders/tests/test_dyer2017.py +++ b/colour_datasets/loaders/tests/test_dyer2017.py @@ -8,7 +8,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_ebner1998.py b/colour_datasets/loaders/tests/test_ebner1998.py index 2124515..7ddd238 100644 --- a/colour_datasets/loaders/tests/test_ebner1998.py +++ b/colour_datasets/loaders/tests/test_ebner1998.py @@ -8,7 +8,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_hung1995.py b/colour_datasets/loaders/tests/test_hung1995.py index f2570e8..7a650cd 100644 --- a/colour_datasets/loaders/tests/test_hung1995.py +++ b/colour_datasets/loaders/tests/test_hung1995.py @@ -8,7 +8,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_jakob2019.py b/colour_datasets/loaders/tests/test_jakob2019.py index c2f2218..8719546 100644 --- a/colour_datasets/loaders/tests/test_jakob2019.py +++ b/colour_datasets/loaders/tests/test_jakob2019.py @@ -7,7 +7,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_jiang2013.py b/colour_datasets/loaders/tests/test_jiang2013.py index 41bdc09..da0f79c 100644 --- a/colour_datasets/loaders/tests/test_jiang2013.py +++ b/colour_datasets/loaders/tests/test_jiang2013.py @@ -9,7 +9,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_karge2015.py b/colour_datasets/loaders/tests/test_karge2015.py index 6a96db9..bb30c94 100644 --- a/colour_datasets/loaders/tests/test_karge2015.py +++ b/colour_datasets/loaders/tests/test_karge2015.py @@ -9,7 +9,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_kuopio.py b/colour_datasets/loaders/tests/test_kuopio.py index 9b85ea9..2138897 100644 --- a/colour_datasets/loaders/tests/test_kuopio.py +++ b/colour_datasets/loaders/tests/test_kuopio.py @@ -11,20 +11,20 @@ MatFileMetadata_KuopioUniversity, read_sds_from_mat_file_KuopioUniversity, ) -from colour_datasets.loaders.kuopio import ( # type: ignore[attr-defined] - DatasetLoader_MunsellColorsMattSpectrofotometerMeasured, - DatasetLoader_MunsellColorsMattAOTFMeasured, - DatasetLoader_MunsellColorsGlossySpectrofotometerMeasured, - DatasetLoader_MunsellColorsGlossyAllSpectrofotometerMeasured, - DatasetLoader_ForestColors, - DatasetLoader_PaperSpectra, - DatasetLoader_LumberSpectra, - DatasetLoader_AgfaIT872Set, +from colour_datasets.loaders.kuopio import ( + DatasetLoader_MunsellColorsMattSpectrofotometerMeasured, # pyright: ignore + DatasetLoader_MunsellColorsMattAOTFMeasured, # pyright: ignore + DatasetLoader_MunsellColorsGlossySpectrofotometerMeasured, # pyright: ignore + DatasetLoader_MunsellColorsGlossyAllSpectrofotometerMeasured, # pyright: ignore + DatasetLoader_ForestColors, # pyright: ignore + DatasetLoader_PaperSpectra, # pyright: ignore + DatasetLoader_LumberSpectra, # pyright: ignore + DatasetLoader_AgfaIT872Set, # pyright: ignore ) __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_labsphere2019.py b/colour_datasets/loaders/tests/test_labsphere2019.py index c57086c..ed6eee6 100644 --- a/colour_datasets/loaders/tests/test_labsphere2019.py +++ b/colour_datasets/loaders/tests/test_labsphere2019.py @@ -14,7 +14,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_luo1997.py b/colour_datasets/loaders/tests/test_luo1997.py index c56cc23..4362ff4 100644 --- a/colour_datasets/loaders/tests/test_luo1997.py +++ b/colour_datasets/loaders/tests/test_luo1997.py @@ -8,7 +8,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_luo1999.py b/colour_datasets/loaders/tests/test_luo1999.py index 67c92f0..69fd488 100644 --- a/colour_datasets/loaders/tests/test_luo1999.py +++ b/colour_datasets/loaders/tests/test_luo1999.py @@ -8,7 +8,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_winquist2022.py b/colour_datasets/loaders/tests/test_winquist2022.py index 38b9fc7..f63a7ce 100644 --- a/colour_datasets/loaders/tests/test_winquist2022.py +++ b/colour_datasets/loaders/tests/test_winquist2022.py @@ -14,7 +14,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_xrite2016.py b/colour_datasets/loaders/tests/test_xrite2016.py index 6809a12..b7bebfc 100644 --- a/colour_datasets/loaders/tests/test_xrite2016.py +++ b/colour_datasets/loaders/tests/test_xrite2016.py @@ -9,7 +9,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/tests/test_zhao2009.py b/colour_datasets/loaders/tests/test_zhao2009.py index 09e789c..f90cba6 100644 --- a/colour_datasets/loaders/tests/test_zhao2009.py +++ b/colour_datasets/loaders/tests/test_zhao2009.py @@ -9,7 +9,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/loaders/winquist2022.py b/colour_datasets/loaders/winquist2022.py index c1707af..5bf0356 100644 --- a/colour_datasets/loaders/winquist2022.py +++ b/colour_datasets/loaders/winquist2022.py @@ -21,7 +21,7 @@ import glob import os -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour_datasets.loaders import AbstractDatasetLoader from colour_datasets.loaders.dyer2017 import MultiSpectralDistributions_AMPAS @@ -29,7 +29,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -88,7 +88,7 @@ def load(self) -> Dict[str, MultiSpectralDistributions_AMPAS]: super().sync() - self._content = dict() + self._content = {} glob_pattern = os.path.join( self.record.repository, "dataset", "*.json" @@ -100,14 +100,14 @@ def load(self) -> Dict[str, MultiSpectralDistributions_AMPAS]: return self._content -_DATASET_LOADER_WINQUIST2022: Optional[DatasetLoader_Winquist2022] = None +_DATASET_LOADER_WINQUIST2022: DatasetLoader_Winquist2022 | None = None """ Singleton instance of the *Winquist et al. (2022)* *Physlight - Camera Spectral Sensitivity Curves* dataset loader. """ -def build_Winquist2022(load: Boolean = True) -> DatasetLoader_Winquist2022: +def build_Winquist2022(load: bool = True) -> DatasetLoader_Winquist2022: """ Singleton factory that builds the *Winquist et al. (2022)* *Physlight - Camera Spectral Sensitivity Curves* dataset loader. @@ -128,7 +128,7 @@ def build_Winquist2022(load: Boolean = True) -> DatasetLoader_Winquist2022: :cite:`Winquist2022` """ - global _DATASET_LOADER_WINQUIST2022 + global _DATASET_LOADER_WINQUIST2022 # noqa: PLW0603 if _DATASET_LOADER_WINQUIST2022 is None: _DATASET_LOADER_WINQUIST2022 = DatasetLoader_Winquist2022() diff --git a/colour_datasets/loaders/xrite2016.py b/colour_datasets/loaders/xrite2016.py index a54e93d..00ef512 100644 --- a/colour_datasets/loaders/xrite2016.py +++ b/colour_datasets/loaders/xrite2016.py @@ -24,14 +24,14 @@ from colour import CCS_ILLUMINANTS, Lab_to_XYZ, XYZ_to_xyY from colour.characterisation import ColourChecker -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour_datasets.loaders import AbstractDatasetLoader from colour_datasets.records import datasets __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -112,7 +112,7 @@ def load(self) -> Dict[str, ColourChecker]: "ICC D50" ] - self._content = dict() + self._content = {} for key, filename in zip(keys, filenames): directory = os.path.splitext(filename)[0] path = os.path.join( @@ -146,18 +146,19 @@ def load(self) -> Dict[str, ColourChecker]: i, j = (6, 4) if len(samples_data) == 24 else (14, 10) samples = np.transpose( - np.array(samples_data).reshape([i, j, 2]), [1, 0, 2] + np.array(samples_data, dtype=object).reshape([i, j, 2]), + [1, 0, 2], ) keys, values = zip(*samples.reshape([-1, 2])) values = XYZ_to_xyY(Lab_to_XYZ(values, illuminant)) self._content[key] = ColourChecker( - key, dict(zip(keys, values)), illuminant + key, dict(zip(keys, values)), illuminant, j, i ) return self._content -_DATASET_LOADER_XRITE2016: Optional[DatasetLoader_XRite2016] = None +_DATASET_LOADER_XRITE2016: DatasetLoader_XRite2016 | None = None """ Singleton instance of the *X-Rite (2016)* *New Color Specifications for ColorChecker SG and Classic Charts* dataset @@ -165,7 +166,7 @@ def load(self) -> Dict[str, ColourChecker]: """ -def build_XRite2016(load: Boolean = True) -> DatasetLoader_XRite2016: +def build_XRite2016(load: bool = True) -> DatasetLoader_XRite2016: """ Singleton factory that the builds *X-Rite (2016)* *New Color Specifications for ColorChecker SG and Classic Charts* dataset @@ -188,7 +189,7 @@ def build_XRite2016(load: Boolean = True) -> DatasetLoader_XRite2016: :cite:`X-Rite2016` """ - global _DATASET_LOADER_XRITE2016 + global _DATASET_LOADER_XRITE2016 # noqa: PLW0603 if _DATASET_LOADER_XRITE2016 is None: _DATASET_LOADER_XRITE2016 = DatasetLoader_XRite2016() diff --git a/colour_datasets/loaders/zhao2009.py b/colour_datasets/loaders/zhao2009.py index f93a775..e1fd1c1 100644 --- a/colour_datasets/loaders/zhao2009.py +++ b/colour_datasets/loaders/zhao2009.py @@ -21,14 +21,14 @@ import os from colour.characterisation import RGB_CameraSensitivities -from colour.hints import Boolean, Dict, Optional +from colour.hints import Dict from colour_datasets.loaders import AbstractDatasetLoader from colour_datasets.records import datasets __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -103,7 +103,7 @@ def load(self) -> Dict[str, RGB_CameraSensitivities]: "KODAK DCS 200", ] - self._content = dict() + self._content = {} for i, camera in enumerate(cameras): data = np.loadtxt( @@ -118,14 +118,14 @@ def load(self) -> Dict[str, RGB_CameraSensitivities]: return self._content -_DATASET_LOADER_JIANG2009: Optional[DatasetLoader_Zhao2009] = None +_DATASET_LOADER_JIANG2009: DatasetLoader_Zhao2009 | None = None """ Singleton instance of the *Zhao et al. (2009)* *Spectral Sensitivity Database* dataset loader. """ -def build_Zhao2009(load: Boolean = True) -> DatasetLoader_Zhao2009: +def build_Zhao2009(load: bool = True) -> DatasetLoader_Zhao2009: """ Singleton factory that builds the *Zhao et al. (2009)* *Spectral Sensitivity Database* dataset loader. @@ -146,7 +146,7 @@ def build_Zhao2009(load: Boolean = True) -> DatasetLoader_Zhao2009: :cite:`Zhao2009` """ - global _DATASET_LOADER_JIANG2009 + global _DATASET_LOADER_JIANG2009 # noqa: PLW0603 if _DATASET_LOADER_JIANG2009 is None: _DATASET_LOADER_JIANG2009 = DatasetLoader_Zhao2009() diff --git a/colour_datasets/records/__init__.py b/colour_datasets/records/__init__.py index 554bb05..d321c97 100644 --- a/colour_datasets/records/__init__.py +++ b/colour_datasets/records/__init__.py @@ -1,6 +1,5 @@ from __future__ import annotations -from colour.hints import Optional from .configuration import Configuration, sandbox, use_sandbox from .zenodo import Community, Record @@ -15,7 +14,7 @@ "Record", ] -_COMMUNITY: Optional[Community] = None +_COMMUNITY: Community | None = None """ Singleton instance of the *Zenodo* community that holds the datasets information. @@ -39,7 +38,7 @@ def datasets() -> Community: 'Camera Spectral Sensitivity Database - Jiang et al. (2013)' """ - global _COMMUNITY + global _COMMUNITY # noqa: PLW0603 if _COMMUNITY is None: _COMMUNITY = Community.from_id(Configuration().community) diff --git a/colour_datasets/records/configuration.py b/colour_datasets/records/configuration.py index bd29737..a9313be 100644 --- a/colour_datasets/records/configuration.py +++ b/colour_datasets/records/configuration.py @@ -10,7 +10,7 @@ import functools import os -from colour.hints import Any, Boolean, Callable, Dict, Optional +from colour.hints import Any, Callable, Dict from colour.utilities import Structure from colour.utilities.documentation import ( DocstringDict, @@ -19,7 +19,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -65,14 +65,14 @@ class Configuration(Structure): Configuration to use instead of the default one. """ - def __init__(self, configuration: Optional[Dict] = None) -> None: + def __init__(self, configuration: Dict | None = None) -> None: super().__init__( DEFAULT_CONFIGURATION if configuration is None else configuration ) def use_sandbox( - state: Boolean = True, + state: bool = True, api_url: str = "https://sandbox.zenodo.org/api", community: str = "colour-science-datasets", ): @@ -89,7 +89,7 @@ def use_sandbox( *Zenodo* community. """ - global DEFAULT_CONFIGURATION + global DEFAULT_CONFIGURATION # noqa: PLW0602 if state: DEFAULT_CONFIGURATION["api_url"] = api_url @@ -117,7 +117,6 @@ def __init__( api_url: str = "https://sandbox.zenodo.org/api", community: str = "colour-science-datasets", ) -> None: - self._api_url = api_url self._community = community diff --git a/colour_datasets/records/tests/test_configuration.py b/colour_datasets/records/tests/test_configuration.py index a5e2185..a1e49d8 100644 --- a/colour_datasets/records/tests/test_configuration.py +++ b/colour_datasets/records/tests/test_configuration.py @@ -9,7 +9,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/colour_datasets/records/tests/test_zenodo.py b/colour_datasets/records/tests/test_zenodo.py index 0ae91e0..1bf095f 100644 --- a/colour_datasets/records/tests/test_zenodo.py +++ b/colour_datasets/records/tests/test_zenodo.py @@ -12,7 +12,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -167,7 +167,7 @@ def test__repr__(self): """Test :func:`colour_datasets.records.zenodo.Record.__repr__` method.""" self.assertIsInstance( - eval( + eval( # noqa: PGH001, S307 repr(self._record), {}, {"Record": Record, "Configuration": Configuration}, @@ -335,7 +335,7 @@ def test__repr__(self): """Test :func:`colour_datasets.records.zenodo.Community.__repr__` method.""" self.assertIsInstance( - eval( + eval( # noqa: PGH001, S307 repr(self._community), {}, {"Community": Community, "Configuration": Configuration}, diff --git a/colour_datasets/records/zenodo.py b/colour_datasets/records/zenodo.py index 407e229..0eaad9b 100644 --- a/colour_datasets/records/zenodo.py +++ b/colour_datasets/records/zenodo.py @@ -26,14 +26,10 @@ from colour.hints import ( Any, - Boolean, Callable, Dict, Generator, - Integer, List, - Optional, - Union, ) from colour.utilities import optional, warning @@ -42,7 +38,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -95,9 +91,8 @@ class Record: """ def __init__( - self, data: dict, configuration: Optional[Configuration] = None + self, data: dict, configuration: Configuration | None = None ) -> None: - self._data: dict = data self._configuration: Configuration = optional( configuration, Configuration() @@ -143,7 +138,7 @@ def repository(self) -> str: return os.path.join(self._configuration.repository, self.id) @property - def id(self) -> str: + def id(self) -> str: # noqa: A003 """ Getter property for the *Zenodo* record id. @@ -194,7 +189,7 @@ def strip_html(text: str) -> str: parts: List[str] = [] parser = HTMLParser() - parser.handle_data = parts.append # type: ignore[assignment] + parser.handle_data = parts.append # pyright: ignore parser.feed(text) return "".join(parts) @@ -279,8 +274,8 @@ def __repr__(self) -> str: @staticmethod def from_id( id_: str, - configuration: Optional[Configuration] = None, - retries: Integer = 3, + configuration: Configuration | None = None, + retries: int = 3, ) -> Record: """ :class:`colour_datasets.Record` class factory that builds an instance @@ -320,7 +315,7 @@ def from_id( return Record(json_open(record_url, retries), configuration) - def synced(self) -> Boolean: + def synced(self) -> bool: """ Return whether the *Zenodo* record data is synced to the local repository. @@ -357,7 +352,7 @@ def synced(self) -> Boolean: ] ) - def pull(self, use_urls_txt_file: Boolean = True, retries: Integer = 3): + def pull(self, use_urls_txt_file: bool = True, retries: int = 3): """ Pull the *Zenodo* record data to the local repository. @@ -384,7 +379,7 @@ def pull(self, use_urls_txt_file: Boolean = True, retries: Integer = 3): True """ - print(f'Pulling "{self.title}" record content...') + print(f'Pulling "{self.title}" record content...') # noqa: T201 if not os.path.exists(self._configuration.repository): os.makedirs(self._configuration.repository) @@ -409,7 +404,7 @@ def urls_download(urls: Dict): for url, md5 in urls.items(): filename = os.path.join( downloads_directory, - urllib.parse.unquote( # type: ignore[attr-defined] + urllib.parse.unquote( # pyright: ignore url.split("/")[-1] ), ) @@ -418,7 +413,7 @@ def urls_download(urls: Dict): try: if use_urls_txt_file and urls_txt: urls = {} - urls_txt_file = tempfile.mktemp() + urls_txt_file = tempfile.NamedTemporaryFile(delete=False).name url_download( urls_txt["links"]["self"], urls_txt_file, @@ -440,7 +435,7 @@ def urls_download(urls: Dict): urls_download(urls) else: - raise ValueError( + raise ValueError( # noqa: TRY301 f'"{self._configuration.urls_txt_file}" file was not ' f"found in record data!" ) @@ -471,7 +466,9 @@ def urls_download(urls: Dict): shutil.copytree(downloads_directory, deflate_directory) for filename in os.listdir(deflate_directory): - filename = os.path.join(deflate_directory, filename) + filename = os.path.join( # noqa: PLW2901 + deflate_directory, filename + ) if not os.path.isfile(filename): continue @@ -484,7 +481,7 @@ def urls_download(urls: Dict): basename = basename.replace(".", "_") unpacking_directory = os.path.join(deflate_directory, basename) - print(f'Unpacking "{filename}" archive...') + print(f'Unpacking "{filename}" archive...') # noqa: T201 setuptools.archive_util.unpack_archive( filename, unpacking_directory ) @@ -568,7 +565,7 @@ class Community(Mapping): """ def __init__( - self, data: Dict, configuration: Optional[Configuration] = None + self, data: Dict, configuration: Configuration | None = None ) -> None: self._data: Dict = data self._configuration: Configuration = optional( @@ -723,7 +720,7 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(\n{data},\n{configuration}\n)" - def __getitem__(self, item: Union[str, Any]) -> Any: + def __getitem__(self, item: str | Any) -> Any: """ Return the *Zenodo* record at given id. @@ -767,7 +764,7 @@ def __iter__(self) -> Generator: yield from self._records - def __len__(self) -> Integer: + def __len__(self) -> int: """ Return *Zenodo* community records count. @@ -789,8 +786,8 @@ def __len__(self) -> Integer: @staticmethod def from_id( id_: str, - configuration: Optional[Configuration] = None, - retries: Integer = 3, + configuration: Configuration | None = None, + retries: int = 3, ) -> Community: """ :class:`colour_datasets.Community` class factory that builds an @@ -857,7 +854,7 @@ def from_id( }.items(): with open(key, "w") as json_file: json.dump(value, json_file, indent=4, sort_keys=True) - except (urllib.error.URLError, ValueError): + except (urllib.error.URLError, ValueError) as error: warning( 'Retrieving the "{0}" community data failed ' "after {1} attempts, " @@ -869,7 +866,9 @@ def from_id( os.path.exists(records_json_filename), ] ): - raise RuntimeError("Local files were not found, aborting!") + raise RuntimeError( + "Local files were not found, aborting!" + ) from error with open(community_json_filename) as json_file: community_data = json.loads(json_file.read()) @@ -884,7 +883,7 @@ def from_id( return Community(data, configuration) - def synced(self) -> Boolean: + def synced(self) -> bool: """ Return whether the *Zenodo* community data is synced to the local repository. @@ -909,9 +908,9 @@ def synced(self) -> Boolean: False """ - return all([record.synced() for record in self._records.values()]) + return all(record.synced() for record in self._records.values()) - def pull(self, use_urls_txt_file: Boolean = True, retries: Integer = 3): + def pull(self, use_urls_txt_file: bool = True, retries: int = 3): """ Pull the *Zenodo* community data to the local repository. @@ -964,7 +963,9 @@ def remove(self): shutil.rmtree(self.repository, onerror=_remove_readonly) -def _remove_readonly(function: Callable, path: str, excinfo: Any): +def _remove_readonly( + function: Callable, path: str, excinfo: Any # noqa: ARG001 +): """ Error handler for :func:`shutil.rmtree` definition that removes read-only files. diff --git a/colour_datasets/utilities/common.py b/colour_datasets/utilities/common.py index cac2981..d72ea11 100644 --- a/colour_datasets/utilities/common.py +++ b/colour_datasets/utilities/common.py @@ -20,11 +20,11 @@ from tqdm import tqdm from cachetools import cached, TTLCache -from colour.hints import Any, Boolean, Callable, Dict, Integer, Optional +from colour.hints import Any, Callable, Dict __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -46,7 +46,7 @@ def __enter__(self) -> suppress_stdout: """Redirect the standard output upon entering the context manager.""" self._stdout = sys.stdout - sys.stdout = open(os.devnull, "w") + sys.stdout = open(os.devnull, "w") # noqa: SIM115 return self @@ -72,9 +72,9 @@ class TqdmUpTo(tqdm): def update_to( self, - chunks_count: Integer = 1, - chunk_size: Integer = 1, - total_size: Optional[Integer] = None, + chunks_count: int = 1, + chunk_size: int = 1, + total_size: int | None = None, ): """ Report the progress of an action. @@ -95,7 +95,7 @@ def update_to( self.update(chunks_count * chunk_size - self.n) -def hash_md5(filename: str, chunk_size: Integer = 2**16) -> str: +def hash_md5(filename: str, chunk_size: int = 2**16) -> str: """ Compute the *Message Digest 5 (MD5)* hash of given file. @@ -112,7 +112,7 @@ def hash_md5(filename: str, chunk_size: Integer = 2**16) -> str: *MD5* hash of given file. """ - md5 = hashlib.md5() + md5 = hashlib.md5() # noqa: S324 with open(filename, "rb") as file_object: while True: @@ -126,7 +126,7 @@ def hash_md5(filename: str, chunk_size: Integer = 2**16) -> str: def url_download( - url: str, filename: str, md5: Optional[str] = None, retries: Integer = 3 + url: str, filename: str, md5: str | None = None, retries: int = 3 ): """ Download given url and saves its content at given file. @@ -161,33 +161,32 @@ def url_download( miniters=1, desc=f"Downloading \"{url.split('/')[-1]}\" file", ) as progress: - urllib.request.urlretrieve( + urllib.request.urlretrieve( # noqa: S310 url, filename=filename, reporthook=progress.update_to, data=None, ) - if md5 is not None: - if md5.lower() != hash_md5(filename): - raise ValueError( - f'"MD5" hash of "{filename}" file does not match the ' - f"expected hash!" - ) + if md5 is not None and md5.lower() != hash_md5(filename): + raise ValueError( # noqa: TRY301 + f'"MD5" hash of "{filename}" file does not match the ' + f"expected hash!" + ) attempt = retries - except (urllib.error.URLError, OSError, ValueError) as error: + except (urllib.error.URLError, OSError, ValueError): attempt += 1 - print( + print( # noqa: T201 f'An error occurred while downloading "{filename}" file ' f"during attempt {attempt}, retrying..." ) if attempt == retries: - raise error + raise @cached(cache=TTLCache(maxsize=256, ttl=300)) -def json_open(url: str, retries: Integer = 3) -> Dict: +def json_open(url: str, retries: int = 3) -> Dict: """ Open given url and return its content as *JSON*. @@ -225,22 +224,24 @@ def json_open(url: str, retries: Integer = 3) -> Dict: attempt = 0 while attempt != retries: try: - return json.loads(urllib.request.urlopen(url).read()) - except (urllib.error.URLError, ValueError) as error: + request = urllib.request.Request(url) + with urllib.request.urlopen(request) as response: # noqa: S310 + return json.loads(response.read()) + except (urllib.error.URLError, ValueError): attempt += 1 - print( + print( # noqa: T201 f'An error occurred while opening "{url}" url during attempt ' f"{attempt}, retrying..." ) if attempt == retries: - raise error + raise return data def unpack_gzipfile( - filename: str, extraction_directory: str, *args: Any -) -> Boolean: + filename: str, extraction_directory: str, *args: Any # noqa: ARG001 +) -> bool: """ Unpack given *GZIP* file to given extraction directory. @@ -279,11 +280,11 @@ def unpack_gzipfile( extraction_path, "wb" ) as output_file: shutil.copyfileobj(gzip_file, output_file) - except Exception as e: - print(e) + except Exception as error: + print(error) # noqa: T201 raise setuptools.archive_util.UnrecognizedFormat( f'{filename} is not a "GZIP" file!' - ) + ) from error return True diff --git a/colour_datasets/utilities/spreadsheet.py b/colour_datasets/utilities/spreadsheet.py index 5138ec5..da7237a 100644 --- a/colour_datasets/utilities/spreadsheet.py +++ b/colour_datasets/utilities/spreadsheet.py @@ -15,14 +15,14 @@ import re import xlrd -from colour.hints import Dict, Integer, List, Union -from colour.utilities import CanonicalMapping +from colour.hints import Dict, List +from colour.utilities import CanonicalMapping, attest __author__ = "Colour Developers, Openpyxl Developers" __copyright__ = "Copyright 2019 Colour Developers" __copyright__ += ", " __copyright__ = "Copyright (C) 2010 openpyxl" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __license__ += ", " __license__ += "MIT Licence - https://opensource.org/licenses/MIT" __maintainer__ = "Colour Developers" @@ -37,8 +37,13 @@ "cell_range_values", ] +# https://stackoverflow.com/questions/64264563/\ +# attributeerror-elementtree-object-has-no-attribute-getiterator-when-trying +xlrd.xlsx.ensure_elementtree_imported(False, None) +xlrd.xlsx.Element_has_iter = True -def _column_number_to_letters(number: Integer) -> str: + +def _column_number_to_letters(number: int) -> str: """ Convert given column number into a column letters. @@ -62,14 +67,14 @@ def _column_number_to_letters(number: Integer) -> str: Examples -------- - # Doctests skip for Python 2.x compatibility. - >>> _column_number_to_letters(128) # doctest: +SKIP + >>> _column_number_to_letters(128) 'DX' """ - assert ( - 1 <= number <= 18278 - ), f"Column number {number} must be in range [1, 18278]!" + attest( + 1 <= number <= 18278, + f"Column number {number} must be in range [1, 18278]!", + ) letters = [] while number > 0: @@ -94,7 +99,7 @@ def _column_number_to_letters(number: Integer) -> str: _LETTERS_TO_NUMBER_CACHE[letter] = i -def row_to_index(row: Union[Integer, str]) -> Integer: +def row_to_index(row: int | str) -> int: """ Return the 0-based index of given row name. @@ -116,12 +121,12 @@ def row_to_index(row: Union[Integer, str]) -> Integer: row = int(row) - assert row > 0, "Row must be greater than 0!" + attest(row > 0, "Row must be greater than 0!") return row - 1 -def index_to_row(index: Integer) -> str: +def index_to_row(index: int) -> str: """ Return the row name of given 0-based index. @@ -145,7 +150,7 @@ def index_to_row(index: Integer) -> str: return str(index + 1) -def column_to_index(column: str) -> Integer: +def column_to_index(column: str) -> int: """ Return the 0-based index of given column letters. @@ -168,7 +173,7 @@ def column_to_index(column: str) -> Integer: return _LETTERS_TO_NUMBER_CACHE[column] - 1 -def index_to_column(index: Integer) -> str: +def index_to_column(index: int) -> str: """ Return the column letters of given 0-based index. diff --git a/colour_datasets/utilities/tests/test_common.py b/colour_datasets/utilities/tests/test_common.py index c950fe2..cbebfb4 100644 --- a/colour_datasets/utilities/tests/test_common.py +++ b/colour_datasets/utilities/tests/test_common.py @@ -16,7 +16,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -70,7 +70,7 @@ class TestUrlDownload(unittest.TestCase): def setUp(self): """Initialise the common tests attributes.""" - self._temporary_file = tempfile.mktemp() + self._temporary_file = tempfile.NamedTemporaryFile(delete=False).name def tearDown(self): """After tests actions.""" diff --git a/colour_datasets/utilities/tests/test_spreadsheet.py b/colour_datasets/utilities/tests/test_spreadsheet.py index 292c7d6..a1b7c0a 100644 --- a/colour_datasets/utilities/tests/test_spreadsheet.py +++ b/colour_datasets/utilities/tests/test_spreadsheet.py @@ -17,7 +17,7 @@ __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" diff --git a/docs/conf.py b/docs/conf.py index fc5afcb..55c62db 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,8 +4,12 @@ """ import re +import sys +from pathlib import Path -import colour_datasets as package +sys.path.append(str(Path(__file__).parent.parent)) + +import colour_datasets as package # noqa: E402 basename = re.sub( "_(\\w)", lambda x: x.group(1).upper(), package.__name__.title() @@ -37,27 +41,20 @@ autodoc_typehints = "both" autodoc_type_aliases = { "ArrayLike": "ArrayLike", - "Boolean": "bool", - "BooleanOrArrayLike": "BooleanOrArrayLike", - "BooleanOrNDArray": "BooleanOrNDArray", "DType": "DType", "DTypeBoolean": "DTypeBoolean", "DTypeComplex": "DTypeComplex", - "DTypeFloating": "DTypeFloating", - "DTypeInteger": "DTypeInteger", - "DTypeNumber": "DTypeNumber", - "Floating": "float", - "FloatingOrArrayLike": "FloatingOrArrayLike", - "FloatingOrNDArray": "FloatingOrNDArray", - "Integer": "int", - "IntegerOrArrayLike": "IntegerOrArrayLike", - "IntegerOrNDArray": "IntegerOrNDArray", - "NestedSequence": "NestedSequence", - "Number": "Number", - "NumberOrArrayLike": "NumberOrArrayLike", - "NumberOrNDArray": "NumberOrNDArray", - "StrOrArrayLike": "StrOrArrayLike", - "StrOrNDArray": "StrOrNDArray", + "DTypeFloat": "DTypeFloat", + "DTypeInt": "DTypeInt", + "DTypeReal": "DTypeReal", + "Dataclass": "Dataclass", + "NDArrayBoolean": "NDArrayBoolean", + "NDArrayComplex": "NDArrayComplex", + "NDArrayFloat": "NDArrayFloat", + "NDArrayInt": "NDArrayInt", + "NDArrayReal": "NDArrayReal", + "NDArrayStr": "NDArrayStr", + "Real": "Real", } autodoc_preserve_defaults = True @@ -75,7 +72,7 @@ master_doc = "index" project = package.__application_name__ -copyright = package.__copyright__.replace("Copyright (C)", "") +copyright = package.__copyright__.replace("Copyright (C)", "") # noqa: A001 version = f"{package.__major_version__}.{package.__minor_version__}" release = package.__version__ @@ -184,19 +181,3 @@ epub_publisher = package.__author__ epub_copyright = package.__copyright__.replace("Copyright (C)", "") epub_exclude_files = ["search.html"] - - -def autodoc_process_docstring(app, what, name, obj, options, lines): - """Process the docstrings to remove the *# noqa* *flake8* pragma.""" - - for i, line in enumerate(lines): - lines[i] = line.replace("# noqa", "") - - -def setup(app): - """ - Prepare the extension and linking resources that Sphinx uses in the - build process. - """ - - app.connect("autodoc-process-docstring", autodoc_process_docstring) diff --git a/docs/index.rst b/docs/index.rst index 4934a2f..9bad645 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,11 +5,11 @@ Colour science datasets for use with `Colour `__ or any Python package manipulating colours. The datasets are hosted in `Zenodo `__ under the -`Colour Science - Datasets `__ +`Colour Science - Datasets `__ community. It is open source and freely available under the -`New BSD License `__ terms. +`BSD-3-Clause `__ terms. .. sectnum:: @@ -27,7 +27,7 @@ when trying to access or use colour science datasets: **Colour - Datasets** offers all the above: it allows users to ingest and load colour science datasets with a single function call. The datasets information -is hosted on `Zenodo `__ +is hosted on `Zenodo `__ where the record for a dataset typically contain: - An *urls.txt* file describing the urls to source the dataset files from. @@ -142,7 +142,7 @@ Code of Conduct --------------- The *Code of Conduct*, adapted from the `Contributor Covenant 1.4 `__, -is available on the `Code of Conduct `__ page. +is available on the `Code of Conduct `__ page. Contact & Social ---------------- @@ -160,5 +160,5 @@ About | **Colour - Datasets** by Colour Developers | Copyright 2019 Colour Developers – `colour-developers@colour-science.org `__ -| This software is released under terms of New BSD License: https://opensource.org/licenses/BSD-3-Clause +| This software is released under terms of BSD-3-Clause: https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-datasets `__ diff --git a/docs/installation.rst b/docs/installation.rst index dda4a14..0365c0f 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -6,14 +6,14 @@ Primary Dependencies **Colour - Datasets** requires various dependencies in order to run: -- `python >= 3.8, < 4 `__ -- `cachetools `__ -- `colour-science >= 4 `__ -- `imageio >= 2, < 3 `__ -- `numpy >= 1.19, < 2 `__ -- `scipy >= 1.5, < 2 `__ -- `tqdm `__ -- `xlrd `__ +- `python >= 3.9, < 4 `__ +- `cachetools `__ +- `colour-science >= 4.3 `__ +- `imageio >= 2, < 3 `__ +- `numpy >= 1.22, < 2 `__ +- `scipy >= 1.8, < 2 `__ +- `tqdm `__ +- `xlrd `__ Pypi ---- diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..a533574 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,46 @@ +accessible-pygments==0.0.4 ; python_version >= "3.9" and python_version < "3.12" +alabaster==0.7.13 ; python_version >= "3.9" and python_version < "3.12" +babel==2.12.1 ; python_version >= "3.9" and python_version < "3.12" +beautifulsoup4==4.12.2 ; python_version >= "3.9" and python_version < "3.12" +biblib-simple==0.1.2 ; python_version >= "3.9" and python_version < "3.12" +cachetools==5.3.1 ; python_version >= "3.9" and python_version < "3.12" +certifi==2023.7.22 ; python_version >= "3.9" and python_version < "3.12" +charset-normalizer==3.2.0 ; python_version >= "3.9" and python_version < "3.12" +colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.12" and (platform_system == "Windows" or sys_platform == "win32") +colour-science==0.4.3 ; python_version >= "3.9" and python_version < "3.12" +docutils==0.17.1 ; python_version >= "3.9" and python_version < "3.12" +idna==3.4 ; python_version >= "3.9" and python_version < "3.12" +imageio==2.31.2 ; python_version >= "3.9" and python_version < "3.12" +imagesize==1.4.1 ; python_version >= "3.9" and python_version < "3.12" +importlib-metadata==6.8.0 ; python_version >= "3.9" and python_version < "3.10" +jinja2==3.1.2 ; python_version >= "3.9" and python_version < "3.12" +latexcodec==2.0.1 ; python_version >= "3.9" and python_version < "3.12" +markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "3.12" +numpy==1.25.2 ; python_version >= "3.9" and python_version < "3.12" +opencv-python==4.8.0.76 ; python_version >= "3.9" and python_version < "3.12" +packaging==23.1 ; python_version >= "3.9" and python_version < "3.12" +pillow==10.0.0 ; python_version >= "3.9" and python_version < "3.12" +pybtex-docutils==1.0.3 ; python_version >= "3.9" and python_version < "3.12" +pybtex==0.24.0 ; python_version >= "3.9" and python_version < "3.12" +pydata-sphinx-theme==0.13.3 ; python_version >= "3.9" and python_version < "3.12" +pygments==2.16.1 ; python_version >= "3.9" and python_version < "3.12" +pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "3.12" +requests==2.31.0 ; python_version >= "3.9" and python_version < "3.12" +restructuredtext-lint==1.4.0 ; python_version >= "3.9" and python_version < "3.12" +scipy==1.11.2 ; python_version >= "3.9" and python_version < "3.12" +six==1.16.0 ; python_version >= "3.9" and python_version < "3.12" +snowballstemmer==2.2.0 ; python_version >= "3.9" and python_version < "3.12" +soupsieve==2.4.1 ; python_version >= "3.9" and python_version < "3.12" +sphinx==4.5.0 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-applehelp==1.0.4 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-bibtex==2.6.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-devhelp==1.0.2 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-htmlhelp==2.0.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-qthelp==1.0.3 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-serializinghtml==1.1.5 ; python_version >= "3.9" and python_version < "3.12" +tqdm==4.66.1 ; python_version >= "3.9" and python_version < "3.12" +typing-extensions==4.7.1 ; python_version >= "3.9" and python_version < "3.12" +urllib3==2.0.4 ; python_version >= "3.9" and python_version < "3.12" +xlrd==1.2.0 ; python_version >= "3.9" and python_version < "3.12" +zipp==3.16.2 ; python_version >= "3.9" and python_version < "3.10" diff --git a/pyproject.toml b/pyproject.toml index 70dd90c..5b99e80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "colour-datasets" -version = "0.2.1" +version = "0.2.2" description = "Colour science datasets for use with Colour" license = "BSD-3-Clause" authors = [ "Colour Developers " ] @@ -45,91 +45,44 @@ classifiers = [ [tool.poetry.dependencies] python = ">= 3.9, < 3.12" cachetools = "*" -colour-science = ">= 0.4.2" +colour-science = ">= 0.4.3" imageio = ">= 2, < 3" -numpy = ">= 1.20, < 2" +numpy = ">= 1.22, < 2" opencv-python = ">= 4, < 5" -scipy = ">= 1.7, < 2" +scipy = ">= 1.8, < 2" tqdm = "*" -typing-extensions = ">= 4, < 5" # Convenience for Google Colab. +typing-extensions = ">= 4, < 5" xlrd = ">= 1.2, < 2" -biblib-simple = { version = "*", optional = true } # Development dependency. -black = { version = "*", optional = true } # Development dependency. -blackdoc = { version = "*", optional = true } # Development dependency. -coverage = { version = "!= 6.3", optional = true } # Development dependency. -coveralls = { version = "*", optional = true } # Development dependency. -flake8 = { version = "*", optional = true } # Development dependency. -flynt = { version = "*", optional = true } # Development dependency. -invoke = { version = "*", optional = true } # Development dependency. -mypy = { version = "*", optional = true } # Development dependency. -pre-commit = { version = "*", optional = true } # Development dependency. -pydata-sphinx-theme = { version = "*", optional = true } # Development dependency. -pydocstyle = { version = "*", optional = true } # Development dependency. -pytest = { version = "*", optional = true } # Development dependency. -pytest-cov = { version = "*", optional = true } # Development dependency. -pytest-xdist = { version = "*", optional = true} #Development dependency -pyupgrade = { version = "*", optional = true } # Development dependency. -restructuredtext-lint = { version = "*", optional = true } # Development dependency. -sphinx = { version = ">= 4, < 5", optional = true } # Development dependency. -sphinxcontrib-bibtex = { version = "*", optional = true } # Development dependency. -toml = { version = "*", optional = true } # Development dependency. -twine = { version = "*", optional = true } # Development dependency. - -[tool.poetry.dev-dependencies] -biblib-simple = "*" +[tool.poetry.group.dev.dependencies] black = "*" blackdoc = "*" coverage = "!= 6.3" coveralls = "*" -flake8 = "*" flynt = "*" invoke = "*" -mypy = "*" +jupyter = "*" pre-commit = "*" +pyright = "*" pytest = "*" -pydata-sphinx-theme = "*" -pydocstyle = "*" pytest-cov = "*" pytest-xdist = "*" -pyupgrade = "*" -restructuredtext-lint = "*" -sphinx = ">= 4, < 5" -sphinxcontrib-bibtex = "*" +ruff = "*" toml = "*" twine = "*" -[tool.poetry.extras] -development = [ - "biblib-simple", - "black", - "blackdoc", - "coverage", - "coveralls", - "flake8", - "flynt", - "invoke", - "mypy", - "pre-commit", - "pydata-sphinx-theme", - "pydocstyle", - "pytest", - "pytest-cov", - "pyupgrade", - "restructuredtext-lint", - "sphinx", - "sphinxcontrib-bibtex", - "toml", - "twine", -] -read-the-docs = [ "pydata-sphinx-theme", "sphinxcontrib-bibtex" ] +[tool.poetry.group.docs.dependencies] +biblib-simple = "*" +pydata-sphinx-theme = "*" +restructuredtext-lint = "*" +sphinx = ">= 4, < 5" +sphinxcontrib-bibtex = "*" [tool.black] line-length = 79 exclude = ''' /( \.git - | \.mypy_cache | build | dist )/ @@ -138,17 +91,110 @@ exclude = ''' [tool.flynt] line_length=999 -[tool.mypy] -plugins = "numpy.typing.mypy_plugin" -ignore_missing_imports = true - -[tool.pydocstyle] -convention = "numpy" -add-ignore = "D104,D200,D202,D205,D301,D400" +[tool.pyright] +reportMissingImports = false +reportMissingModuleSource = false +reportUnboundVariable = false +reportUnnecessaryCast = true +reportUnnecessaryTypeIgnoreComment = true +reportUnsupportedDunderAll = false +reportUnusedExpression = false [tool.pytest.ini_options] addopts = "--durations=5" +[tool.ruff] +target-version = "py39" +line-length = 88 +select = [ + "A", # flake8-builtins + "ARG", # flake8-unused-arguments + # "ANN", # flake8-annotations + "B", # flake8-bugbear + # "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + # "C90", # mccabe + # "COM", # flake8-commas + "DTZ", # flake8-datetimez + "D", # pydocstyle + "E", # pydocstyle + # "ERA", # eradicate + # "EM", # flake8-errmsg + "EXE", # flake8-executable + "F", # flake8 + # "FBT", # flake8-boolean-trap + "G", # flake8-logging-format + "I", # isort + "ICN", # flake8-import-conventions + "INP", # flake8-no-pep420 + "ISC", # flake8-implicit-str-concat + "N", # pep8-naming + # "PD", # pandas-vet + "PIE", # flake8-pie + "PGH", # pygrep-hooks + "PL", # pylint + # "PT", # flake8-pytest-style + # "PTH", # flake8-use-pathlib [Enable] + "Q", # flake8-quotes + "RET", # flake8-return + "RUF", # Ruff + "S", # flake8-bandit + "SIM", # flake8-simplify + "T10", # flake8-debugger + "T20", # flake8-print + # "TCH", # flake8-type-checking + "TID", # flake8-tidy-imports + "TRY", # tryceratops + "UP", # pyupgrade + "W", # pydocstyle + "YTT" # flake8-2020 +] +ignore = [ + "B008", + "B905", + "D104", + "D200", + "D202", + "D205", + "D301", + "D400", + "I001", + "N801", + "N802", + "N803", + "N806", + "N813", + "N815", + "N816", + "PGH003", + "PIE804", + "PLE0605", + "PLR0911", + "PLR0912", + "PLR0913", + "PLR0915", + "PLR2004", + "RET504", + "RET505", + "RET506", + "RET507", + "RET508", + "TRY003", + "TRY300", +] +typing-modules = ["colour.hints"] +fixable = ["B", "C", "E", "F", "PIE", "RUF", "SIM", "UP", "W"] + +[tool.ruff.pydocstyle] +convention = "numpy" + +[tool.ruff.per-file-ignores] +"colour_datasets/examples/*" = ["INP", "T201", "T203"] +"docs/*" = ["INP"] +"tasks.py" = ["INP"] +"utilities/*" = ["EXE001", "INP"] +"utilities/unicode_to_ascii.py" = ["RUF001"] + [build-system] requires = [ "poetry_core>=1.0.0" ] build-backend = "poetry.core.masonry.api" diff --git a/requirements.txt b/requirements.txt index 258cfbb..cf5a179 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,99 +1,177 @@ -alabaster==0.7.12 -astor==0.8.1 -attrs==22.1.0 -Babel==2.11.0 -beautifulsoup4==4.11.1 -biblib-simple==0.1.2 -black==22.10.0 -blackdoc==0.3.8 -bleach==5.0.1 -cachetools==5.2.0 -certifi==2022.9.24 -cfgv==3.3.1 -charset-normalizer==2.1.1 -click==8.1.3 -colour-science==0.4.2 -commonmark==0.9.1 -coverage==6.5.0 -coveralls==3.3.1 -distlib==0.3.6 -docopt==0.6.2 -docutils==0.17.1 -execnet==1.9.0 -filelock==3.8.0 -flake8==6.0.0 -flynt==0.77 -identify==2.5.9 -idna==3.4 -imageio==2.22.4 -imagesize==1.4.1 -importlib-metadata==5.1.0 -iniconfig==1.1.1 -invoke==1.7.3 -jaraco.classes==3.2.3 -Jinja2==3.1.2 -keyring==23.11.0 -latexcodec==2.0.1 -MarkupSafe==2.1.1 -mccabe==0.7.0 -more-itertools==9.0.0 -mypy==0.991 -mypy-extensions==0.4.3 -nodeenv==1.7.0 -numpy==1.23.5 -opencv-python==4.6.0.66 -packaging==21.3 -pathspec==0.10.2 -Pillow==9.3.0 -pip==22.3.1 -pkginfo==1.9.2 -platformdirs==2.5.4 -pluggy==1.0.0 -pre-commit==2.20.0 -pybtex==0.24.0 -pybtex-docutils==1.0.2 -pycodestyle==2.10.0 -pydata-sphinx-theme==0.12.0 -pydocstyle==6.1.1 -pyflakes==3.0.1 -Pygments==2.13.0 -pyparsing==3.0.9 -pytest==7.2.0 -pytest-cov==4.0.0 -pytest-xdist==3.1.0 -pytz==2022.6 -pyupgrade==3.3.0 -PyYAML==6.0 -readme-renderer==37.3 -requests==2.28.1 -requests-toolbelt==0.10.1 -restructuredtext-lint==1.4.0 -rfc3986==2.0.0 -rich==12.6.0 -scipy==1.9.3 -setuptools==65.6.3 -six==1.16.0 -snowballstemmer==2.2.0 -soupsieve==2.3.2.post1 -Sphinx==4.5.0 -sphinxcontrib-applehelp==1.0.2 -sphinxcontrib-bibtex==2.5.0 -sphinxcontrib-devhelp==1.0.2 -sphinxcontrib-htmlhelp==2.0.0 -sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.3 -sphinxcontrib-serializinghtml==1.1.5 -tokenize-rt==5.0.0 -toml==0.10.2 -tomli==2.0.1 -tqdm==4.64.1 -twine==4.0.2 -types-cachetools==5.2.1 -types-setuptools==65.6.0.1 -typing_extensions==4.4.0 -urllib3==1.26.13 -virtualenv==20.17.0 -webencodings==0.5.1 -wheel==0.38.4 -xlrd==1.2.0 -zipp==3.11.0 +accessible-pygments==0.0.4 ; python_version >= "3.9" and python_version < "3.12" +alabaster==0.7.13 ; python_version >= "3.9" and python_version < "3.12" +anyio==3.7.1 ; python_version >= "3.9" and python_version < "3.12" +appnope==0.1.3 ; python_version >= "3.9" and python_version < "3.12" and (platform_system == "Darwin" or sys_platform == "darwin") +argon2-cffi-bindings==21.2.0 ; python_version >= "3.9" and python_version < "3.12" +argon2-cffi==23.1.0 ; python_version >= "3.9" and python_version < "3.12" +arrow==1.2.3 ; python_version >= "3.9" and python_version < "3.12" +astor==0.8.1 ; python_version >= "3.9" and python_version < "3.12" +asttokens==2.2.1 ; python_version >= "3.9" and python_version < "3.12" +async-lru==2.0.4 ; python_version >= "3.9" and python_version < "3.12" +attrs==23.1.0 ; python_version >= "3.9" and python_version < "3.12" +babel==2.12.1 ; python_version >= "3.9" and python_version < "3.12" +backcall==0.2.0 ; python_version >= "3.9" and python_version < "3.12" +beautifulsoup4==4.12.2 ; python_version >= "3.9" and python_version < "3.12" +biblib-simple==0.1.2 ; python_version >= "3.9" and python_version < "3.12" +black==23.7.0 ; python_version >= "3.9" and python_version < "3.12" +blackdoc==0.3.8 ; python_version >= "3.9" and python_version < "3.12" +bleach==6.0.0 ; python_version >= "3.9" and python_version < "3.12" +cachetools==5.3.1 ; python_version >= "3.9" and python_version < "3.12" +certifi==2023.7.22 ; python_version >= "3.9" and python_version < "3.12" +cffi==1.15.1 ; python_version >= "3.9" and python_version < "3.12" +cfgv==3.4.0 ; python_version >= "3.9" and python_version < "3.12" +charset-normalizer==3.2.0 ; python_version >= "3.9" and python_version < "3.12" +click==8.1.7 ; python_version >= "3.9" and python_version < "3.12" +colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.12" and (platform_system == "Windows" or sys_platform == "win32") +colour-science==0.4.3 ; python_version >= "3.9" and python_version < "3.12" +comm==0.1.4 ; python_version >= "3.9" and python_version < "3.12" +coverage==6.5.0 ; python_version >= "3.9" and python_version < "3.12" +coverage[toml]==6.5.0 ; python_version >= "3.9" and python_version < "3.12" +coveralls==3.3.1 ; python_version >= "3.9" and python_version < "3.12" +cryptography==41.0.3 ; python_version >= "3.9" and python_version < "3.12" and sys_platform == "linux" +debugpy==1.6.7.post1 ; python_version >= "3.9" and python_version < "3.12" +decorator==5.1.1 ; python_version >= "3.9" and python_version < "3.12" +defusedxml==0.7.1 ; python_version >= "3.9" and python_version < "3.12" +distlib==0.3.7 ; python_version >= "3.9" and python_version < "3.12" +docopt==0.6.2 ; python_version >= "3.9" and python_version < "3.12" +docutils==0.17.1 ; python_version >= "3.9" and python_version < "3.12" +exceptiongroup==1.1.3 ; python_version >= "3.9" and python_version < "3.11" +execnet==2.0.2 ; python_version >= "3.9" and python_version < "3.12" +executing==1.2.0 ; python_version >= "3.9" and python_version < "3.12" +fastjsonschema==2.18.0 ; python_version >= "3.9" and python_version < "3.12" +filelock==3.12.3 ; python_version >= "3.9" and python_version < "3.12" +flynt==1.0.1 ; python_version >= "3.9" and python_version < "3.12" +fqdn==1.5.1 ; python_version >= "3.9" and python_version < "3.12" +identify==2.5.27 ; python_version >= "3.9" and python_version < "3.12" +idna==3.4 ; python_version >= "3.9" and python_version < "3.12" +imageio==2.31.2 ; python_version >= "3.9" and python_version < "3.12" +imagesize==1.4.1 ; python_version >= "3.9" and python_version < "3.12" +importlib-metadata==6.8.0 ; python_version >= "3.9" and python_version < "3.12" +iniconfig==2.0.0 ; python_version >= "3.9" and python_version < "3.12" +invoke==2.2.0 ; python_version >= "3.9" and python_version < "3.12" +ipykernel==6.25.1 ; python_version >= "3.9" and python_version < "3.12" +ipython-genutils==0.2.0 ; python_version >= "3.9" and python_version < "3.12" +ipython==8.14.0 ; python_version >= "3.9" and python_version < "3.12" +ipywidgets==8.1.0 ; python_version >= "3.9" and python_version < "3.12" +isoduration==20.11.0 ; python_version >= "3.9" and python_version < "3.12" +jaraco-classes==3.3.0 ; python_version >= "3.9" and python_version < "3.12" +jedi==0.19.0 ; python_version >= "3.9" and python_version < "3.12" +jeepney==0.8.0 ; python_version >= "3.9" and python_version < "3.12" and sys_platform == "linux" +jinja2==3.1.2 ; python_version >= "3.9" and python_version < "3.12" +json5==0.9.14 ; python_version >= "3.9" and python_version < "3.12" +jsonpointer==2.4 ; python_version >= "3.9" and python_version < "3.12" +jsonschema-specifications==2023.7.1 ; python_version >= "3.9" and python_version < "3.12" +jsonschema==4.19.0 ; python_version >= "3.9" and python_version < "3.12" +jsonschema[format-nongpl]==4.19.0 ; python_version >= "3.9" and python_version < "3.12" +jupyter-client==8.3.1 ; python_version >= "3.9" and python_version < "3.12" +jupyter-console==6.6.3 ; python_version >= "3.9" and python_version < "3.12" +jupyter-core==5.3.1 ; python_version >= "3.9" and python_version < "3.12" +jupyter-events==0.7.0 ; python_version >= "3.9" and python_version < "3.12" +jupyter-lsp==2.2.0 ; python_version >= "3.9" and python_version < "3.12" +jupyter-server-terminals==0.4.4 ; python_version >= "3.9" and python_version < "3.12" +jupyter-server==2.7.2 ; python_version >= "3.9" and python_version < "3.12" +jupyter==1.0.0 ; python_version >= "3.9" and python_version < "3.12" +jupyterlab-pygments==0.2.2 ; python_version >= "3.9" and python_version < "3.12" +jupyterlab-server==2.24.0 ; python_version >= "3.9" and python_version < "3.12" +jupyterlab-widgets==3.0.8 ; python_version >= "3.9" and python_version < "3.12" +jupyterlab==4.0.5 ; python_version >= "3.9" and python_version < "3.12" +keyring==24.2.0 ; python_version >= "3.9" and python_version < "3.12" +latexcodec==2.0.1 ; python_version >= "3.9" and python_version < "3.12" +markdown-it-py==3.0.0 ; python_version >= "3.9" and python_version < "3.12" +markupsafe==2.1.3 ; python_version >= "3.9" and python_version < "3.12" +matplotlib-inline==0.1.6 ; python_version >= "3.9" and python_version < "3.12" +mdurl==0.1.2 ; python_version >= "3.9" and python_version < "3.12" +mistune==3.0.1 ; python_version >= "3.9" and python_version < "3.12" +more-itertools==10.1.0 ; python_version >= "3.9" and python_version < "3.12" +mypy-extensions==1.0.0 ; python_version >= "3.9" and python_version < "3.12" +nbclient==0.8.0 ; python_version >= "3.9" and python_version < "3.12" +nbconvert==7.8.0 ; python_version >= "3.9" and python_version < "3.12" +nbformat==5.9.2 ; python_version >= "3.9" and python_version < "3.12" +nest-asyncio==1.5.7 ; python_version >= "3.9" and python_version < "3.12" +nodeenv==1.8.0 ; python_version >= "3.9" and python_version < "3.12" +notebook-shim==0.2.3 ; python_version >= "3.9" and python_version < "3.12" +notebook==7.0.2 ; python_version >= "3.9" and python_version < "3.12" +numpy==1.25.2 ; python_version >= "3.9" and python_version < "3.12" +opencv-python==4.8.0.76 ; python_version >= "3.9" and python_version < "3.12" +overrides==7.4.0 ; python_version >= "3.9" and python_version < "3.12" +packaging==23.1 ; python_version >= "3.9" and python_version < "3.12" +pandocfilters==1.5.0 ; python_version >= "3.9" and python_version < "3.12" +parso==0.8.3 ; python_version >= "3.9" and python_version < "3.12" +pathspec==0.11.2 ; python_version >= "3.9" and python_version < "3.12" +pexpect==4.8.0 ; python_version >= "3.9" and python_version < "3.12" and sys_platform != "win32" +pickleshare==0.7.5 ; python_version >= "3.9" and python_version < "3.12" +pillow==10.0.0 ; python_version >= "3.9" and python_version < "3.12" +pkginfo==1.9.6 ; python_version >= "3.9" and python_version < "3.12" +platformdirs==3.10.0 ; python_version >= "3.9" and python_version < "3.12" +pluggy==1.3.0 ; python_version >= "3.9" and python_version < "3.12" +pre-commit==3.3.3 ; python_version >= "3.9" and python_version < "3.12" +prometheus-client==0.17.1 ; python_version >= "3.9" and python_version < "3.12" +prompt-toolkit==3.0.39 ; python_version >= "3.9" and python_version < "3.12" +psutil==5.9.5 ; python_version >= "3.9" and python_version < "3.12" +ptyprocess==0.7.0 ; python_version >= "3.9" and python_version < "3.12" and (sys_platform != "win32" or os_name != "nt") +pure-eval==0.2.2 ; python_version >= "3.9" and python_version < "3.12" +pybtex-docutils==1.0.3 ; python_version >= "3.9" and python_version < "3.12" +pybtex==0.24.0 ; python_version >= "3.9" and python_version < "3.12" +pycparser==2.21 ; python_version >= "3.9" and python_version < "3.12" +pydata-sphinx-theme==0.13.3 ; python_version >= "3.9" and python_version < "3.12" +pygments==2.16.1 ; python_version >= "3.9" and python_version < "3.12" +pyright==1.1.324 ; python_version >= "3.9" and python_version < "3.12" +pytest-cov==4.1.0 ; python_version >= "3.9" and python_version < "3.12" +pytest-xdist==3.3.1 ; python_version >= "3.9" and python_version < "3.12" +pytest==7.4.0 ; python_version >= "3.9" and python_version < "3.12" +python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "3.12" +python-json-logger==2.0.7 ; python_version >= "3.9" and python_version < "3.12" +pywin32-ctypes==0.2.2 ; python_version >= "3.9" and python_version < "3.12" and sys_platform == "win32" +pywin32==306 ; sys_platform == "win32" and platform_python_implementation != "PyPy" and python_version >= "3.9" and python_version < "3.12" +pywinpty==2.0.11 ; python_version >= "3.9" and python_version < "3.12" and os_name == "nt" +pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "3.12" +pyzmq==25.1.1 ; python_version >= "3.9" and python_version < "3.12" +qtconsole==5.4.3 ; python_version >= "3.9" and python_version < "3.12" +qtpy==2.4.0 ; python_version >= "3.9" and python_version < "3.12" +readme-renderer==41.0 ; python_version >= "3.9" and python_version < "3.12" +referencing==0.30.2 ; python_version >= "3.9" and python_version < "3.12" +requests-toolbelt==1.0.0 ; python_version >= "3.9" and python_version < "3.12" +requests==2.31.0 ; python_version >= "3.9" and python_version < "3.12" +restructuredtext-lint==1.4.0 ; python_version >= "3.9" and python_version < "3.12" +rfc3339-validator==0.1.4 ; python_version >= "3.9" and python_version < "3.12" +rfc3986-validator==0.1.1 ; python_version >= "3.9" and python_version < "3.12" +rfc3986==2.0.0 ; python_version >= "3.9" and python_version < "3.12" +rich==13.5.2 ; python_version >= "3.9" and python_version < "3.12" +rpds-py==0.10.0 ; python_version >= "3.9" and python_version < "3.12" +ruff==0.0.286 ; python_version >= "3.9" and python_version < "3.12" +scipy==1.11.2 ; python_version >= "3.9" and python_version < "3.12" +secretstorage==3.3.3 ; python_version >= "3.9" and python_version < "3.12" and sys_platform == "linux" +send2trash==1.8.2 ; python_version >= "3.9" and python_version < "3.12" +setuptools==68.1.2 ; python_version >= "3.9" and python_version < "3.12" +six==1.16.0 ; python_version >= "3.9" and python_version < "3.12" +sniffio==1.3.0 ; python_version >= "3.9" and python_version < "3.12" +snowballstemmer==2.2.0 ; python_version >= "3.9" and python_version < "3.12" +soupsieve==2.4.1 ; python_version >= "3.9" and python_version < "3.12" +sphinx==4.5.0 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-applehelp==1.0.4 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-bibtex==2.6.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-devhelp==1.0.2 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-htmlhelp==2.0.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-jsmath==1.0.1 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-qthelp==1.0.3 ; python_version >= "3.9" and python_version < "3.12" +sphinxcontrib-serializinghtml==1.1.5 ; python_version >= "3.9" and python_version < "3.12" +stack-data==0.6.2 ; python_version >= "3.9" and python_version < "3.12" +terminado==0.17.1 ; python_version >= "3.9" and python_version < "3.12" +tinycss2==1.2.1 ; python_version >= "3.9" and python_version < "3.12" +toml==0.10.2 ; python_version >= "3.9" and python_version < "3.12" +tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.12" +tornado==6.3.3 ; python_version >= "3.9" and python_version < "3.12" +tqdm==4.66.1 ; python_version >= "3.9" and python_version < "3.12" +traitlets==5.9.0 ; python_version >= "3.9" and python_version < "3.12" +twine==4.0.2 ; python_version >= "3.9" and python_version < "3.12" +typing-extensions==4.7.1 ; python_version >= "3.9" and python_version < "3.12" +uri-template==1.3.0 ; python_version >= "3.9" and python_version < "3.12" +urllib3==2.0.4 ; python_version >= "3.9" and python_version < "3.12" +virtualenv==20.24.3 ; python_version >= "3.9" and python_version < "3.12" +wcwidth==0.2.6 ; python_version >= "3.9" and python_version < "3.12" +webcolors==1.13 ; python_version >= "3.9" and python_version < "3.12" +webencodings==0.5.1 ; python_version >= "3.9" and python_version < "3.12" +websocket-client==1.6.2 ; python_version >= "3.9" and python_version < "3.12" +widgetsnbextension==4.0.8 ; python_version >= "3.9" and python_version < "3.12" +xlrd==1.2.0 ; python_version >= "3.9" and python_version < "3.12" +zipp==3.16.2 ; python_version >= "3.9" and python_version < "3.12" diff --git a/setup.py b/setup.py deleted file mode 100644 index 37ed046..0000000 --- a/setup.py +++ /dev/null @@ -1,79 +0,0 @@ -""" -Colour - Datasets - Setup -========================= -""" - -import codecs -from setuptools import setup - -packages = [ - "colour_datasets", - "colour_datasets.examples", - "colour_datasets.loaders", - "colour_datasets.loaders.tests", - "colour_datasets.records", - "colour_datasets.records.tests", - "colour_datasets.utilities", - "colour_datasets.utilities.tests", -] - -package_data = { - "": ["*"], - "colour_datasets.loaders.tests": ["resources/*"], - "colour_datasets.utilities.tests": ["resources/*"], -} - -install_requires = [ - "cachetools", - "colour-science>=0.4.2", - "imageio>=2,<3", - "numpy>=1.20,<2", - "opencv-python>=4,<5", - "scipy>=1.7,<2", - "tqdm", - "typing-extensions>=4,<5", - "xlrd>=1.2,<2", -] - -extras_require = { - "development": [ - "biblib-simple", - "black", - "blackdoc", - "coverage!=6.3", - "coveralls", - "flake8", - "flynt", - "invoke", - "mypy", - "pre-commit", - "pydata-sphinx-theme", - "pydocstyle", - "pytest", - "pytest-cov", - "pyupgrade", - "restructuredtext-lint", - "sphinx>=4,<5", - "sphinxcontrib-bibtex", - "toml", - "twine", - ], - "read-the-docs": ["pydata-sphinx-theme", "sphinxcontrib-bibtex"], -} - -setup( - name="colour-datasets", - version="0.2.1", - description="Colour science datasets for use with Colour", - long_description=codecs.open("README.rst", encoding="utf8").read(), - author="Colour Developers", - author_email="colour-developers@colour-science.org", - maintainer="Colour Developers", - maintainer_email="colour-developers@colour-science.org", - url="https://www.colour-science.org/", - packages=packages, - package_data=package_data, - install_requires=install_requires, - extras_require=extras_require, - python_requires=">=3.9,<3.12", -) diff --git a/tasks.py b/tasks.py index 1bf592d..9073053 100644 --- a/tasks.py +++ b/tasks.py @@ -6,25 +6,26 @@ from __future__ import annotations import biblib.bib +import contextlib import fnmatch import os import re import uuid import colour_datasets -from colour.hints import Boolean from colour.utilities import message_box import inspect if not hasattr(inspect, "getargspec"): - inspect.getargspec = inspect.getfullargspec + inspect.getargspec = inspect.getfullargspec # pyright: ignore -from invoke import Context, task +from invoke.tasks import task +from invoke.context import Context __author__ = "Colour Developers" __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -68,10 +69,9 @@ @task def clean( ctx: Context, - docs: Boolean = True, - bytecode: Boolean = False, - mypy: Boolean = True, - pytest: Boolean = True, + docs: bool = True, + bytecode: bool = False, + pytest: bool = True, ): """ Clean the project. @@ -84,8 +84,6 @@ def clean( Whether to clean the *docs* directory. bytecode Whether to clean the bytecode files, e.g. *.pyc* files. - mypy - Whether to clean the *Mypy* cache directory. pytest Whether to clean the *Pytest* cache directory. """ @@ -102,9 +100,6 @@ def clean( patterns.append("**/__pycache__") patterns.append("**/*.pyc") - if mypy: - patterns.append(".mypy_cache") - if pytest: patterns.append(".pytest_cache") @@ -115,8 +110,8 @@ def clean( @task def formatting( ctx: Context, - asciify: Boolean = True, - bibtex: Boolean = True, + asciify: bool = True, + bibtex: bool = True, ): """ Convert unicode characters to ASCII and cleanup the *BibTeX* file. @@ -145,10 +140,8 @@ def formatting( ) for entry in sorted(entries.values(), key=lambda x: x.key): - try: + with contextlib.suppress(KeyError): del entry["file"] - except KeyError: - pass for key, value in entry.items(): entry[key] = re.sub("(? requirements.txt" + "poetry export -f requirements.txt " + "--without-hashes " + "--with dev,docs " + "--output requirements.txt" + ) + + message_box('Exporting "docs/requirements.txt" file...') + ctx.run( + "poetry export -f requirements.txt " + "--without-hashes " + "--with docs " + "--output docs/requirements.txt" ) @@ -346,68 +338,11 @@ def build(ctx: Context): message_box("Building...") ctx.run("poetry build") - - with ctx.cd("dist"): - ctx.run(f"tar -xvf {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION}.tar.gz") - ctx.run(f"cp {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION}/setup.py ../") - - ctx.run(f"rm -rf {PYPI_ARCHIVE_NAME}-{APPLICATION_VERSION}") - - with open("setup.py") as setup_file: - source = setup_file.read() - - setup_kwargs = [] - - def sub_callable(match): - setup_kwargs.append(match) - - return "" - - template = """ -setup({0} -) -""" - - source = re.sub( - "from setuptools import setup", - ( - '"""\n' - "Colour - Datasets - Setup\n" - "=========================\n" - '"""\n\n' - "import codecs\n" - "from setuptools import setup" - ), - source, - ) - source = re.sub( - "setup_kwargs = {(.*)}.*setup\\(\\*\\*setup_kwargs\\)", - sub_callable, - source, - flags=re.DOTALL, - )[:-2] - setup_kwargs = setup_kwargs[0].group(1).splitlines() - for i, line in enumerate(setup_kwargs): - setup_kwargs[i] = re.sub("^\\s*('(\\w+)':\\s?)", " \\2=", line) - if setup_kwargs[i].strip().startswith("long_description"): - setup_kwargs[i] = ( - " long_description=" - "codecs.open('README.rst', encoding='utf8')" - ".read()," - ) - - source += template.format("\n".join(setup_kwargs)) - - with open("setup.py", "w") as setup_file: - setup_file.write(source) - - ctx.run("poetry run pre-commit run --files setup.py || true") - ctx.run("twine check dist/*") @task -def virtualise(ctx: Context, tests: Boolean = True): +def virtualise(ctx: Context, tests: bool = True): """ Create a virtual environment for the project build. @@ -429,7 +364,6 @@ def virtualise(ctx: Context, tests: Boolean = True): if tests: ctx.run( "poetry run pytest " - "--disable-warnings " "--doctest-modules " f"--ignore={PYTHON_PACKAGE_NAME}/examples " f"{PYTHON_PACKAGE_NAME}", @@ -450,42 +384,42 @@ def tag(ctx: Context): message_box("Tagging...") result = ctx.run("git rev-parse --abbrev-ref HEAD", hide="both") - assert ( - result.stdout.strip() == "develop" - ), "Are you still on a feature or master branch?" + if result.stdout.strip() != "develop": # pyright: ignore + raise RuntimeError("Are you still on a feature or master branch?") with open(os.path.join(PYTHON_PACKAGE_NAME, "__init__.py")) as file_handle: file_content = file_handle.read() major_version = re.search( '__major_version__\\s+=\\s+"(.*)"', file_content - ).group( # type: ignore[union-attr] + ).group( # pyright: ignore 1 ) minor_version = re.search( '__minor_version__\\s+=\\s+"(.*)"', file_content - ).group( # type: ignore[union-attr] + ).group( # pyright: ignore 1 ) change_version = re.search( '__change_version__\\s+=\\s+"(.*)"', file_content - ).group( # type: ignore[union-attr] + ).group( # pyright: ignore 1 ) version = ".".join((major_version, minor_version, change_version)) result = ctx.run("git ls-remote --tags upstream", hide="both") - remote_tags = result.stdout.strip().split("\n") + remote_tags = result.stdout.strip().split("\n") # pyright: ignore tags = set() for remote_tag in remote_tags: tags.add( remote_tag.split("refs/tags/")[1].replace("refs/tags/", "^{}") ) - tags = sorted(list(tags)) - assert f"v{version}" not in tags, ( - f'A "{PYTHON_PACKAGE_NAME}" "v{version}" tag already exists in ' - f"remote repository!" - ) + version_tags = sorted(tags) + if f"v{version}" in version_tags: + raise RuntimeError( + f'A "{PYTHON_PACKAGE_NAME}" "v{version}" tag already exists in ' + f"remote repository!" + ) ctx.run(f"git flow release start v{version}") ctx.run(f"git flow release finish v{version}") diff --git a/utilities/export_todo.py b/utilities/export_todo.py index 50c121c..89df55e 100755 --- a/utilities/export_todo.py +++ b/utilities/export_todo.py @@ -10,7 +10,7 @@ import os __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -34,9 +34,9 @@ ----- | **Colour - Datasets** by Colour Developers -| Copyright 2019 Colour Developers – \ +| Copyright 2019 Colour Developers - \ `colour-developers@colour-science.org `__ -| This software is released under terms of New BSD License: \ +| This software is released under terms of BSD-3-Clause: \ https://opensource.org/licenses/BSD-3-Clause | `https://github.com/colour-science/colour-datasets \ `__ @@ -66,7 +66,7 @@ def extract_todo_items(root_directory: str) -> dict: if not filename.endswith(".py"): continue - filename = os.path.join(root, filename) + filename = os.path.join(root, filename) # noqa: PLW2901 with codecs.open(filename, encoding="utf8") as file_handle: content = file_handle.readlines() @@ -74,7 +74,7 @@ def extract_todo_items(root_directory: str) -> dict: line_number = 1 todo_item = [] for i, line in enumerate(content): - line = line.strip() + line = line.strip() # noqa: PLW2901 if line.startswith("# TODO:"): in_todo = True line_number = i + 1 @@ -108,9 +108,9 @@ def export_todo_items(todo_items: dict, file_path: str): """ todo_rst = [] - for module, todo_items in todo_items.items(): + for module, module_todo_items in todo_items.items(): todo_rst.append(f"- {module}\n") - for line_numer, todo_item in todo_items: + for line_numer, todo_item in module_todo_items: todo_rst.append(f" - Line {line_numer} : {todo_item}") todo_rst.append("\n") @@ -120,6 +120,8 @@ def export_todo_items(todo_items: dict, file_path: str): if __name__ == "__main__": + os.chdir(os.path.dirname(__file__)) + export_todo_items( extract_todo_items(os.path.join("..", "colour_checker_detection")), os.path.join("..", "TODO.rst"), diff --git a/utilities/unicode_to_ascii.py b/utilities/unicode_to_ascii.py index 072163f..0fb9fea 100755 --- a/utilities/unicode_to_ascii.py +++ b/utilities/unicode_to_ascii.py @@ -11,7 +11,7 @@ import unicodedata __copyright__ = "Copyright 2019 Colour Developers" -__license__ = "New BSD License - https://opensource.org/licenses/BSD-3-Clause" +__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause" __maintainer__ = "Colour Developers" __email__ = "colour-developers@colour-science.org" __status__ = "Production" @@ -52,7 +52,7 @@ def unicode_to_ascii(root_directory: str): if filename == "unicode_to_ascii.py": continue - filename = os.path.join(root, filename) + filename = os.path.join(root, filename) # noqa: PLW2901 with codecs.open(filename, encoding="utf8") as file_handle: content = file_handle.read() @@ -66,4 +66,6 @@ def unicode_to_ascii(root_directory: str): if __name__ == "__main__": + os.chdir(os.path.dirname(__file__)) + unicode_to_ascii(os.path.join("..", "colour_checker_detection"))