Skip to content

Convert slider docstrings to numpydoc #9517

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
Oct 22, 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
33 changes: 28 additions & 5 deletions lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ def _update(self, event):
self.set_val(val)

def set_val(self, val):
"""
Set slider value to *val*

Parameters
----------
val : float
"""
xy = self.poly.xy
xy[2] = val, 1
xy[3] = val, 0
Expand All @@ -437,25 +444,41 @@ def set_val(self, val):

def on_changed(self, func):
"""
When the slider value is changed, call *func* with the new
slider position
When the slider value is changed call *func* with the new
slider value

A connection id is returned which can be used to disconnect
Parameters
----------
func : callable
Function to call when slider is changed.
The function must accept a single float as its arguments.

Returns
-------
cid : int
Connection id (which can be used to disconnect *func*)
"""
cid = self.cnt
self.observers[cid] = func
self.cnt += 1
return cid

def disconnect(self, cid):
"""remove the observer with connection id *cid*"""
"""
Remove the observer with connection id *cid*

Parameters
----------
cid : int
Connection id of the observer to be removed
"""
try:
del self.observers[cid]
except KeyError:
pass

def reset(self):
"""reset the slider to the initial value if needed"""
"""Reset the slider to the initial value"""
if (self.val != self.valinit):
self.set_val(self.valinit)

Expand Down