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

Skip to content

MNT: Rename callbacksSM to callbacks #20799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/api/next_api_changes/deprecations/20799-GL.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``ScalarMappable.callbacksSM``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
is deprecated. Use ``ScalarMappable.callbacks`` instead.
2 changes: 1 addition & 1 deletion doc/api/next_api_changes/removals/19552-GL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ ScalarMappable update checkers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``ScalarMappable.update_dict``, ``ScalarMappable.add_checker()``, and
``ScalarMappable.check_update()`` have been removed. A callback can
be registered in ``ScalarMappable.callbacksSM`` to be notified of updates.
be registered in ``ScalarMappable.callbacks`` to be notified of updates.
2 changes: 1 addition & 1 deletion examples/images_contours_and_fields/multi_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def update(changed_image):


for im in images:
im.callbacksSM.connect('changed', update)
im.callbacks.connect('changed', update)

plt.show()

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4923,7 +4923,7 @@ def on_changed(collection):
vbar.set_cmap(collection.get_cmap())
vbar.set_clim(collection.get_clim())

collection.callbacksSM.connect('changed', on_changed)
collection.callbacks.connect('changed', on_changed)

return collection

Expand Down
7 changes: 5 additions & 2 deletions lib/matplotlib/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ def __init__(self, norm=None, cmap=None):
self.set_cmap(cmap) # The Colormap instance of this ScalarMappable.
#: The last colorbar associated with this ScalarMappable. May be None.
self.colorbar = None
self.callbacksSM = cbook.CallbackRegistry()
self.callbacks = cbook.CallbackRegistry()

callbacksSM = _api.deprecated("3.5", alternative="callbacks")(
property(lambda self: self.callbacks))

def _scale_norm(self, norm, vmin, vmax):
"""
Expand Down Expand Up @@ -495,5 +498,5 @@ def changed(self):
Call this whenever the mappable is changed to notify all the
callbackSM listeners to the 'changed' signal.
"""
self.callbacksSM.process('changed', self)
self.callbacks.process('changed', self)
self.stale = True
4 changes: 2 additions & 2 deletions lib/matplotlib/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def __init__(self, ax, mappable=None, *, cmap=None,
alpha = mappable.get_alpha()

mappable.colorbar = self
mappable.colorbar_cid = mappable.callbacksSM.connect(
mappable.colorbar_cid = mappable.callbacks.connect(
'changed', self.update_normal)

_api.check_in_list(
Expand Down Expand Up @@ -981,7 +981,7 @@ def remove(self):
"""
self.ax.remove()

self.mappable.callbacksSM.disconnect(self.mappable.colorbar_cid)
self.mappable.callbacks.disconnect(self.mappable.colorbar_cid)
self.mappable.colorbar = None
self.mappable.colorbar_cid = None

Expand Down