Skip to content

Commit

Permalink
Use colour checks configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 22, 2024
1 parent 91ac338 commit 8fece10
Show file tree
Hide file tree
Showing 49 changed files with 459 additions and 403 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
4 changes: 2 additions & 2 deletions colour_datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
__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 = (
Expand All @@ -68,7 +68,7 @@
.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
5 changes: 4 additions & 1 deletion colour_datasets/loaders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
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
44 changes: 18 additions & 26 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 @@ -76,22 +76,12 @@ class Specification_Asano2015(
:cite:`Asano2015`
"""

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 8fece10

Please sign in to comment.