8000 Fix pydocstyle D208 (Docstring is over-indented) by timhoffm · Pull Request #14496 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix pydocstyle D208 (Docstring is over-indented) #14496

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
Jun 9, 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
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ignore =
N801, N802, N803, N806, N812,
# pydocstyle
D100, D101, D102, D103, D104, D105, D106, D107,
D200, D202, D203, D204, D205, D207, D208, D209, D212, D213,
D200, D202, D203, D204, D205, D207, D209, D212, D213,
D300, D301
D400, D401, D402, D403, D413,

Expand Down
15 changes: 8 additions & 7 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,23 +1249,24 @@ def get_backend():

def interactive(b):
8000 """
Set interactive mode to boolean b.

If b is True, then draw after every plotting command, e.g., after xlabel
Set whether to redraw after every plotting command (e.g. `.pyplot.xlabel`).
"""
rcParams['interactive'] = b


def is_interactive():
'Return true if plot mode is interactive'
"""Return whether to redraw after every plotting command."""
return rcParams['interactive']


@cbook.deprecated("3.1", alternative="rcParams['tk.window_focus']")
def tk_window_focus():
"""Return true if focus maintenance under TkAgg on win32 is on.
This currently works only for python.exe and IPython.exe.
Both IDLE and Pythonwin.exe fail badly when tk_window_focus is on."""
"""
Return true if focus maintenance under TkAgg on win32 is on.

This currently works only for python.exe and IPython.exe.
Both IDLE and Pythonwin.exe fail badly when tk_window_focus is on.
"""
if rcParams['backend'] != 'TkAgg':
return False
return rcParams['tk.window_focus']
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,16 +613,16 @@ def set_bad(self, color='k', alpha=None):
self._set_extremes()

def set_under(self, color='k', alpha=None):
"""Set color to be used for low out-of-range values.
Requires norm.clip = False
"""
Set the color for low out-of-range values when ``norm.clip = False``.
"""
self._rgba_under = to_rgba(color, alpha)
if self._isinit:
self._set_extremes()

def set_over(self, color='k', alpha=None):
"""Set color to be used for high out-of-range values.
Requires norm.clip = False
"""
Set the color for high out-of-range values when ``norm.clip = False``.
"""
self._rgba_over = to_rgba(color, alpha)
if self._isinit:
Expand Down
35 changes: 25 additions & 10 deletions lib/matplotlib/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,12 +321,22 @@ class strpdate2num:
you know the date format string of the date you are parsing.
"""
def __init__(self, fmt):
"""fmt: any valid strptime format is supported"""
"""
Parameters
----------
fmt : any valid strptime format
"""
self.fmt = fmt

def __call__(self, s):
"""s : string to be converted
return value: a date2num float
"""
Parameters
----------
s : str

Returns
-------
date2num float
"""
return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))

Expand All @@ -341,19 +351,24 @@ class bytespdate2num(strpdate2num):
"""
def __init__(self, fmt, encoding='utf-8'):
"""
Args:
fmt: any valid strptime format is supported
encoding: encoding to use on byte input (default: 'utf-8')
Parameters
----------
fmt : any valid strptime format
encoding : str
Encoding to use on byte input.
"""
super().__init__(fmt)
self.encoding = encoding

def __call__(self, b):
"""
Args:
b: byte input to be converted
Returns:
A date2num float
Parameters
----------
b : bytes

Returns
-------
date2num float
"""
s = b.decode(self.encoding)
return super().__call__(s)
Expand Down
28 changes: 17 additions & 11 deletions lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,10 +709,13 @@ def get_path(self):
return Path.unit_rectangle()

def _update_patch_transform(self):
"""NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
makes it very important to call the accessor method and
not directly access the transformation member variable.
"""
Notes
-----
This cannot be called until after this has been added to an Axes,
otherwise unit conversion will fail. This makes it very important to
call the accessor method and not directly access the transformation
member variable.
"""
x0, y0, x1, y1 = self._convert_units()
bbox = transforms.Bbox.from_extents(x0, y0, x1, y1)
Expand Down Expand Up @@ -1364,10 +1367,13 @@ def __init__(self, xy, width, height, angle=0, **kwargs):
self._patch_transform = transforms.IdentityTransform()

