Skip to content

Commit

Permalink
Enable PYI checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Dec 22, 2024
1 parent 73d4a82 commit 40c531e
Show file tree
Hide file tree
Showing 34 changed files with 1,213 additions and 438 deletions.
6 changes: 4 additions & 2 deletions colour/adaptation/cmccat2000.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from __future__ import annotations

from typing import NamedTuple
from dataclasses import dataclass

import numpy as np

Expand All @@ -31,6 +31,7 @@
from colour.hints import ArrayLike, Literal, NDArrayFloat
from colour.utilities import (
CanonicalMapping,
MixinDataclassIterable,
as_float_array,
from_range_100,
to_domain_100,
Expand Down Expand Up @@ -61,7 +62,8 @@
"""


class InductionFactors_CMCCAT2000(NamedTuple):
@dataclass(frozen=True)
class InductionFactors_CMCCAT2000(MixinDataclassIterable):
"""
*CMCCAT2000* chromatic adaptation model induction factors.
Expand Down
14 changes: 9 additions & 5 deletions colour/adaptation/fairchild2020.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass

import numpy as np

Expand All @@ -26,6 +26,7 @@
from colour.hints import ArrayLike, Literal, NDArrayFloat
from colour.utilities import (
CanonicalMapping,
MixinDataclassIterable,
as_float_array,
from_range_1,
row_as_diagonal,
Expand All @@ -49,9 +50,8 @@
]


class Coefficients_DegreeOfAdaptation_vK20(
namedtuple("Coefficients_DegreeOfAdaptation_vK20", ("D_n", "D_r", "D_p"))
):
@dataclass(frozen=True)
class Coefficients_DegreeOfAdaptation_vK20(MixinDataclassIterable):
"""
*Von Kries 2020* (*vK20*) degree of adaptation coefficients.
Expand All @@ -69,6 +69,10 @@ class Coefficients_DegreeOfAdaptation_vK20(
:cite:`Fairchild2020`
"""

D_n: float
D_r: float
D_p: float


CONDITIONS_DEGREE_OF_ADAPTATION_VK20: CanonicalMapping = CanonicalMapping(
{
Expand Down Expand Up @@ -200,7 +204,7 @@ def matrix_chromatic_adaptation_vk20(

M = CHROMATIC_ADAPTATION_TRANSFORMS[transform]

D_n, D_r, D_p = coefficients
D_n, D_r, D_p = coefficients.values

LMS_n = vecmul(M, XYZ_n)
LMS_r = vecmul(M, XYZ_r)
Expand Down
5 changes: 3 additions & 2 deletions colour/algebra/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
Callable,
Literal,
NDArrayFloat,
Self,
Tuple,
cast,
)
Expand Down Expand Up @@ -202,7 +203,7 @@ def __init__(
self._mode = optional(mode, get_sdiv_mode())
self._previous_mode = get_sdiv_mode()

def __enter__(self) -> sdiv_mode:
def __enter__(self) -> Self:
"""
Set the *Colour* safe division function mode upon entering the context
manager.
Expand Down Expand Up @@ -411,7 +412,7 @@ def __init__(self, enable: bool) -> None:
self._enable = enable
self._previous_state = is_spow_enabled()

def __enter__(self) -> spow_enable:
def __enter__(self) -> Self:
"""
Set the *Colour* safe / symmetrical power function enabled state
upon entering the context manager.
Expand Down
9 changes: 7 additions & 2 deletions colour/appearance/cam16.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import astuple, dataclass, field

import numpy as np
Expand Down Expand Up @@ -54,6 +53,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
from_range_100,
Expand Down Expand Up @@ -89,7 +89,8 @@
"""Inverse adaptation matrix :math:`M^{-1}_{16}`."""


class InductionFactors_CAM16(namedtuple("InductionFactors_CAM16", ("F", "c", "N_c"))):
@dataclass(frozen=True)
class InductionFactors_CAM16(MixinDataclassIterable):
"""
*CAM16* colour appearance model induction factors.
Expand All @@ -112,6 +113,10 @@ class InductionFactors_CAM16(namedtuple("InductionFactors_CAM16", ("F", "c", "N_
:cite:`Li2017`
"""

F: float
c: float
N_c: float


VIEWING_CONDITIONS_CAM16: CanonicalMapping = CanonicalMapping(
VIEWING_CONDITIONS_CIECAM02
Expand Down
11 changes: 7 additions & 4 deletions colour/appearance/ciecam02.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import astuple, dataclass, field

import numpy as np
Expand All @@ -51,6 +50,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
as_int_array,
Expand Down Expand Up @@ -117,9 +117,8 @@
"""Inverse CAT02 chromatic adaptation transform."""


class InductionFactors_CIECAM02(
namedtuple("InductionFactors_CIECAM02", ("F", "c", "N_c"))
):
@dataclass(frozen=True)
class InductionFactors_CIECAM02(MixinDataclassIterable):
"""
*CIECAM02* colour appearance model induction factors.
Expand All @@ -138,6 +137,10 @@ class InductionFactors_CIECAM02(
:cite:`Wikipedia2007a`
"""

F: float
c: float
N_c: float


VIEWING_CONDITIONS_CIECAM02: CanonicalMapping = CanonicalMapping(
{
Expand Down
11 changes: 7 additions & 4 deletions colour/appearance/ciecam16.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import astuple, dataclass, field

import numpy as np
Expand Down Expand Up @@ -53,6 +52,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
from_range_100,
Expand Down Expand Up @@ -84,9 +84,8 @@
]


class InductionFactors_CIECAM16(
namedtuple("InductionFactors_CIECAM16", ("F", "c", "N_c"))
):
@dataclass(frozen=True)
class InductionFactors_CIECAM16(MixinDataclassIterable):
"""
*CIECAM16* colour appearance model induction factors.
Expand All @@ -109,6 +108,10 @@ class InductionFactors_CIECAM16(
:cite:`CIEDivision12022`
"""

F: float
c: float
N_c: float


VIEWING_CONDITIONS_CIECAM16: CanonicalMapping = CanonicalMapping(
VIEWING_CONDITIONS_CIECAM02
Expand Down
11 changes: 7 additions & 4 deletions colour/appearance/hellwig2022.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import astuple, dataclass, field

import numpy as np
Expand Down Expand Up @@ -53,6 +52,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
from_range_100,
Expand Down Expand Up @@ -91,9 +91,8 @@
]


class InductionFactors_Hellwig2022(
namedtuple("InductionFactors_Hellwig2022", ("F", "c", "N_c"))
):
@dataclass(frozen=True)
class InductionFactors_Hellwig2022(MixinDataclassIterable):
"""
*Hellwig and Fairchild (2022)* colour appearance model induction factors.
Expand All @@ -116,6 +115,10 @@ class InductionFactors_Hellwig2022(
:cite:`Fairchild2022`, :cite:`Hellwig2022`
"""

F: float
c: float
N_c: float


VIEWING_CONDITIONS_HELLWIG2022: CanonicalMapping = CanonicalMapping(
VIEWING_CONDITIONS_CIECAM02
Expand Down
24 changes: 7 additions & 17 deletions colour/appearance/hunt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass, field

import numpy as np
Expand All @@ -29,6 +28,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
from_range_degrees,
Expand Down Expand Up @@ -79,9 +79,8 @@
]


class InductionFactors_Hunt(
namedtuple("InductionFactors_Hunt", ("N_c", "N_b", "N_cb", "N_bb"))
):
@dataclass(frozen=True)
class InductionFactors_Hunt(MixinDataclassIterable):
"""
*Hunt* colour appearance model induction factors.
Expand All @@ -105,19 +104,10 @@ class InductionFactors_Hunt(
:cite:`Fairchild2013u`, :cite:`Hunt2004b`
"""

def __new__(
cls,
N_c: float,
N_b: float,
N_cb: float | None = None,
N_bb: float | None = None,
) -> InductionFactors_Hunt:
"""
Return a new instance of the
:class:`colour.appearance.InductionFactors_Hunt` class.
"""

return super().__new__(cls, N_c, N_b, N_cb, N_bb)
N_c: float
N_b: float
N_cb: float | None = field(default_factory=lambda: None)
N_bb: float | None = field(default_factory=lambda: None)


VIEWING_CONDITIONS_HUNT: CanonicalMapping = CanonicalMapping(
Expand Down
22 changes: 10 additions & 12 deletions colour/appearance/kim2009.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from __future__ import annotations

from collections import namedtuple
from dataclasses import astuple, dataclass, field

import numpy as np
Expand All @@ -42,6 +41,7 @@
from colour.utilities import (
CanonicalMapping,
MixinDataclassArithmetic,
MixinDataclassIterable,
as_float,
as_float_array,
from_range_100,
Expand Down Expand Up @@ -72,9 +72,8 @@
]


class InductionFactors_Kim2009(
namedtuple("InductionFactors_Kim2009", ("F", "c", "N_c"))
):
@dataclass(frozen=True)
class InductionFactors_Kim2009(MixinDataclassIterable):
"""
*Kim, Weyrich and Kautz (2009)* colour appearance model induction factors.
Expand Down Expand Up @@ -102,6 +101,10 @@ class InductionFactors_Kim2009(
:cite:`Kim2009`
"""

F: float
c: float
N_c: float


VIEWING_CONDITIONS_KIM2009: CanonicalMapping = CanonicalMapping(
VIEWING_CONDITIONS_CIECAM02
Expand All @@ -116,7 +119,8 @@ class InductionFactors_Kim2009(
"""


class MediaParameters_Kim2009(namedtuple("MediaParameters_Kim2009", ("E",))):
@dataclass(frozen=True)
class MediaParameters_Kim2009:
"""
*Kim, Weyrich and Kautz (2009)* colour appearance model media parameters.
Expand All @@ -130,13 +134,7 @@ class MediaParameters_Kim2009(namedtuple("MediaParameters_Kim2009", ("E",))):
:cite:`Kim2009`
"""

def __new__(cls, E: float) -> MediaParameters_Kim2009:
"""
Return a new instance of the
:class:`colour.appearance.MediaParameters_Kim2009` class.
"""

return super().__new__(cls, E)
E: float


MEDIA_PARAMETERS_KIM2009: CanonicalMapping = CanonicalMapping(
Expand Down
Loading

0 comments on commit 40c531e

Please sign in to comment.