Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89f8a7f

Browse files
committed
TST: Adding tests for clip and vcenter to norm updater
1 parent 5257731 commit 89f8a7f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

lib/matplotlib/colors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1454,7 +1454,9 @@ def vcenter(self):
14541454

14551455
@vcenter.setter
14561456
def vcenter(self, vcenter):
1457-
self._vcenter = vcenter
1457+
if vcenter != self._vcenter:
1458+
self._vcenter = vcenter
1459+
self._changed()
14581460
if self.vmax is not None:
14591461
# recompute halfrange assuming vmin and vmax represent
14601462
# min and max of data

lib/matplotlib/tests/test_colors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,3 +1446,17 @@ def test_scalarmappable_norm_update():
14461446
sm.stale = False
14471447
norm.vmax = 5
14481448
assert sm.stale
1449+
sm.stale = False
1450+
norm.clip = True
1451+
assert sm.stale
1452+
# change to the CenteredNorm and TwoSlopeNorm to test those
1453+
norm = mcolors.CenteredNorm()
1454+
sm = matplotlib.cm.ScalarMappable(norm=norm, cmap='plasma')
1455+
sm.stale = False
1456+
norm.vcenter = 1
1457+
assert sm.stale
1458+
norm = mcolors.TwoSlopeNorm(vcenter=0, vmin=-1, vmax=1)
1459+
sm = matplotlib.cm.ScalarMappable(norm=norm, cmap='plasma')
1460+
sm.stale = False
1461+
norm.vcenter = 1
1462+
assert sm.stale

0 commit comments

Comments
 (0)