Skip to content

Commit

Permalink
Add various new literals for typing annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
KelSolaar committed Sep 14, 2023
1 parent 878ae03 commit d361cd5
Show file tree
Hide file tree
Showing 16 changed files with 552 additions and 806 deletions.
38 changes: 7 additions & 31 deletions colour/adaptation/vonkries.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

from colour.adaptation import CHROMATIC_ADAPTATION_TRANSFORMS
from colour.algebra import matrix_dot, vector_dot, sdiv, sdiv_mode
from colour.hints import ArrayLike, Literal, NDArrayFloat
from colour.hints import (
ArrayLike,
LiteralChromaticAdaptationTransform,
NDArrayFloat,
)
from colour.utilities import (
from_range_1,
row_as_diagonal,
Expand All @@ -44,21 +48,7 @@
def matrix_chromatic_adaptation_VonKries(
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
| str = "CAT02",
transform: LiteralChromaticAdaptationTransform | str = "CAT02",
) -> NDArrayFloat:
"""
Compute the *chromatic adaptation* matrix from test viewing conditions
Expand Down Expand Up @@ -145,21 +135,7 @@ def chromatic_adaptation_VonKries(
XYZ: ArrayLike,
XYZ_w: ArrayLike,
XYZ_wr: ArrayLike,
transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
| str = "CAT02",
transform: LiteralChromaticAdaptationTransform | str = "CAT02",
) -> NDArrayFloat:
"""
Adapt given stimulus from test viewing conditions to reference viewing
Expand Down
47 changes: 4 additions & 43 deletions colour/characterisation/aces_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
ArrayLike,
Callable,
DTypeFloat,
Literal,
LiteralChromaticAdaptationTransform,
Mapping,
NDArrayFloat,
Tuple,
Expand Down Expand Up @@ -160,20 +160,7 @@
def sd_to_aces_relative_exposure_values(
sd: SpectralDistribution,
illuminant: SpectralDistribution | None = None,
chromatic_adaptation_transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
chromatic_adaptation_transform: LiteralChromaticAdaptationTransform
| str
| None = "CAT02",
**kwargs,
Expand Down Expand Up @@ -665,20 +652,7 @@ def training_data_sds_to_XYZ(
training_data: MultiSpectralDistributions,
cmfs: MultiSpectralDistributions,
illuminant: SpectralDistribution,
chromatic_adaptation_transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
chromatic_adaptation_transform: LiteralChromaticAdaptationTransform
| str
| None = "CAT02",
) -> NDArrayFloat:
Expand Down Expand Up @@ -1022,20 +996,7 @@ def matrix_idt(
cmfs: MultiSpectralDistributions | None = None,
optimisation_factory: Callable = optimisation_factory_rawtoaces_v1,
optimisation_kwargs: dict | None = None,
chromatic_adaptation_transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
chromatic_adaptation_transform: LiteralChromaticAdaptationTransform
| str
| None = "CAT02",
additional_data: bool = False,
Expand Down
24 changes: 8 additions & 16 deletions colour/corresponding/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@
BRENEMAN_EXPERIMENTS,
BRENEMAN_EXPERIMENT_PRIMARIES_CHROMATICITIES,
)
from colour.hints import Any, ArrayLike, Literal, Tuple
from colour.hints import (
Any,
ArrayLike,
Literal,
LiteralChromaticAdaptationTransform,
Tuple,
)
from colour.models import (
Luv_to_uv,
Luv_uv_to_xy,
Expand Down Expand Up @@ -513,21 +519,7 @@ def corresponding_chromaticities_prediction_CMCCAT2000(
def corresponding_chromaticities_prediction_VonKries(
experiment: Literal[1, 2, 3, 4, 6, 8, 9, 11, 12]
| CorrespondingColourDataset = 1,
transform: Literal[
"Bianco 2010",
"Bianco PC 2010",
"Bradford",
"CAT02 Brill 2008",
"CAT02",
"CAT16",
"CMCCAT2000",
"CMCCAT97",
"Fairchild",
"Sharp",
"Von Kries",
"XYZ Scaling",
]
| str = "CAT02",
transform: LiteralChromaticAdaptationTransform | str = "CAT02",
) -> Tuple[CorrespondingChromaticitiesPrediction, ...]:
"""
Return the corresponding chromaticities prediction for *Von Kries*
Expand Down
Loading

0 comments on commit d361cd5

Please sign in to comment.