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

Fix callbackregistry docstring. #9687

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
Nov 5, 2017
Merged
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
Fix callbackregistry docstring.
Note in particular `**args` (typo) -> `*args`.
  • Loading branch information
anntzer committed Nov 4, 2017
commit 440e4648b3a474c4b2c0d15c44c1c4440449e552
16 changes: 7 additions & 9 deletions 16 lib/matplotlib/cbook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ def _exception_printer(exc):


class CallbackRegistry(object):
"""Handle registering and disconnecting for a set of signals and
callbacks:
"""Handle registering and disconnecting for a set of signals and callbacks:

>>> def oneat(x):
... print('eat', x)
Expand Down Expand Up @@ -332,9 +331,7 @@ def __setstate__(self, state):
self.__init__(**state)

def connect(self, s, func):
"""
register *func* to be called when a signal *s* is generated
func will be called
"""Register *func* to be called when signal *s* is generated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious to me what the signal s is here, or even what type it should have

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can indeed be anything (hashable):

In [1]: from matplotlib.cbook import CallbackRegistry; cbr = CallbackRegistry()

In [2]: s = object()

In [3]: cbr.connect(s, print)
Out[3]: 1

In [4]: cbr.process(s, "hello world")
hello world

"""
self._func_cid_map.setdefault(s, WeakKeyDictionary())
# Note proxy not needed in python 3.
Expand Down Expand Up @@ -363,8 +360,7 @@ def _remove_proxy(self, proxy):
del self._func_cid_map[signal]

def disconnect(self, cid):
"""
disconnect the callback registered with callback id *cid*
"""Disconnect the callback registered with callback id *cid*.
"""
for eventname, callbackd in list(six.iteritems(self.callbacks)):
try:
Expand All @@ -381,8 +377,10 @@ def disconnect(self, cid):

def process(self, s, *args, **kwargs):
"""
process signal `s`. All of the functions registered to receive
callbacks on `s` will be called with ``**args`` and ``**kwargs``
Process signal *s*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I'm not sure what s should be here


All of the functions registered to receive callbacks on *s* will be
called with ``*args`` and ``**kwargs``.
"""
if s in self.callbacks:
for cid, proxy in list(six.iteritems(self.callbacks[s])):
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.