Skip to content

Commit 6674323

Browse files
committed
Actually correcly annoate mypy stub for image
1 parent 61ff822 commit 6674323

2 files changed

Lines changed: 44 additions & 79 deletions

File tree

‎lib/matplotlib/_image.pyi‎

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +0,0 @@
1-
# Stub generated from the C++ (pybind11) signatures in ``src/_image_wrapper.cpp``.
2-
# NOT verified with matplotlib's ``stubtest`` (the extension was not importable
3-
# when this stub was written); treat the annotations as best-effort.
4-
from enum import Enum
5-
from typing import cast
6-
7-
import numpy as np
8-
9-
class _InterpolationType(Enum):
10-
NEAREST = cast(int, ...)
11-
BILINEAR = cast(int, ...)
12-
BICUBIC = cast(int, ...)
13-
SPLINE16 = cast(int, ...)
14-
SPLINE36 = cast(int, ...)
15-
HANNING = cast(int, ...)
16-
HAMMING = cast(int, ...)
17-
HERMITE = cast(int, ...)
18-
KAISER = cast(int, ...)
19-
QUADRIC = cast(int, ...)
20-
CATROM = cast(int, ...)
21-
GAUSSIAN = cast(int, ...)
22-
BESSEL = cast(int, ...)
23-
MITCHELL = cast(int, ...)
24-
SINC = cast(int, ...)
25-
LANCZOS = cast(int, ...)
26-
BLACKMAN = cast(int, ...)
27-
28-
# ``_InterpolationType`` uses ``.export_values()``, so every member is also
29-
# injected as a module-level constant.
30-
NEAREST: _InterpolationType
31-
BILINEAR: _InterpolationType
32-
BICUBIC: _InterpolationType
33-
SPLINE16: _InterpolationType
34-
SPLINE36: _InterpolationType
35-
HANNING: _InterpolationType
36-
HAMMING: _InterpolationType
37-
HERMITE: _InterpolationType
38-
KAISER: _InterpolationType
39-
QUADRIC: _InterpolationType
40-
CATROM: _InterpolationType
41-
GAUSSIAN: _InterpolationType
42-
BESSEL: _InterpolationType
43-
MITCHELL: _InterpolationType
44-
SINC: _InterpolationType
45-
LANCZOS: _InterpolationType
46-
BLACKMAN: _InterpolationType
47-
48-
def resample(
49-
input_array: np.ndarray,
50-
output_array: np.ndarray,
51-
transform: np.ndarray,
52-
interpolation: _InterpolationType = ...,
53-
resample: bool = ...,
54-
alpha: float = ...,
55-
norm: bool = ...,
56-
radius: float = ...,
57-
) -> None: ...
58-
def calculate_rms_and_diff(
59-
expected_image: np.ndarray, actual_image: np.ndarray
60-
) -> tuple[float, np.ndarray]: ...

‎lib/matplotlib/image.pyi‎

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections.abc import Callable, Sequence
2+
from enum import Enum
23
import os
34
import pathlib
4-
from typing import Any, BinaryIO, Literal
5+
from typing import Any, BinaryIO, Literal, cast
56

67
import numpy as np
78
from numpy.typing import ArrayLike, NDArray
@@ -19,34 +20,58 @@ from matplotlib.transforms import Affine2D, BboxBase, Bbox, Transform
1920
# These names are re-exported from matplotlib._image.
2021
#
2122

22-
BESSEL: int
23-
BICUBIC: int
24-
BILINEAR: int
25-
BLACKMAN: int
26-
CATROM: int
27-
GAUSSIAN: int
28-
HAMMING: int
29-
HANNING: int
30-
HERMITE: int
31-
KAISER: int
32-
LANCZOS: int
33-
MITCHELL: int
34-
NEAREST: int
35-
QUADRIC: int
36-
SINC: int
37-
SPLINE16: int
38-
SPLINE36: int
23+
class _InterpolationType(Enum):
24+
NEAREST = cast(int, ...)
25+
BILINEAR = cast(int, ...)
26+
BICUBIC = cast(int, ...)
27+
SPLINE16 = cast(int, ...)
28+
SPLINE36 = cast(int, ...)
29+
HANNING = cast(int, ...)
30+
HAMMING = cast(int, ...)
31+
HERMITE = cast(int, ...)
32+
KAISER = cast(int, ...)
33+
QUADRIC = cast(int, ...)
34+
CATROM = cast(int, ...)
35+
GAUSSIAN = cast(int, ...)
36+
BESSEL = cast(int, ...)
37+
MITCHELL = cast(int, ...)
38+
SINC = cast(int, ...)
39+
LANCZOS = cast(int, ...)
40+
BLACKMAN = cast(int, ...)
41+
42+
# ``_InterpolationType`` uses ``.export_values()``, so every member is also
43+
# injected as a module-level constant.
44+
NEAREST: _InterpolationType
45+
BILINEAR: _InterpolationType
46+
BICUBIC: _InterpolationType
47+
SPLINE16: _InterpolationType
48+
SPLINE36: _InterpolationType
49+
HANNING: _InterpolationType
50+
HAMMING: _InterpolationType
51+
HERMITE: _InterpolationType
52+
KAISER: _InterpolationType
53+
QUADRIC: _InterpolationType
54+
CATROM: _InterpolationType
55+
GAUSSIAN: _InterpolationType
56+
BESSEL: _InterpolationType
57+
MITCHELL: _InterpolationType
58+
SINC: _InterpolationType
59+
LANCZOS: _InterpolationType
60+
BLACKMAN: _InterpolationType
3961

4062
def resample(
4163
input_array: NDArray[np.float32] | NDArray[np.float64] | NDArray[np.int8],
4264
output_array: NDArray[np.float32] | NDArray[np.float64] | NDArray[np.int8],
4365
transform: Transform,
44-
interpolation: int = ...,
66+
interpolation: _InterpolationType = ...,
4567
resample: bool = ...,
4668
alpha: float = ...,
4769
norm: bool = ...,
4870
radius: float = ...,
4971
) -> None: ...
72+
def calculate_rms_and_diff(
73+
expected_image: np.ndarray, actual_image: np.ndarray
74+
) -> tuple[float, np.ndarray]: ...
5075

5176
#
5277
# END names re-exported from matplotlib._image.

0 commit comments

Comments
 (0)