Skip to content

Commit ed66836

Browse files
committed
Merge branch 'feature/v0.2.2' into develop
2 parents f59d055 + 7369a28 commit ed66836

31 files changed

+1539
-1620
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.2.2
4-
hooks:
5-
- id: pyupgrade
6-
args: [--py39-plus]
72
- repo: https://github.com/ikamensh/flynt/
83
rev: '0.77'
94
hooks:
105
- id: flynt
6+
- repo: https://github.com/charliermarsh/ruff-pre-commit
7+
rev: 'v0.0.239'
8+
hooks:
9+
- id: ruff
1110
- repo: https://github.com/psf/black
1211
rev: 22.10.0
1312
hooks:
@@ -18,14 +17,3 @@ repos:
1817
hooks:
1918
- id: blackdoc
2019
language_version: python3.9
21-
- repo: https://github.com/PyCQA/flake8
22-
rev: 6.0.0
23-
hooks:
24-
- id: flake8
25-
- repo: https://github.com/pycqa/pydocstyle
26-
rev: 6.1.1
27-
hooks:
28-
- id: pydocstyle
29-
args:
30-
- --convention=numpy
31-
- --add-ignore=D104,D200,D202,D205,D301,D400

colour_datasets/__init__.py

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

18+
import contextlib
1819
import numpy as np
1920
import os
2021
import subprocess # nosec
@@ -77,7 +78,5 @@
7778
del _version
7879

7980
# TODO: Remove legacy printing support when deemed appropriate.
80-
try:
81+
with contextlib.suppress(TypeError):
8182
np.set_printoptions(legacy="1.13")
82-
except TypeError:
83-
pass

colour_datasets/loaders/__init__.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sys
44

5-
from colour.hints import Any, Union
5+
from colour.hints import Any
66
from colour.utilities import CanonicalMapping, warning
77

88
from colour_datasets.records import datasets
@@ -105,22 +105,19 @@
105105
Dataset loaders ids and callables.
106106
"""
107107

108-
from .kuopio import DATASET_LOADERS_KUOPIO_UNIVERSITY # noqa
108+
from .kuopio import DATASET_LOADERS_KUOPIO_UNIVERSITY # noqa: E402
109109

110110
DATASET_LOADERS.update(DATASET_LOADERS_KUOPIO_UNIVERSITY)
111111

112-
from . import kuopio # noqa
112+
from . import kuopio # noqa: E402
113113

114114
_module = sys.modules["colour_datasets.loaders"]
115115

116116
for _export in kuopio.__all__:
117117
if _export.startswith("DatasetLoader_") or _export.startswith("build_"):
118-
119118
setattr(_module, _export, getattr(kuopio, _export))
120119

121-
__all__ += [
122-
_export,
123-
]
120+
__all__ += [_export] # noqa: PLE0604
124121

125122
del _module, _export
126123

@@ -133,7 +130,7 @@
133130
"""
134131

135132

136-
def load(dataset: Union[int, str]) -> Any:
133+
def load(dataset: int | str) -> Any:
137134
"""
138135
Load given dataset: The dataset is pulled locally, i.e. synced if required
139136
and then its data is loaded.

colour_datasets/loaders/abstract.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from abc import ABC, abstractmethod
1313

14-
from colour.hints import Any, Optional
14+
from colour.hints import Any
1515

1616
from colour_datasets.records import Record
1717

@@ -63,7 +63,7 @@ class AbstractDatasetLoader(ABC):
6363

6464
def __init__(self, record: Record) -> None:
6565
self._record: Record = record
66-
self._content: Optional[Any] = None
66+
self._content: Any | None = None
6767

6868
@property
6969
def record(self) -> Record:
@@ -79,7 +79,7 @@ def record(self) -> Record:
7979
return self._record
8080

8181
@property
82-
def id(self) -> str:
82+
def id(self) -> str: # noqa: A003
8383
"""
8484
Getter property for the dataset id.
8585
@@ -122,8 +122,6 @@ def load(self) -> Any:
122122
when they implement it, e.g. ``super().sync()``.
123123
"""
124124

125-
pass
126-
127125
def sync(self):
128126
"""
129127
Sync the dataset content, i.e. checks whether it is synced and pulls

colour_datasets/loaders/asano2015.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
XYZ_ColourMatchingFunctions,
2727
LMS_ConeFundamentals,
2828
)
29-
from colour.hints import Dict, NDArrayFloat, Optional
29+
from colour.hints import Dict, NDArrayFloat
3030
from colour.utilities import as_float_array, tstack
3131