def _recompute_transform(self):
"""NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
makes it very important to call the accessor method and
not directly access the transformation member variable.
"""
Notes
-----
This cannot be called until after this has been added to an Axes,
otherwise unit conversion will fail. This makes it very important to
call the accessor method and not directly access the transformation
member variable.
"""
center = (self.convert_xunits(self._center[0]),
self.convert_yunits(self._center[1]))
Expand Down Expand Up @@ -1941,10 +1947,10 @@ class Square(_Base):

def __init__(self, pad=0.3):
"""
*pad*
amount of padding
Parameters
----------
pad : float
"""

self.pad = pad
super().__init__()

Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def show(*args, **kw):


def isinteractive():
"""Return the status of interactive mode."""
"""Return whether to redraw after every plotting command."""
return matplotlib.is_interactive()


Expand Down Expand Up @@ -1007,7 +1007,7 @@ def subplot(*args, **kwargs):

# add ax2 to the figure again
plt.subplot(ax2)
"""
"""

# if subplot called without arguments, create subplot(1,1,1)
if len(args) == 0:
Expand Down
11 changes: 7 additions & 4 deletions lib/matplotlib/spines.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,13 @@ def set_patch_line(self):

# Behavior copied from mpatches.Ellipse:
def _recompute_transform(self):
"""NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
makes it very important to call the accessor method and
not directly access the transformation member variable.
"""
Notes
-----
This cannot be called until after this has been added to an Axes,
otherwise unit conversion will fail. This makes it very important to
call the accessor method and not directly access the transformation
member variable.
"""
assert self._patch_type in ('arc', 'circle')
center = (self.convert_xunits(self._center[0]),
Expand Down
13 changes: 7 additions & 6 deletions lib/matplotlib/testing/jpl_units/EpochConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@


class EpochConverter(units.ConversionInterface):
""": A matplotlib converter class. Provides matplotlib conversion
functionality for Monte Epoch and Duration classes.
"""
Provides Matplotlib conversion functionality for Monte Epoch and Duration
classes.
"""

# julian date reference for "Jan 1, 0001" minus 1 day because
# matplotlib really wants "Jan 0, 0001"
# Matplotlib really wants "Jan 0, 0001"
jdRef = 1721425.5 - 1

@staticmethod
Expand All @@ -26,7 +27,7 @@ def axisinfo(unit, axis):
- unit The units to use for a axis with Epoch data.

= RETURN VALUE
- Returns a matplotlib AxisInfo data structure that contains
- Returns a AxisInfo data structure that contains
minor/major formatters, major/minor locators, and default
label information.
"""
Expand All @@ -38,11 +39,11 @@ def axisinfo(unit, axis):

@staticmethod
def float2epoch(value, unit):
""": Convert a matplotlib floating-point date into an Epoch of the
""": Convert a Matplotlib floating-point date into an Epoch of the
specified units.

= INPUT VARIABLES
- value The matplotlib floating-point date.
- value The Matplotlib floating-point date.
- unit The unit system to use for the Epoch.

= RETURN VALUE
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/testing/jpl_units/UnitDblConverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def rad_fn(x, pos=None):


class UnitDblConverter(units.ConversionInterface):
""": A matplotlib converter class. Provides matplotlib conversion
functionality for the Monte UnitDbl class.
"""
Provides Matplotlib conversion functionality for the Monte UnitDbl class.
"""
# default for plotting
defaults = {
Expand Down
15 changes: 7 additions & 8 deletions lib/matplotlib/testing/jpl_units/UnitDblFormatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,23 @@


class UnitDblFormatter(ticker.ScalarFormatter):
"""The formatter for UnitDbl data types. This allows for formatting
with the unit string.
"""
def __init__(self, *args, **kwargs):
'The arguments are identical to matplotlib.ticker.ScalarFormatter.'
ticker.ScalarFormatter.__init__(self, *args, **kwargs)
The formatter for UnitDbl data types.

This allows for formatting with the unit string.
"""

def __call__(self, x, pos=None):
'Return the format for tick val x at position pos'
# docstring inherited
if len(self.locs) == 0:
return ''
else:
return '{:.12}'.format(x)

def format_data_short(self, value):
"Return the value formatted in 'short' format."
# docstring inherited
return '{:.12}'.format(value)

def format_data(self, value):
"Return the value formatted into a string."
# docstring inherited
return '{:.12}'.format(value)
3 changes: 1 addition & 2 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,8 +1512,7 @@ def __call__(self):
raise NotImplementedError('Derived must override')

def raise_if_exceeds(self, locs):
"""raise a RuntimeError if Locator attempts to create more than
MAXTICKS locs"""
"""Raise a RuntimeError if ``len(locs) > self.MAXTICKS``."""
if len(locs) >= self.MAXTICKS:
raise RuntimeError("Locator attempting to generate {} ticks from "
"{} to {}: exceeds Locator.MAXTICKS".format(
Expand Down
6 changes: 4 additions & 2 deletions lib/mpl_toolkits/axisartist/axisline_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ class SimpleArrow(_Base):

def __init__(self, size=1):
"""
*size*
size of the arrow as a fraction of the ticklabel size.
Parameters
----------
size : float
Size of the arrow as a fraction of the ticklabel size.
"""

self.size = size
Expand Down
0