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

Skip to content

Docstring cleanup #14337

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
May 27, 2019
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
4 changes: 2 additions & 2 deletions lib/matplotlib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1091,12 +1091,12 @@ def get_ticklabel_extents(self, renderer):
return bbox, bbox2

def set_smart_bounds(self, value):
"""set the axis to have smart bounds"""
"""Set the axis to have smart bounds."""
self._smart_bounds = value
self.stale = True

def get_smart_bounds(self):
"""get whether the axis has smart bounds"""
"""Return whether the axis has smart bounds."""
return self._smart_bounds

def _update_ticks(self):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/_backend_tk.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def idle_draw(*args):
self._idle_callback = self._tkcanvas.after_idle(idle_draw)

def get_tk_widget(self):
"""returns the Tk widget used to implement FigureCanvasTkAgg.
"""Return the Tk widget used to implement FigureCanvasTkAgg.
Although the initial implementation uses a Tk canvas, this routine
is intended to hide that fact.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/gridspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_subplot_params(self, figure=None, fig=None):

def new_subplotspec(self, loc, rowspan=1, colspan=1):
"""
create and return a SubplotSpec instance.
Create and return a SubplotSpec instance.
"""
loc1, loc2 = loc
subplotspec = self[loc1:loc1+rowspan, loc2:loc2+colspan]
Expand Down
28 changes: 14 additions & 14 deletions lib/matplotlib/rcsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def validate_bool(b):


def validate_bool_maybe_none(b):
'Convert b to a boolean or raise'
"""Convert b to a boolean or raise."""
if isinstance(b, str):
b = b.lower()
if b is None or b == 'none':
Expand All @@ -145,7 +145,7 @@ def validate_bool_maybe_none(b):


def validate_float(s):
"""convert s to float or raise"""
"""Convert s to float or raise."""
try:
return float(s)
except ValueError:
Expand All @@ -154,7 +154,7 @@ def validate_float(s):


def validate_float_or_None(s):
"""convert s to float, None or raise"""
"""Convert s to float, None or raise."""
# values directly from the rc file can only be strings,
# so we need to recognize the string "None" and convert
# it into the object. We will be case-sensitive here to
Expand All @@ -169,7 +169,7 @@ def validate_float_or_None(s):


def validate_string_or_None(s):
"""convert s to string or raise"""
"""Convert s to string or raise."""
if s is None:
return None
try:
Expand Down Expand Up @@ -205,7 +205,7 @@ def validate_axisbelow(s):


def validate_dpi(s):
"""confirm s is string 'figure' or convert s to float or raise"""
"""Confirm s is string 'figure' or convert s to float or raise."""
if s == 'figure':
return s
try:
Expand All @@ -216,15 +216,15 @@ def validate_dpi(s):


def validate_int(s):
"""convert s to int or raise"""
"""Convert s to int or raise."""
try:
return int(s)
except ValueError:
raise ValueError('Could not convert "%s" to int' % s)


def validate_int_or_None(s):
"""if not None, tries to validate as an int"""
"""Return None if s is None or return ``int(s)``, otherwise raise."""
if s == 'None':
s = None
if s is None:
Expand All @@ -237,8 +237,8 @@ def validate_int_or_None(s):

def validate_fonttype(s):
"""
confirm that this is a Postscript of PDF font type that we know how to
convert to
Confirm that this is a Postscript or PDF font type that we know how to
convert to.
"""
fonttypes = {'type3': 3,
'truetype': 42}
Expand Down Expand Up @@ -305,7 +305,7 @@ def __init__(self, n=None, allow_none=False):
self.allow_none = allow_none

def __call__(self, s):
"""return a seq of n floats or raise"""
"""Return a list of *n* floats or raise."""
if isinstance(s, str):
s = [x.strip() for x in s.split(',')]
err_msg = _str_err_msg
Expand All @@ -329,7 +329,7 @@ def __init__(self, n=None):
self.n = n

def __call__(self, s):
"""return a seq of n ints or raise"""
"""Return a list of *n* ints or raise."""
if isinstance(s, str):
s = [x.strip() for x in s.split(',')]
err_msg = _str_err_msg
Expand All @@ -346,7 +346,7 @@ def __call__(self, s):


def validate_color_or_inherit(s):
'return a valid color arg'
"""Return a valid color arg."""
if s == 'inherit':
return s
return validate_color(s)
Expand Down Expand Up @@ -375,7 +375,7 @@ def validate_color_for_prop_cycle(s):


def validate_color(s):
'return a valid color arg'
"""Return a valid color arg."""
try:
if s.lower() == 'none':
return 'none'
Expand Down Expand Up @@ -867,7 +867,7 @@ def cycler(*args, **kwargs):


def validate_cycler(s):
'return a Cycler object from a string repr or the object itself'
"""Return a Cycler object from a string repr or the object itself."""
if isinstance(s, str):
try:
# TODO: We might want to rethink this...
Expand Down
26 changes: 13 additions & 13 deletions lib/matplotlib/spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
self._patch_transform = mtransforms.IdentityTransform()

def set_smart_bounds(self, value):
"""set the spine and associated axis to have smart bounds"""
"""Set the spine and associated axis to have smart bounds."""
self._smart_bounds = value

# also set the axis if possible
Expand All @@ -91,11 +91,11 @@ def set_smart_bounds(self, value):
self.stale = True

def get_smart_bounds(self):
"""get whether the spine has smart bounds"""
"""Return whether the spine has smart bounds."""
return self._smart_bounds

