Skip to content

Fix make_norm_from_scale __name__ when used inline. #21112

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 1 commit into from
Sep 19, 2021
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
3 changes: 2 additions & 1 deletion lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,8 @@ def inverse(self, value):
.reshape(np.shape(value)))
return value[0] if is_scalar else value

Norm.__name__ = base_norm_cls.__name__
Norm.__name__ = (f"{scale_cls.__name__}Norm" if base_norm_cls is Normalize
else base_norm_cls.__name__)
Norm.__qualname__ = base_norm_cls.__qualname__
Norm.__module__ = base_norm_cls.__module__
Norm.__doc__ = base_norm_cls.__doc__
Expand Down
6 changes: 6 additions & 0 deletions lib/matplotlib/tests/test_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,3 +1475,9 @@ def test_norm_update_figs(fig_test, fig_ref):
# Force initial draw to make sure it isn't already stale
fig_test.canvas.draw()
norm.vmin, norm.vmax = 10, 90


def test_make_norm_from_scale_name():
logitnorm = mcolors.make_norm_from_scale(
mscale.LogitScale, mcolors.Normalize)
assert logitnorm.__name__ == "LogitScaleNorm"