Skip to content

Commit

Permalink
Merge a045136 into b7fb86c
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 11, 2022
2 parents b7fb86c + a045136 commit 3b78468
Show file tree
Hide file tree
Showing 328 changed files with 5,056 additions and 5,650 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Expand Up @@ -15,13 +15,13 @@ 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.
- [ ] New transformations have been added to the *Automatic Colour Conversion Graph*.
- [ ] New transformations have been exported to the relevant namespaces, e.g. `colour`, `colour.models`.

<!-- The unit tests can be invoked with `poetry run invoke tests` -->
<!-- Mypy can be started with `dmypy run -- --show-error-codes --warn-unused-ignores --warn-redundant-casts --install-types --non-interactive -p colour` -->
<!-- Pyright can be started with `pyright --skipunannotated` -->

**Documentation**

Expand Down
Expand Up @@ -32,4 +32,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
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -3,11 +3,9 @@
*.pyo
.DS_Store
.coverage
.dmypy.json
.fleet
.idea
.ipynb_checkpoints
.mypy_cache
.vs
.vscode
.sandbox
Expand Down
16 changes: 8 additions & 8 deletions colour/__init__.py
Expand Up @@ -904,12 +904,12 @@ def __getattr__(self, attribute) -> Any:
return super().__getattr__(attribute)


colour.__application_name__ = __application_name__ # type: ignore[attr-defined]
colour.__application_name__ = __application_name__ # pyright: ignore

colour.__major_version__ = __major_version__ # type: ignore[attr-defined]
colour.__minor_version__ = __minor_version__ # type: ignore[attr-defined]
colour.__change_version__ = __change_version__ # type: ignore[attr-defined]
colour.__version__ = __version__ # type: ignore[attr-defined]
colour.__major_version__ = __major_version__ # pyright: ignore
colour.__minor_version__ = __minor_version__ # pyright: ignore
colour.__change_version__ = __change_version__ # pyright: ignore
colour.__version__ = __version__ # pyright: ignore

