Skip to content

Commit

Permalink
Fix various static typing issues.
Browse files Browse the repository at this point in the history
References #1201.

Co-authored-by: Thomas A Caswell <[email protected]>
  • Loading branch information
KelSolaar and tacaswell committed Sep 22, 2023
1 parent bc5ddcd commit 66e3e1f
Show file tree
Hide file tree
Showing 35 changed files with 223 additions and 182 deletions.
2 changes: 1 addition & 1 deletion colour/colorimetry/lefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def mesopic_weighting_function(

mesopic_x_luminance_values = sorted(DATA_MESOPIC_X.keys())
index = mesopic_x_luminance_values.index(
closest(mesopic_x_luminance_values, L_p) # pyright: ignore
closest(mesopic_x_luminance_values, L_p)
)
x = DATA_MESOPIC_X[mesopic_x_luminance_values[index]][source][method]

Expand Down
2 changes: 1 addition & 1 deletion colour/io/luts/lut.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ def linear_table(
samples = [
np.pad(
axis,
(0, np.max(size_array) - len(axis)),
(0, np.max(size_array) - len(axis)), # pyright: ignore
mode="constant",
constant_values=np.nan,
)
Expand Down
8 changes: 5 additions & 3 deletions colour/io/ocio.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def process_image_OpenColorIO(

config = kwargs.get("config")
config = (
ocio.Config.CreateFromEnv()
ocio.Config.CreateFromEnv() # pyright: ignore
if config is None
else ocio.Config.CreateFromFile(config)
else ocio.Config.CreateFromFile(config) # pyright: ignore
)

a = as_float_array(a)
Expand All @@ -148,7 +148,9 @@ def process_image_OpenColorIO(

processor = config.getProcessor(*args).getDefaultCPUProcessor()

image_desc = ocio.PackedImageDesc(a, width, height, channels)
image_desc = ocio.PackedImageDesc( # pyright: ignore
a, width, height, channels
)

processor.apply(image_desc)

Expand Down
5 changes: 3 additions & 2 deletions colour/plotting/blindness.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

from __future__ import annotations

import matplotlib.pyplot as plt
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from colour.algebra import vector_dot
from colour.blindness import matrix_cvd_Machado2009
Expand Down Expand Up @@ -43,7 +44,7 @@ def plot_cvd_simulation_Machado2009(
severity: float = 0.5,
M_a: ArrayLike | None = None,
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Perform colour vision deficiency simulation on given *RGB* colourspace
array using *Machado et al. (2009)* model.
Expand Down
7 changes: 4 additions & 3 deletions colour/plotting/characterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from __future__ import annotations

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from colour.hints import Any, Dict, Sequence, Tuple
from colour.characterisation import ColourChecker
Expand Down Expand Up @@ -54,7 +55,7 @@ def plot_single_colour_checker(
colour_checker: ColourChecker
| str = "ColorChecker24 - After November 2014",
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given colour checker.
Expand Down Expand Up @@ -103,7 +104,7 @@ def plot_single_colour_checker(
def plot_multi_colour_checkers(
colour_checkers: ColourChecker | str | Sequence[ColourChecker | str],
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot and compares given colour checkers.
Expand Down
30 changes: 16 additions & 14 deletions colour/plotting/colorimetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import matplotlib.pyplot as plt
import numpy as np
from functools import reduce
from matplotlib.axes import Axes
from matplotlib.figure import Figure
from matplotlib.patches import Polygon

from colour.algebra import (
Expand Down Expand Up @@ -117,7 +119,7 @@ def plot_single_sd(
modulate_colours_with_sd_amplitude: bool = False,
equalize_sd_amplitude: bool = False,
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given spectral distribution.
Expand Down Expand Up @@ -272,7 +274,7 @@ def plot_multi_sds(
| MultiSpectralDistributions,
plot_kwargs: dict | List[dict] | None = None,
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given spectral distributions.
Expand Down Expand Up @@ -420,7 +422,7 @@ def plot_multi_sds(
min(x_limit_min),
max(x_limit_max),
min(y_limit_min),
max(y_limit_max) * 1.05, # pyright: ignore
max(y_limit_max) * 1.05,
)
settings: Dict[str, Any] = {
"axes": axes,
Expand All @@ -442,7 +444,7 @@ def plot_single_cmfs(
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given colour matching functions.
Expand Down Expand Up @@ -494,7 +496,7 @@ def plot_multi_cmfs(
| str
| Sequence[MultiSpectralDistributions | str],
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given colour matching functions.
Expand Down Expand Up @@ -597,7 +599,7 @@ def plot_single_illuminant_sd(
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given single illuminant spectral distribution.
Expand Down Expand Up @@ -661,7 +663,7 @@ def plot_multi_illuminant_sds(
| str
| Sequence[SpectralDistribution | str],
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given illuminants spectral distributions.
Expand Down Expand Up @@ -735,7 +737,7 @@ def plot_visible_spectrum(
] = "CIE 1931 2 Degree Standard Observer",
out_of_gamut_clipping: bool = True,
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot the visible colours spectrum using given standard observer *CIE XYZ*
colour matching functions.
Expand Down Expand Up @@ -812,7 +814,7 @@ def plot_visible_spectrum(
@override_style()
def plot_single_lightness_function(
function: Callable | str, **kwargs: Any
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given *Lightness* function.
Expand Down Expand Up @@ -855,7 +857,7 @@ def plot_single_lightness_function(
def plot_multi_lightness_functions(
functions: Callable | str | Sequence[Callable | str],
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given *Lightness* functions.
Expand Down Expand Up @@ -908,7 +910,7 @@ def plot_multi_lightness_functions(
@override_style()
def plot_single_luminance_function(
function: Callable | str, **kwargs: Any
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given *Luminance* function.
Expand Down Expand Up @@ -950,7 +952,7 @@ def plot_single_luminance_function(
def plot_multi_luminance_functions(
functions: Callable | str | Sequence[Callable | str],
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given *Luminance* functions.
Expand Down Expand Up @@ -1010,7 +1012,7 @@ def plot_blackbody_spectral_radiance(
] = "CIE 1931 2 Degree Standard Observer",
blackbody: str = "VY Canis Major",
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot given blackbody spectral radiance.
Expand Down Expand Up @@ -1111,7 +1113,7 @@ def plot_blackbody_colours(
MultiSpectralDistributions | str
] = "CIE 1931 2 Degree Standard Observer",
**kwargs: Any,
) -> Tuple[plt.Figure, plt.Axes]:
) -> Tuple[Figure, Axes]:
"""
Plot blackbody colours.
Expand Down
Loading

0 comments on commit 66e3e1f

Please sign in to comment.