Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d971c59

Browse filesBrowse files
authored
Merge pull request #17166 from anntzer/updatedict
Deprecate ScalarMappable.check_update and associated machinery.
2 parents 6134ced + c016538 commit d971c59
Copy full SHA for d971c59

File tree

Expand file treeCollapse file tree

3 files changed

+32
-18
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+32
-18
lines changed

‎doc/api/api_changes_3.3/deprecations.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes_3.3/deprecations.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,8 @@ needed.
450450
The associated helper methods ``NavigationToolbar2.draw()`` and
451451
``ToolViewsPositions.refresh_locators()`` are deprecated, and should be
452452
replaced by calls to ``draw_idle()`` on the corresponding canvas.
453+
454+
`.ScalarMappable` checkers
455+
~~~~~~~~~~~~~~~~~~~~~~~~~~
456+
The ``add_checker`` and ``check_update`` methods and ``update_dict`` attribute
457+
of `.ScalarMappable` are deprecated.

‎lib/matplotlib/cm.py

Copy file name to clipboardExpand all lines: lib/matplotlib/cm.py
+24-15Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def __init__(self, norm=None, cmap=None):
177177
#: The last colorbar associated with this ScalarMappable. May be None.
178178
self.colorbar = None
179179
self.callbacksSM = cbook.CallbackRegistry()
180-
self.update_dict = {'array': False}
180+
self._update_dict = {'array': False}
181181

182182
def _scale_norm(self, norm, vmin, vmax):
183183
"""
@@ -279,7 +279,7 @@ def set_array(self, A):
279279
A : ndarray
280280
"""
281281
self._A = A
282-
self.update_dict['array'] = True
282+
self._update_dict['array'] = True
283283

284284
def get_array(self):
285285
"""Return the data array."""
@@ -386,30 +386,39 @@ def autoscale_None(self):
386386
self.norm.autoscale_None(self._A)
387387
self.changed()
388388

389-
def add_checker(self, checker):
389+
def _add_checker(self, checker):
390390
"""
391391
Add an entry to a dictionary of boolean flags
392392
that are set to True when the mappable is changed.
393393
"""
394-
self.update_dict[checker] = False
394+
self._update_dict[checker] = False
395395

396-
def check_update(self, checker):
397-
"""
398-
If mappable has changed since the last check,
399-
return True; else return False
400-
"""
401-
if self.update_dict[checker]:
402-
self.update_dict[checker] = False
396+
def _check_update(self, checker):
397+
"""Return whether mappable has changed since the last check."""
398+
if self._update_dict[checker]:
399+
self._update_dict[checker] = False
403400
return True
404401
return False
405402

406403
def changed(self):
407404
"""
408405
Call this whenever the mappable is changed to notify all the
409-
callbackSM listeners to the 'changed' signal
406+
callbackSM listeners to the 'changed' signal.
410407
"""
411408
self.callbacksSM.process('changed', self)
412-
413-
for key in self.update_dict:
414-
self.update_dict[key] = True
409+
for key in self._update_dict:
410+
self._update_dict[key] = True
415411
self.stale = True
412+
413+
@cbook.deprecated("3.3")
414+
@property
415+
def update_dict(self):
416+
return self._update_dict
417+
418+
@cbook.deprecated("3.3")
419+
def add_checker(self, checker):
420+
return self._add_checker(checker)
421+
422+
@cbook.deprecated("3.3")
423+
def check_update(self, checker):
424+
return self.check_update(checker)

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ def set_edgecolor(self, c):
768768
def set_alpha(self, alpha):
769769
# docstring inherited
770770
super().set_alpha(alpha)
771-
self.update_dict['array'] = True
771+
self._update_dict['array'] = True
772772
self._set_facecolor(self._original_facecolor)
773773
self._set_edgecolor(self._original_edgecolor)
774774

@@ -784,7 +784,7 @@ def update_scalarmappable(self):
784784
return
785785
if self._A.ndim > 1:
786786
raise ValueError('Collections can only map rank 1 arrays')
787-
if not self.check_update("array"):
787+
if not self._check_update("array"):
788788
return
789789
if self._is_filled:
790790
self._facecolors = self.to_rgba(self._A, self._alpha)
@@ -815,7 +815,7 @@ def update_from(self, other):
815815
self._A = other._A
816816
self.norm = other.norm
817817
self.cmap = other.cmap
818-
# self.update_dict = other.update_dict # do we need to copy this? -JJL
818+
# do we need to copy self._update_dict? -JJL
819819
self.stale = True
820820

821821

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.