Skip to content

Commit 04a43d6

Browse files
authored
Merge pull request #21112 from anntzer/mnfsn
Fix make_norm_from_scale `__name__` when used inline.
2 parents b8dcf0b + a00a909 commit 04a43d6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/matplotlib/colors.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,8 @@ def inverse(self, value):
15611561
.reshape(np.shape(value)))
15621562
return value[0] if is_scalar else value
15631563

1564-
Norm.__name__ = base_norm_cls.__name__
1564+
Norm.__name__ = (f"{scale_cls.__name__}Norm" if base_norm_cls is Normalize
1565+
else base_norm_cls.__name__)
15651566
Norm.__qualname__ = base_norm_cls.__qualname__
15661567
Norm.__module__ = base_norm_cls.__module__
15671568
Norm.__doc__ = base_norm_cls.__doc__

lib/matplotlib/tests/test_colors.py

+6
Original file line numberDiff line numberDiff line change
@@ -1475,3 +1475,9 @@ def test_norm_update_figs(fig_test, fig_ref):
14751475
# Force initial draw to make sure it isn't already stale
14761476
fig_test.canvas.draw()
14771477
norm.vmin, norm.vmax = 10, 90
1478+
1479+
1480+
def test_make_norm_from_scale_name():
1481+
logitnorm = mcolors.make_norm_from_scale(
1482+
mscale.LogitScale, mcolors.Normalize)
1483+
assert logitnorm.__name__ == "LogitScaleNorm"

0 commit comments

Comments
 (0)