# v0.4.0
API_CHANGES = {
Expand Down Expand Up @@ -943,14 +943,14 @@ def __getattr__(self, attribute) -> Any:
"""Defines the *colour.models* sub-package API changes."""

if not is_documentation_building():
sys.modules["colour"] = colour( # type: ignore[assignment]
sys.modules["colour"] = colour( # pyright: ignore
sys.modules["colour"], build_API_changes(API_CHANGES)
)

del ModuleAPI, is_documentation_building, build_API_changes, sys

colour.__disable_lazy_load__ = True # type: ignore[attr-defined]
__disable_lazy_load__ = colour.__disable_lazy_load__ # type: ignore[attr-defined]
colour.__disable_lazy_load__ = True # pyright: ignore
__disable_lazy_load__ = colour.__disable_lazy_load__ # pyright: ignore
"""
Ensures that the lazy loaded datasets are not transformed during import.
See :class:`colour.utilities.LazyCanonicalMapping` for more information.
Expand Down
4 changes: 2 additions & 2 deletions colour/adaptation/__init__.py
Expand Up @@ -26,7 +26,7 @@

from __future__ import annotations

from colour.hints import Any, ArrayLike, Literal, NDArray, Union
from colour.hints import Any, ArrayLike, Literal, NDArrayFloat, Union
from colour.utilities import (
CanonicalMapping,
filter_kwargs,
Expand Down Expand Up @@ -136,7 +136,7 @@ def chromatic_adaptation(
str,
] = "Von Kries",
**kwargs: Any,
) -> NDArray:
) -> NDArrayFloat:
"""
Adapt given stimulus from test viewing conditions to reference viewing
conditions.
Expand Down
73 changes: 35 additions & 38 deletions colour/adaptation/cie1994.py
Expand Up @@ -20,12 +20,7 @@

from colour.algebra import sdiv, sdiv_mode, spow, vector_dot
from colour.adaptation import CAT_VON_KRIES
from colour.hints import (
ArrayLike,
FloatingOrArrayLike,
FloatingOrNDArray,
NDArray,
)
from colour.hints import ArrayLike, NDArrayFloat
from colour.utilities import (
as_float_array,
from_range_100,
Expand Down Expand Up @@ -57,13 +52,15 @@
"corresponding_colour",
]

MATRIX_XYZ_TO_RGB_CIE1994: NDArray = CAT_VON_KRIES
MATRIX_XYZ_TO_RGB_CIE1994: NDArrayFloat = CAT_VON_KRIES
"""
*CIE 1994* colour appearance model *CIE XYZ* tristimulus values to cone
responses matrix.
"""

MATRIX_RGB_TO_XYZ_CIE1994: NDArray = np.linalg.inv(MATRIX_XYZ_TO_RGB_CIE1994)
MATRIX_RGB_TO_XYZ_CIE1994: NDArrayFloat = np.linalg.inv(
MATRIX_XYZ_TO_RGB_CIE1994
)
"""
*CIE 1994* colour appearance model cone responses to *CIE XYZ* tristimulus
values matrix.
Expand All @@ -74,11 +71,11 @@ def chromatic_adaptation_CIE1994(
XYZ_1: ArrayLike,
xy_o1: ArrayLike,
xy_o2: ArrayLike,
Y_o: FloatingOrArrayLike,
E_o1: FloatingOrArrayLike,
E_o2: FloatingOrArrayLike,
n: FloatingOrArrayLike = 1,
) -> NDArray:
Y_o: ArrayLike,
E_o1: ArrayLike,
E_o2: ArrayLike,
n: ArrayLike = 1,
) -> NDArrayFloat:
"""
Adapt given stimulus *CIE XYZ_1* tristimulus values from test viewing
conditions to reference viewing conditions using *CIE 1994* chromatic
Expand Down Expand Up @@ -174,7 +171,7 @@ def chromatic_adaptation_CIE1994(
return from_range_100(XYZ_2)


def XYZ_to_RGB_CIE1994(XYZ: ArrayLike) -> NDArray:
def XYZ_to_RGB_CIE1994(XYZ: ArrayLike) -> NDArrayFloat:
"""
Convert from *CIE XYZ* tristimulus values to cone responses.
Expand All @@ -198,7 +195,7 @@ def XYZ_to_RGB_CIE1994(XYZ: ArrayLike) -> NDArray:
return vector_dot(MATRIX_XYZ_TO_RGB_CIE1994, XYZ)


def RGB_to_XYZ_CIE1994(RGB: ArrayLike) -> NDArray:
def RGB_to_XYZ_CIE1994(RGB: ArrayLike) -> NDArrayFloat:
"""
Convert from cone responses to *CIE XYZ* tristimulus values.
Expand All @@ -222,7 +219,7 @@ def RGB_to_XYZ_CIE1994(RGB: ArrayLike) -> NDArray:
return vector_dot(MATRIX_RGB_TO_XYZ_CIE1994, RGB)


def intermediate_values(xy_o: ArrayLike) -> NDArray:
def intermediate_values(xy_o: ArrayLike) -> NDArrayFloat:
"""
Return the intermediate values :math:`\\xi`, :math:`\\eta`,
:math:`\\zeta`.
Expand Down Expand Up @@ -257,8 +254,8 @@ def intermediate_values(xy_o: ArrayLike) -> NDArray:


def effective_adapting_responses(
xez: ArrayLike, Y_o: FloatingOrArrayLike, E_o: FloatingOrArrayLike
) -> NDArray:
xez: ArrayLike, Y_o: ArrayLike, E_o: ArrayLike
) -> NDArrayFloat:
"""
Derive the effective adapting responses in the fundamental primary system
of the test or reference field.
Expand Down Expand Up @@ -296,7 +293,7 @@ def effective_adapting_responses(
return RGB_o


def beta_1(x: FloatingOrArrayLike) -> FloatingOrNDArray:
def beta_1(x: ArrayLike) -> NDArrayFloat:
"""
Compute the exponent :math:`\\beta_1` for the middle and long-wavelength
sensitive cones.
Expand All @@ -308,7 +305,7 @@ def beta_1(x: FloatingOrArrayLike) -> FloatingOrNDArray:
Returns
-------
:class:`numpy.floating` or :class:`numpy.ndarray`
:class:`numpy.ndarray`
Exponent :math:`\\beta_1`.
Examples
Expand All @@ -322,7 +319,7 @@ def beta_1(x: FloatingOrArrayLike) -> FloatingOrNDArray:
return (6.469 + 6.362 * x_p) / (6.469 + x_p)


def beta_2(x: FloatingOrArrayLike) -> FloatingOrNDArray:
def beta_2(x: ArrayLike) -> NDArrayFloat:
"""
Compute the exponent :math:`\\beta_2` for the short-wavelength sensitive
cones.
Expand All @@ -334,7 +331,7 @@ def beta_2(x: FloatingOrArrayLike) -> FloatingOrNDArray:
Returns
-------
:class:`numpy.floating` or :class:`numpy.ndarray`
:class:`numpy.ndarray`
Exponent :math:`\\beta_2`.
Examples
Expand All @@ -348,7 +345,7 @@ def beta_2(x: FloatingOrArrayLike) -> FloatingOrNDArray:
return 0.7844 * (8.414 + 8.091 * x_p) / (8.414 + x_p)


def exponential_factors(RGB_o: ArrayLike) -> NDArray:
def exponential_factors(RGB_o: ArrayLike) -> NDArrayFloat:
"""
Return the chromatic adaptation exponential factors :math:`\\beta_1(R_o)`,
:math:`\\beta_1(G_o)` and :math:`\\beta_2(B_o)` of given cone responses.
Expand Down Expand Up @@ -387,9 +384,9 @@ def K_coefficient(
xez_2: ArrayLike,
bRGB_o1: ArrayLike,
bRGB_o2: ArrayLike,
Y_o: FloatingOrArrayLike,
n: FloatingOrArrayLike = 1,
) -> FloatingOrNDArray:
Y_o: ArrayLike,
n: ArrayLike = 1,
) -> NDArrayFloat:
"""
Compute the coefficient :math:`K` for correcting the difference between
the test and references illuminances.
Expand Down Expand Up @@ -417,7 +414,7 @@ def K_coefficient(
Returns
-------
:class:`numpy.floating` or :class:`numpy.ndarray`
:class:`numpy.ndarray`
Coefficient :math:`K`.
Examples
Expand Down Expand Up @@ -455,10 +452,10 @@ def corresponding_colour(
xez_2: ArrayLike,
bRGB_o1: ArrayLike,
bRGB_o2: ArrayLike,
Y_o: FloatingOrArrayLike,
K: FloatingOrArrayLike,
n: FloatingOrArrayLike = 1,
) -> NDArray:
Y_o: ArrayLike,
K: ArrayLike,
n: ArrayLike = 1,
) -> NDArrayFloat:
"""
Compute the corresponding colour cone responses of given test sample cone
responses :math:`RGB_1`.
Expand Down Expand Up @@ -518,13 +515,13 @@ def corresponding_colour(
n = as_float_array(n)

def RGB_c(
x_1: NDArray,
x_2: NDArray,
y_1: NDArray,
y_2: NDArray,
z: NDArray,
n: NDArray,
) -> NDArray:
x_1: NDArrayFloat,
x_2: NDArrayFloat,
y_1: NDArrayFloat,
y_2: NDArrayFloat,
z: NDArrayFloat,
n: NDArrayFloat,
) -> NDArrayFloat:
"""Compute the corresponding colour cone responses component."""

with sdiv_mode():
Expand Down
31 changes: 12 additions & 19 deletions colour/adaptation/cmccat2000.py
Expand Up @@ -27,14 +27,7 @@

from colour.adaptation import CAT_CMCCAT2000
from colour.algebra import vector_dot
from colour.hints import (
ArrayLike,
Floating,
FloatingOrArrayLike,
Literal,
NDArray,
Union,
)
from colour.hints import ArrayLike, Literal, NDArrayFloat, Union
from colour.utilities import (
CanonicalMapping,
as_float_array,
Expand All @@ -59,7 +52,7 @@
"chromatic_adaptation_CMCCAT2000",
]

CAT_INVERSE_CMCCAT2000: NDArray = np.linalg.inv(CAT_CMCCAT2000)
CAT_INVERSE_CMCCAT2000: NDArrayFloat = np.linalg.inv(CAT_CMCCAT2000)
"""
Inverse *CMCCAT2000* chromatic adaptation transform.
Expand All @@ -81,7 +74,7 @@ class InductionFactors_CMCCAT2000(NamedTuple):
:cite:`Li2002a`, :cite:`Westland2012k`
"""

F: Floating
F: float


VIEWING_CONDITIONS_CMCCAT2000: CanonicalMapping = CanonicalMapping(
Expand All @@ -104,12 +97,12 @@ def chromatic_adaptation_forward_CMCCAT2000(
XYZ: ArrayLike,
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
L_A1: FloatingOrArrayLike,
L_A2: FloatingOrArrayLike,
L_A1: ArrayLike,
L_A2: ArrayLike,
surround: InductionFactors_CMCCAT2000 = VIEWING_CONDITIONS_CMCCAT2000[
"Average"
],
) -> NDArray:
) -> NDArrayFloat:
"""
Adapt given stimulus *CIE XYZ* tristimulus values from test viewing
conditions to reference viewing conditions using *CMCCAT2000* forward
Expand Down Expand Up @@ -199,12 +192,12 @@ def chromatic_adaptation_inverse_CMCCAT2000(
XYZ_c: ArrayLike,
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
L_A1: FloatingOrArrayLike,
L_A2: FloatingOrArrayLike,
L_A1: ArrayLike,
L_A2: ArrayLike,
surround: InductionFactors_CMCCAT2000 = VIEWING_CONDITIONS_CMCCAT2000[
"Average"
],
) -> NDArray:
) -> NDArrayFloat:
"""
Adapt given stimulus corresponding colour *CIE XYZ* tristimulus values
from reference viewing conditions to test viewing conditions using
Expand Down Expand Up @@ -296,13 +289,13 @@ def chromatic_adaptation_CMCCAT2000(
XYZ: ArrayLike,
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
L_A1: FloatingOrArrayLike,
L_A2: FloatingOrArrayLike,
L_A1: ArrayLike,
L_A2: ArrayLike,
surround: InductionFactors_CMCCAT2000 = VIEWING_CONDITIONS_CMCCAT2000[
"Average"
],
direction: Union[Literal["Forward", "Inverse"], str] = "Forward",
) -> NDArray:
) -> NDArrayFloat:
"""
Adapt given stimulus *CIE XYZ* tristimulus values using given viewing
conditions.
Expand Down

0 comments on commit 3b78468

Please sign in to comment.