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

TYP: Adjust type hint of Norm.__call__ to return masked array #26434

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

Merged
merged 2 commits into from
Aug 3, 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
4 changes: 4 additions & 0 deletions 4 lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,9 +2095,13 @@ class NoNorm(Normalize):
indices directly in a `~matplotlib.cm.ScalarMappable`.
"""
def __call__(self, value, clip=None):
if np.iterable(value):
return np.ma.array(value)
return value

def inverse(self, value):
if np.iterable(value):
return np.ma.array(value)
return value


Expand Down
20 changes: 11 additions & 9 deletions 20 lib/matplotlib/colors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,17 @@ class Normalize:
def clip(self, value: bool) -> None: ...
@staticmethod
def process_value(value: ArrayLike) -> tuple[np.ma.MaskedArray, bool]: ...
@overload
def __call__(self, value: float, clip: bool | None = ...) -> float: ...
@overload
def __call__(self, value: np.ndarray, clip: bool | None = ...) -> np.ma.MaskedArray: ...
@overload
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
@overload
def inverse(self, value: float) -> float: ...
@overload
def inverse(self, value: np.ndarray) -> np.ma.MaskedArray: ...
@overload
def inverse(self, value: ArrayLike) -> ArrayLike: ...
def autoscale(self, A: ArrayLike) -> None: ...
def autoscale_None(self, A: ArrayLike) -> None: ...
Expand All @@ -161,8 +171,6 @@ class TwoSlopeNorm(Normalize):
@vcenter.setter
def vcenter(self, value: float) -> None: ...
def autoscale_None(self, A: ArrayLike) -> None: ...
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
def inverse(self, value: ArrayLike) -> ArrayLike: ...

class CenteredNorm(Normalize):
def __init__(
Expand Down Expand Up @@ -240,8 +248,6 @@ class PowerNorm(Normalize):
vmax: float | None = ...,
clip: bool = ...,
) -> None: ...
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
def inverse(self, value: ArrayLike) -> ArrayLike: ...

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

class NoNorm(Normalize):
def __call__(self, value: ArrayLike, clip: bool | None = ...) -> ArrayLike: ...
def inverse(self, value: ArrayLike) -> ArrayLike: ...
class NoNorm(Normalize): ...

def rgb_to_hsv(arr: ArrayLike) -> np.ndarray: ...
def hsv_to_rgb(hsv: ArrayLike) -> np.ndarray: ...
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.