8000 Merge pull request #20799 from greglucas/rename-callbacksSM · matplotlib/matplotlib@d77783b · GitHub
[go: up one dir, main page]

Skip to content

Commit d77783b

Browse files
authored
Merge pull request #20799 from greglucas/rename-callbacksSM
MNT: Rename callbacksSM to callbacks
2 parents a8977fd + 5a4c8db commit d77783b

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``ScalarMappable.callbacksSM``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
is deprecated. Use ``ScalarMappable.callbacks`` instead.

doc/api/next_api_changes/removals/19552-GL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ ScalarMappable update checkers
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33
``ScalarMappable.update_dict``, ``ScalarMappable.add_checker()``, and
44
``ScalarMappable.check_update()`` have been removed. A callback can
5-
be registered in ``ScalarMappable.callbacksSM`` to be notified of updates.
5+
be registered in ``ScalarMappable.callbacks`` to be notified of updates.

examples/images_contours_and_fields/multi_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def update(changed_image):
4747

4848

4949
for im in images:
50-
im.callbacksSM.connect('changed', update)
50+
im.callbacks.connect('changed', update)
5151

5252
plt.show()
5353

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ def on_changed(collection):
49234923
vbar.set_cmap(collection.get_cmap())
49244924
vbar.set_clim(collection.get_clim())
49254925

4926-
collection.callbacksSM.connect('changed', on_changed)
4926+
collection.callbacks.connect('changed', on_changed)
49274927

49284928
return collection
49294929

lib/matplotlib/cm.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ def __init__(self, norm=None, cmap=None):
263263
self.set_cmap(cmap) # The Colormap instance of this ScalarMappable.
264264
#: The last colorbar associated with this ScalarMappable. May be None.
265265
self.colorbar = None
266-
self.callbacksSM = cbook.CallbackRegistry()
266+
self.callbacks = cbook.CallbackRegistry()
267+
268+
callbacksSM = _api.deprecated("3.5", alternative="callbacks")(
269+
property(lambda self: self.callbacks))
267270

268271
def _scale_norm(self, norm, vmin, vmax):
269272
"""
@@ -495,5 +498,5 @@ def changed(self):
495498
Call this whenever the mappable is changed to notify all the
496499
callbackSM listeners to the 'changed' signal.
497500
"""
498-
self.callbacksSM.process('changed', self)
501+
self.callbacks.process('changed', self)
499502
self.stale = True

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
416416
alpha = mappable.get_alpha()
417417

418418
mappable.colorbar = self
419-
mappable.colorbar_cid = mappable.callbacksSM.connect(
419+
mappable.colorbar_cid = mappable.callbacks.connect(
420420
'changed', self.update_normal)
421421

422422
_api.check_in_list(
@@ -1000,7 +1000,7 @@ def remove(self):
10001000
"""
10011001
self.ax.remove()
10021002

1003-
self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid)
1003+
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)
10041004
self.mappable.colorbar = None
10051005
self.mappable.colorbar_cid = None
10061006

0 commit comments

Comments
 (0)
0