Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9bba195

Browse filesBrowse files
authored
Merge pull request #26434 from ksunden/norm_masked_array
TYP: Adjust type hint of Norm.__call__ to return masked array
2 parents ea8cf0d + 6385edc commit 9bba195
Copy full SHA for 9bba195

File tree

Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-9
lines changed

‎lib/matplotlib/colors.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,9 +2095,13 @@ class NoNorm(Normalize):
20952095
indices directly in a `~matplotlib.cm.ScalarMappable`.
20962096
"""
20972097
def __call__(self, value, clip=None):
2098+
if np.iterable(value):
2099+
return np.ma.array(value)
20982100
return value
20992101

21002102
def inverse(self, value):
2103+
if np.iterable(value):
2104+
return np.ma.array(value)
21012105
return value
21022106

21032107

‎lib/matplotlib/colors.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/colors.pyi
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,17 @@ class Normalize:
146146
def clip(self, value: bool) -> None: ...
147147
@staticmethod
148148
def process_value(value: ArrayLike) -> tuple[np.ma.MaskedArray, bool]: ...
149+
@overload
150+
def __call__(self, value: float, clip: bool | None = ...) -> float: ...
151+
@overload
152+
def __call__(self, value: np.ndarray, clip: bool | None = ...) -> np.ma.MaskedArray: ...
153+
@overload
149154
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
155+
@overload
156+
def inverse(self, value: float) -> float: ...
157+
@overload
158+
def inverse(self, value: np.ndarray) -> np.ma.MaskedArray: ...
159+
@overload
150160
def inverse(self, value: ArrayLike) -> ArrayLike: ...
151161
def autoscale(self, A: ArrayLike) -> None: ...
152162
def autoscale_None(self, A: ArrayLike) -> None: ...
@@ -161,8 +171,6 @@ class TwoSlopeNorm(Normalize):
161171
@vcenter.setter
162172
def vcenter(self, value: float) -> None: ...
163173
def autoscale_None(self, A: ArrayLike) -> None: ...
164-
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
165-
def inverse(self, value: ArrayLike) -> ArrayLike: ...
166174

167175
class CenteredNorm(Normalize):
168176
def __init__(
@@ -240,8 +248,6 @@ class PowerNorm(Normalize):
240248
vmax: float | None = ...,
241249
clip: bool = ...,
242250
) -> None: ...
243-
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
244-
def inverse(self, value: ArrayLike) -> ArrayLike: ...
245251

246252
class BoundaryNorm(Normalize):
247253
boundaries: np.ndarray
@@ -256,12 +262,8 @@ class BoundaryNorm(Normalize):
256262
*,
257263
extend: Literal["neither", "both", "min", "max"] = ...
258264
) -> None: ...
259-
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
260-
def inverse(self, value: ArrayLike) -> ArrayLike: ...
261265

262-
class NoNorm(Normalize):
263-
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
264-
def inverse(self, value: ArrayLike) -> ArrayLike: ...
266+
class NoNorm(Normalize): ...
265267

266268
def rgb_to_hsv(arr: ArrayLike) -> np.ndarray: ...
267269
def hsv_to_rgb(hsv: ArrayLike) -> np.ndarray: ...

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.