Skip to content

Commit

Permalink
Merge branch 'feature/v0.2.8' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 24, 2024
2 parents 37c3e80 + 06f43bb commit aa4ae7b
Show file tree
Hide file tree
Showing 58 changed files with 683 additions and 617 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ sigterm = True
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
if TYPE_CHECKING:
pass
29 changes: 17 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
# Common Files
*.egg-info
*.pyc
*.pyo
.DS_Store
.coverage*
.fleet
.idea
.ipynb_checkpoints
uv.lock

# Common Directories
.fleet/
.idea/
.ipynb_checkpoints/
.python-version
.sandbox
.vs
.vscode
.vs/
.vscode/
.sandbox/
build/
dist/
docs/_build/
docs/generated/
node_modules/
references/

__pycache__

build
dist
docs/_build
docs/generated
references
# Project Directories
zenodo
uv.lock
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.5.0"
rev: "v5.0.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -15,32 +15,29 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
rev: v2.3.0
hooks:
- id: codespell
args: ["--ignore-words-list=exitance,seperately"]
args:
["--ignore-words-list=assertIn,exitance,seperately,socio-economic"]
exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst"
- repo: https://github.com/ikamensh/flynt
rev: "1.0.1"
hooks:
- id: flynt
args: [--verbose]
- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.14"
rev: "v0.8.2"
hooks:
- id: ruff-format
- id: ruff
args: [--fix]
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
rev: 1.19.1
hooks:
- id: blacken-docs
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
rev: "v4.0.0-alpha.8"
hooks:
- id: prettier
- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ The *Colour Developers* can be reached via different means:
- `Facebook <https://www.facebook.com/python.colour.science>`__
- `Github Discussions <https://github.com/colour-science/colour-datasets/discussions>`__
- `Gitter <https://gitter.im/colour-science/colour>`__
- `Twitter <https://twitter.com/colour_science>`__
- `X <https://x.com/colour_science>`__
- `Bluesky <https://bsky.app/profile/colour-science.bsky.social>`__

About
-----
Expand Down
12 changes: 8 additions & 4 deletions colour_datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- utilities: Various utilities.
"""

# isort: skip_file

from __future__ import annotations

import contextlib
import os
import subprocess
Expand Down Expand Up @@ -52,19 +56,19 @@
__major_version__ = "0"
__minor_version__ = "2"
__change_version__ = "6"
__version__ = ".".join((__major_version__, __minor_version__, __change_version__))
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"

try:
_version = (
subprocess.check_output(
["git", "describe"], # noqa: S603, S607
subprocess.check_output( # noqa: S603
["git", "describe"], # noqa: S607
cwd=os.path.dirname(__file__),
stderr=subprocess.STDOUT,
)
.strip()
.decode("utf-8")
)
except Exception:
except Exception: # noqa: BLE001
_version = __version__

colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-datasets"] = _version # pyright: ignore
Expand Down
7 changes: 6 additions & 1 deletion colour_datasets/loaders/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# isort: skip_file

from __future__ import annotations

import sys
import typing

if typing.TYPE_CHECKING:
from colour.hints import Any

from colour.hints import Any
from colour.utilities import CanonicalMapping, warning

from colour_datasets.records import datasets
Expand Down
8 changes: 5 additions & 3 deletions colour_datasets/loaders/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@

from __future__ import annotations

import typing
from abc import ABC, abstractmethod

from colour.hints import Any
if typing.TYPE_CHECKING:
from colour.hints import Any

from colour_datasets.records import Record
from colour_datasets.records import Record

__author__ = "Colour Developers"
__copyright__ = "Copyright 2019 Colour Developers"
Expand Down Expand Up @@ -122,7 +124,7 @@ def load(self) -> Any:
when they implement it, e.g., ``super().sync()``.
"""

def sync(self):
def sync(self) -> None:
"""
Sync the dataset content, i.e., checks whether it is synced and pulls
it if required.
Expand Down
46 changes: 19 additions & 27 deletions colour_datasets/loaders/asano2015.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from __future__ import annotations

import os
from collections import namedtuple
import typing
from dataclasses import dataclass, field

import numpy as np
import xlrd
Expand All @@ -26,7 +27,10 @@
LMS_ConeFundamentals,
XYZ_ColourMatchingFunctions,
)
from colour.hints import Dict, NDArrayFloat

if typing.TYPE_CHECKING:
from colour.hints import Dict

from colour.utilities import as_float_array, tstack

from colour_datasets.loaders import AbstractDatasetLoader
Expand All @@ -47,12 +51,8 @@
]


class Specification_Asano2015(
namedtuple(
"Specification_Asano2015",
("XYZ_2", "XYZ_10", "LMS_2", "LMS_10", "parameters", "others"),
)
):
@dataclass(frozen=True)
class Specification_Asano2015:
"""
Define the *Asano (2015)* specification for an observer.
Expand All @@ -74,24 +74,14 @@ class Specification_Asano2015(
References
----------
:cite:`Asano2015`
""" # noqa: D405, D407, D410, D411

def __new__(
cls,
XYZ_2: XYZ_ColourMatchingFunctions,
XYZ_10: XYZ_ColourMatchingFunctions,
LMS_2: LMS_ConeFundamentals,
LMS_10: LMS_ConeFundamentals,
parameters: NDArrayFloat,
others: Dict | None = None,
):
"""
Return a new instance of the
:class:`colour_datasets.loaders.asano2015.Specification_Asano2015`
class.
"""
"""

return super().__new__(cls, XYZ_2, XYZ_10, LMS_2, LMS_10, parameters, others)
XYZ_2: XYZ_ColourMatchingFunctions
XYZ_10: XYZ_ColourMatchingFunctions
LMS_2: LMS_ConeFundamentals
LMS_10: LMS_ConeFundamentals
parameters: Dict
others: Dict = field(default_factory=dict)


class DatasetLoader_Asano2015(AbstractDatasetLoader):
Expand Down Expand Up @@ -199,7 +189,7 @@ def load(self) -> Dict[str, Dict[int, Specification_Asano2015]]:
observer["LMS_2"],
observer["LMS_10"],
observer["parameters"],
dict(zip(header, values[i])),
dict(zip(header, values[i], strict=False)),
)

return self._content
Expand Down Expand Up @@ -284,7 +274,9 @@ def parse_workbook_Asano2015(

for i in range(observers[1]):
observer = i + 1
data[observer]["parameters"] = dict(zip(header, as_float_array(values[i])))
data[observer]["parameters"] = dict(
zip(header, as_float_array(values[i]), strict=False)
)

return data

Expand Down
6 changes: 5 additions & 1 deletion colour_datasets/loaders/brendel2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
from __future__ import annotations

import os
import typing

import numpy as np
from colour import LinearInterpolator, SpectralDistribution, SpectralShape
from colour.hints import Dict

if typing.TYPE_CHECKING:
from colour.hints import Dict

from colour.utilities import as_int

from colour_datasets.loaders import AbstractDatasetLoader
Expand Down
Loading

0 comments on commit aa4ae7b

Please sign in to comment.