Skip to content

Commit aa4ae7b

Browse files
committed
Merge branch 'feature/v0.2.8' into develop
2 parents 37c3e80 + 06f43bb commit aa4ae7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+683
-617
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ sigterm = True
55
exclude_lines =
66
pragma: no cover
77
if __name__ == .__main__.:
8+
if TYPE_CHECKING:
89
pass

.gitignore

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
# Common Files
12
*.egg-info
23
*.pyc
34
*.pyo
45
.DS_Store
56
.coverage*
6-
.fleet
7-
.idea
8-
.ipynb_checkpoints
7+
uv.lock
8+
9+
# Common Directories
10+
.fleet/
11+
.idea/
12+
.ipynb_checkpoints/
913
.python-version
10-
.sandbox
11-
.vs
12-
.vscode
14+
.vs/
15+
.vscode/
16+
.sandbox/
17+
build/
18+
dist/
19+
docs/_build/
20+
docs/generated/
21+
node_modules/
22+
references/
1323

1424
__pycache__
1525

16-
build
17-
dist
18-
docs/_build
19-
docs/generated
20-
references
26+
# Project Directories
2127
zenodo
22-
uv.lock

.pre-commit-config.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: "v4.5.0"
3+
rev: "v5.0.0"
44
hooks:
55
- id: check-added-large-files
66
- id: check-case-conflict
@@ -15,32 +15,29 @@ repos:
1515
- id: requirements-txt-fixer
1616
- id: trailing-whitespace
1717
- repo: https://github.com/codespell-project/codespell
18-
rev: v2.2.6
18+
rev: v2.3.0
1919
hooks:
2020
- id: codespell
21-
args: ["--ignore-words-list=exitance,seperately"]
21+
args:
22+
["--ignore-words-list=assertIn,exitance,seperately,socio-economic"]
2223
exclude: "BIBLIOGRAPHY.bib|CONTRIBUTORS.rst"
23-
- repo: https://github.com/ikamensh/flynt
24-
rev: "1.0.1"
25-
hooks:
26-
- id: flynt
27-
args: [--verbose]
2824
- repo: https://github.com/PyCQA/isort
2925
rev: "5.13.2"
3026
hooks:
3127
- id: isort
3228
- repo: https://github.com/astral-sh/ruff-pre-commit
33-
rev: "v0.1.14"
29+
rev: "v0.8.2"
3430
hooks:
3531
- id: ruff-format
3632
- id: ruff
33+
args: [--fix]
3734
- repo: https://github.com/adamchainz/blacken-docs
38-
rev: 1.16.0
35+
rev: 1.19.1
3936
hooks:
4037
- id: blacken-docs
4138
language_version: python3.10
4239
- repo: https://github.com/pre-commit/mirrors-prettier
43-
rev: "v3.1.0"
40+
rev: "v4.0.0-alpha.8"
4441
hooks:
4542
- id: prettier
4643
- repo: https://github.com/pre-commit/pygrep-hooks

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ The *Colour Developers* can be reached via different means:
217217
- `Facebook <https://www.facebook.com/python.colour.science>`__
218218
- `Github Discussions <https://github.com/colour-science/colour-datasets/discussions>`__
219219
- `Gitter <https://gitter.im/colour-science/colour>`__
220-
- `Twitter <https://twitter.com/colour_science>`__
220+
- `X <https://x.com/colour_science>`__
221+
- `Bluesky <https://bsky.app/profile/colour-science.bsky.social>`__
221222

222223
About
223224
-----

colour_datasets/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
- utilities: Various utilities.
1616
"""
1717

18+
# isort: skip_file
19+
20+
from __future__ import annotations
21+
1822
import contextlib
1923
import os
2024
import subprocess
@@ -52,19 +56,19 @@
5256
__major_version__ = "0"
5357
__minor_version__ = "2"
5458
__change_version__ = "6"
55-
__version__ = ".".join((__major_version__, __minor_version__, __change_version__))
59+
__version__ = f"{__major_version__}.{__minor_version__}.{__change_version__}"
5660

5761
try:
5862
_version = (
59-
subprocess.check_output(
60-
["git", "describe"], # noqa: S603, S607
63+
subprocess.check_output( # noqa: S603
64+
["git", "describe"], # noqa: S607
6165
cwd=os.path.dirname(__file__),
6266
stderr=subprocess.STDOUT,
6367
)
6468
.strip()
6569
.decode("utf-8")
6670
)
67-
except Exception:
71+
except Exception: # noqa: BLE001
6872
_version = __version__
6973

7074
colour.utilities.ANCILLARY_COLOUR_SCIENCE_PACKAGES["colour-datasets"] = _version # pyright: ignore

colour_datasets/loaders/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
# isort: skip_file
2+
13
from __future__ import annotations
24

35
import sys
6+
import typing
7+
8+
if typing.TYPE_CHECKING:
9+
from colour.hints import Any
410

5-
from colour.hints import Any
611
from colour.utilities import CanonicalMapping, warning
712

813
from colour_datasets.records import datasets

colour_datasets/loaders/abstract.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99

1010
from __future__ import annotations
1111

12+
import typing
1213
from abc import ABC, abstractmethod
1314

14-
from colour.hints import Any
15+
if typing.TYPE_CHECKING:
16+
from colour.hints import Any
1517

16-
from colour_datasets.records import Record
18+
from colour_datasets.records import Record
1719

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

125-
def sync(self):
127+
def sync(self) -> None:
126128
"""
127129
Sync the dataset content, i.e., checks whether it is synced and pulls
128130
it if required.

