8000 TST: Adding tests for clip and vcenter to norm updater · matplotlib/matplotlib@b26748d · GitHub
[go: up one dir, main page]

Skip to content

Commit b26748d

Browse files
committed
TST: Adding tests for clip and vcenter to norm updater
1 parent 3c6e144 commit b26748d

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/colors.py

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

14401440
@vcenter.setter
14411441
def vcenter(self, vcenter):
1442-
self._vcenter = vcenter
1442+
if vcenter != self._vcenter:
1443+
self._vcenter = vcenter
1444+
self._changed()
14431445
if self.vmax is not None:
14441446
# recompute halfrange assuming vmin and vmax represent
14451447
# 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
@@ -1417,3 +1417,17 @@ def test_scalarmappable_norm_update():
14171417
sm.stale = False
14181418
norm.vmax = 5
14191419
assert sm.stale
1420+
sm.stale = False
1421+
norm.clip = True
1422+
assert sm.stale
1423+
# change to the CenteredNorm and TwoSlopeNorm to test those
1424+
norm = mcolors.CenteredNorm()
1425+
sm = matplotlib.cm.ScalarMappable(norm=norm, cmap='plasma')
1426+
sm.stale = False
1427+
norm.vcenter = 1
1428+
assert sm.stale
1429+
norm = mcolors.TwoSlopeNorm(vcenter=0, vmin=-1, vmax=1)
1430+
sm = matplotlib.cm.ScalarMappable(norm=norm, cmap='plasma')
1431+
sm.stale = False
1432+
norm.vcenter = 1
1433+
assert sm.stale

0 commit comments

Comments
 (0)
0