def set_patch_arc(self, center, radius, theta1, theta2):
"""set the spine to be arc-like"""
"""Set the spine to be arc-like."""
self._patch_type = 'arc'
self._center = center
self._width = radius * 2
Expand All @@ -108,7 +108,7 @@ def set_patch_arc(self, center, radius, theta1, theta2):
self.stale = True

def set_patch_circle(self, center, radius):
"""set the spine to be circular"""
"""Set the spine to be circular."""
self._patch_type = 'circle'
self._center = center
self._width = radius * 2
Expand All @@ -118,7 +118,7 @@ def set_patch_circle(self, center, radius):
self.stale = True

def set_patch_line(self):
"""set the spine to be linear"""
"""Set the spine to be linear."""
self._patch_type = 'line'
self.stale = True

Expand Down Expand Up @@ -213,7 +213,7 @@ def _ensure_position_is_set(self):
self.set_position(self._position)

def register_axis(self, axis):
"""register an axis
"""Register an axis.

An axis should be registered with its corresponding spine from
the Axes instance. This allows the spine to clear any axis
Expand All @@ -225,14 +225,14 @@ def register_axis(self, axis):
self.stale = True

def cla(self):
"""Clear the current spine"""
"""Clear the current spine."""
self._position = None # clear position
if self.axis is not None:
self.axis.cla()

@cbook.deprecated("3.1")
def is_frame_like(self):
"""return True if directly on axes frame
"""Return True if directly on axes frame.

This is useful for determining if a spine is the edge of an
old style MPL plot. If so, this function will return True.
Expand All @@ -253,7 +253,7 @@ def is_frame_like(self):
return False

def _adjust_location(self):
"""automatically set spine bounds to the view interval"""
"""Automatically set spine bounds to the view interval."""

if self.spine_type == 'circle':
return
Expand Down Expand Up @@ -368,7 +368,7 @@ def draw(self, renderer):
return ret

def _calc_offset_transform(self):
"""calculate the offset transform performed by the spine"""
"""Calculate the offset transform performed by the spine."""
self._ensure_position_is_set()
position = self._position
if isinstance(position, str):
Expand Down Expand Up @@ -442,7 +442,7 @@ def _calc_offset_transform(self):
mtransforms.IdentityTransform())

def set_position(self, position):
"""set the position of the spine
"""Set the position of the spine.

Spine position is specified by a 2 tuple of (position type,
amount). The position types are:
Expand Down Expand Up @@ -481,12 +481,12 @@ def set_position(self, position):
self.stale = True

def get_position(self):
"""get the spine position"""
"""Return the spine position."""
self._ensure_position_is_set()
return self._position

def get_spine_transform(self):
"""get the spine transform"""
"""Return the spine transform."""
self._ensure_position_is_set()
what, how = self._spine_transform

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def set_active(self, index):

def get_status(self):
"""
returns a tuple of the status (True/False) of all of the check buttons
Return a tuple of the status (True/False) of all of the check buttons.
"""
return [l1.get_visible() for (l1, l2) in self.lines]

Expand Down
12 changes: 5 additions & 7 deletions lib/mpl_toolkits/axes_grid1/axes_divider.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
def append_axes(self, position, size, pad=None, add_to_figure=True,
**kwargs):
"""
create an axes at the given *position* with the same height
Create an axes at the given *position* with the same height
(or width) of the main axes.

*position*
Expand Down Expand Up @@ -713,9 +713,8 @@ def _calc_offsets(appended_sizes, karray):

def new_locator(self, nx, nx1=None):
"""
returns a new locator
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
specified cell.
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
the specified cell.

Parameters
----------
Expand Down Expand Up @@ -806,9 +805,8 @@ class VBoxDivider(HBoxDivider):

def new_locator(self, ny, ny1=None):
"""
returns a new locator
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
specified cell.
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
the specified cell.

Parameters
----------
Expand Down
5 changes: 4 additions & 1 deletion lib/mpl_toolkits/axes_grid1/axes_rgb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True):
"""
pad : fraction of the axes height.
Parameters
----------
pad : float
Fraction of the axes height.
"""

divider = make_axes_locatable(ax)
Expand Down
27 changes: 12 additions & 15 deletions lib/mpl_toolkits/axes_grid1/parasite_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,11 @@ def pick(self, mouseevent):

def twinx(self, axes_class=None):
"""
create a twin of Axes for generating a plot with a sharex
x-axis but independent y axis. The y-axis of self will have
ticks on left and the returned axes will have ticks on the
right
"""
Create a twin of Axes with a shared x-axis but independent y-axis.

The y-axis of self will have ticks on the left and the returned axes
will have ticks on the right.
"""
if axes_class is None:
axes_class = self._get_base_axes()

Expand All @@ -280,12 +279,11 @@ def _remove_twinx(self, ax):

def twiny(self, axes_class=None):
"""
create a twin of Axes for generating a plot with a shared
y-axis but independent x axis. The x-axis of self will have
ticks on bottom and the returned axes will have ticks on the
top
"""
Create a twin of Axes with a shared y-axis but independent x-axis.

The x-axis of self will have ticks on the bottom and the returned axes
will have ticks on the top.
"""
if axes_class is None:
axes_class = self._get_base_axes()

Expand All @@ -309,12 +307,11 @@ def _remove_twiny(self, ax):

def twin(self, aux_trans=None, axes_class=None):
"""
create a twin of Axes for generating a plot with a sharex
x-axis but independent y axis. The y-axis of self will have
ticks on left and the returned axes will have ticks on the
right
"""
Create a twin of Axes with no shared axis.

While self will have ticks on the left and bottom axis, the returned
axes will have ticks on the top and right axis.
"""
if axes_class is None:
axes_class = self._get_base_axes()

Expand Down