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

Skip to content

Commit 5a4c8db

Browse files
committed
MNT: Rename callbacksSM to callbacks
This makes the code more consistent throughout with objects having a `callbacks` attribute, rather than associating a name with them on the end.
1 parent ec126b0 commit 5a4c8db

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
@@ -404,7 +404,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
404404
alpha = mappable.get_alpha()
405405

406406
mappable.colorbar = self
407-
mappable.colorbar_cid = mappable.callbacksSM.connect(
407+
mappable.colorbar_cid = mappable.callbacks.connect(
408408
'changed', self.update_normal)
409409

410410
_api.check_in_list(
@@ -981,7 +981,7 @@ def remove(self):
981981
"""
982982
self.ax.remove()
983983

984-
self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid)
984+
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)
985985
self.mappable.colorbar = None
986986
self.mappable.colorbar_cid = None
987987

0 commit comments

Comments
 (0)