3232
from colour_datasets.loaders import AbstractDatasetLoader
@@ -52,7 +52,7 @@ class Specification_Asano2015(
5252
"Specification_Asano2015",
5353
("XYZ_2", "XYZ_10", "LMS_2", "LMS_10", "parameters", "others"),
5454
)
55-
): # noqa: D405,D407,D410,D411
55+
):
5656
"""
5757
Define the *Asano (2015)* specification for an observer.
5858
@@ -74,7 +74,7 @@ class Specification_Asano2015(
7474
References
7575
----------
7676
:cite:`Asano2015`
77-
"""
77+
""" # noqa: D405, D407, D410, D411
7878

7979
def __new__(
8080
cls,
@@ -83,7 +83,7 @@ def __new__(
8383
LMS_2: LMS_ConeFundamentals,
8484
LMS_10: LMS_ConeFundamentals,
8585
parameters: NDArrayFloat,
86-
others: Optional[Dict] = None,
86+
others: Dict | None = None,
8787
):
8888
"""
8989
Return a new instance of the
@@ -122,7 +122,7 @@ class DatasetLoader_Asano2015(AbstractDatasetLoader):
122122
def __init__(self) -> None:
123123
super().__init__(datasets()[DatasetLoader_Asano2015.ID])
124124

125-
def load(self) -> Dict[str, Specification_Asano2015]:
125+
def load(self) -> Dict[str, Dict[int, Specification_Asano2015]]:
126126
"""
127127
Sync, parse, convert and return the *Asano (2015)*
128128
*Observer Function Database* dataset content.
@@ -145,12 +145,10 @@ def load(self) -> Dict[str, Specification_Asano2015]:
145145

146146
super().sync()
147147

148-
self._content = dict(
149-
[
150-
("Categorical Observers", dict()),
151-
("Colour Normal Observers", dict()),
152-
]
153-
)
148+
self._content = {
149+
"Categorical Observers": {},
150+
"Colour Normal Observers": {},
151+
}
154152

155153
# Categorical Observers
156154
workbook_path = os.path.join(
@@ -247,7 +245,7 @@ def parse_workbook_Asano2015(
247245

248246
shape = SpectralShape(390, 780, 5)
249247
wavelengths = shape.range()
250-
data: Dict = dict()
248+
data: Dict = {}
251249

252250
for i, cmfs in enumerate(
253251
[
@@ -276,7 +274,7 @@ def parse_workbook_Asano2015(
276274
observer = k + 1
277275
rgb = tstack([x[k], y[k], z[k]])
278276
if data.get(observer) is None:
279-
data[observer] = dict()
277+
data[observer] = {}
280278

281279
key = f"{cmfs[1]}_{degree[0]}"
282280
data[observer][key] = cmfs[0](
@@ -310,7 +308,7 @@ def parse_workbook_Asano2015(
310308
return data
311309

312310

313-
_DATASET_LOADER_ASANO2015: Optional[DatasetLoader_Asano2015] = None
311+
_DATASET_LOADER_ASANO2015: DatasetLoader_Asano2015 | None = None
314312
"""
315313
Singleton instance of the *Asano (2015)* *Observer Function Database* dataset
316314
loader.

colour_datasets/loaders/brendel2020.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import os
2222

2323
from colour import LinearInterpolator, SpectralShape, SpectralDistribution
24-
from colour.hints import Dict, Optional
24+
from colour.hints import Dict
2525
from colour.utilities import as_int
2626

2727
from colour_datasets.loaders import AbstractDatasetLoader
@@ -87,7 +87,7 @@ def load(self) -> Dict[str, SpectralDistribution]:
8787

8888
super().sync()
8989

90-
self._content = dict()
90+
self._content = {}
9191

9292
wavelengths = SpectralShape(350, 700, 2).range()
9393

@@ -108,7 +108,7 @@ def load(self) -> Dict[str, SpectralDistribution]:
108108
return self._content
109109

110110

111-
_DATASET_LOADER_BRENDEL2020: Optional[DatasetLoader_Brendel2020] = None
111+
_DATASET_LOADER_BRENDEL2020: DatasetLoader_Brendel2020 | None = None
112112
"""
113113
Singleton instance of the *Brendel (2020)* *Measured Commercial LED Spectra*
114114
dataset loader.

0 commit comments

Comments
 (0)