colour_datasets/loaders/asano2015.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from __future__ import annotations
1818

1919
import os
20-
from collections import namedtuple
20+
import typing
21+
from dataclasses import dataclass, field
2122

2223
import numpy as np
2324
import xlrd
@@ -26,7 +27,10 @@
2627
LMS_ConeFundamentals,
2728
XYZ_ColourMatchingFunctions,
2829
)
29-
from colour.hints import Dict, NDArrayFloat
30+
31+
if typing.TYPE_CHECKING:
32+
from colour.hints import Dict
33+
3034
from colour.utilities import as_float_array, tstack
3135

3236
from colour_datasets.loaders import AbstractDatasetLoader
@@ -47,12 +51,8 @@
4751
]
4852

4953

50-
class Specification_Asano2015(
51-
namedtuple(
52-
"Specification_Asano2015",
53-
("XYZ_2", "XYZ_10", "LMS_2", "LMS_10", "parameters", "others"),
54-
)
55-
):
54+
@dataclass(frozen=True)
55+
class Specification_Asano2015:
5656
"""
5757
Define the *Asano (2015)* specification for an observer.
5858
@@ -74,24 +74,14 @@ class Specification_Asano2015(
7474
References
7575
----------
7676
:cite:`Asano2015`
77-
""" # noqa: D405, D407, D410, D411
78-
79-
def __new__(
80-
cls,
81-
XYZ_2: XYZ_ColourMatchingFunctions,
82-
XYZ_10: XYZ_ColourMatchingFunctions,
83-
LMS_2: LMS_ConeFundamentals,
84-
LMS_10: LMS_ConeFundamentals,
85-
parameters: NDArrayFloat,
86-
others: Dict | None = None,
87-
):
88-
"""
89-
Return a new instance of the
90-
:class:`colour_datasets.loaders.asano2015.Specification_Asano2015`
91-
class.
92-
"""
77+
"""
9378

94-
return super().__new__(cls, XYZ_2, XYZ_10, LMS_2, LMS_10, parameters, others)
79+
XYZ_2: XYZ_ColourMatchingFunctions
80+
XYZ_10: XYZ_ColourMatchingFunctions
81+
LMS_2: LMS_ConeFundamentals
82+
LMS_10: LMS_ConeFundamentals
83+
parameters: Dict
84+
others: Dict = field(default_factory=dict)
9585

9686

9787
class DatasetLoader_Asano2015(AbstractDatasetLoader):
@@ -199,7 +189,7 @@ def load(self) -> Dict[str, Dict[int, Specification_Asano2015]]:
199189
observer["LMS_2"],
200190
observer["LMS_10"],
201191
observer["parameters"],
202-
dict(zip(header, values[i])),
192+
dict(zip(header, values[i], strict=False)),
203193
)
204194

205195
return self._content
@@ -284,7 +274,9 @@ def parse_workbook_Asano2015(
284274

285275
for i in range(observers[1]):
286276
observer = i + 1
287-
data[observer]["parameters"] = dict(zip(header, as_float_array(values[i])))
277+
data[observer]["parameters"] = dict(
278+
zip(header, as_float_array(values[i]), strict=False)
279+
)
288280

289281
return data
290282

colour_datasets/loaders/brendel2020.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
from __future__ import annotations
1919

2020
import os
21+
import typing
2122

2223
import numpy as np
2324
from colour import LinearInterpolator, SpectralDistribution, SpectralShape
24-
from colour.hints import Dict
25+
26+
if typing.TYPE_CHECKING:
27+
from colour.hints import Dict
28+
2529
from colour.utilities import as_int
2630

2731
from colour_datasets.loaders import AbstractDatasetLoader

0 commit comments

Comments
 (0)