Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add various new literals for typing annotations. #1198

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading