FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Backport PR #25079 on branch v3.7.x (FIX: Only send one update signal when autoscaling norms) by meeseeksmachine · Pull Request #25082 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 6 additions & 2 deletions lib/matplotlib/colors.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1372,8 +1372,12 @@ def inverse(self, value):

def autoscale(self, A):
"""Set *vmin*, *vmax* to min, max of *A*."""
self.vmin = self.vmax = None
self.autoscale_None(A)
with self.callbacks.blocked():
# Pause callbacks while we are updating so we only get
# a single update signal at the end
self.vmin = self.vmax = None
self.autoscale_None(A)
self._changed()

def autoscale_None(self, A):
"""If vmin or vmax are not set, use the min/max of *A* to set them."""
Expand Down
5 changes: 5 additions & 0 deletions lib/matplotlib/tests/test_colors.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,11 @@ def test_norm_callback():
norm.vmax = 5
assert increment.call_count == 2

# We only want autoscale() calls to send out one update signal
increment.call_count = 0
norm.autoscale([0, 1, 2])
assert increment.call_count == 1


def test_scalarmappable_norm_update():
norm = mcolors.Normalize()
Expand Down

Back | FazBrowse Home | New Git URL