From e76c94e749202723628c8e955e09324b371e2b4e Mon Sep 17 00:00:00 2001 From: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com> Date: Sat, 8 Jun 2019 16:46:33 +0200 Subject: [PATCH] Fix pydocstyle D208 --- .flake8 | 2 +- lib/matplotlib/__init__.py | 15 ++++---- lib/matplotlib/colors.py | 8 ++--- lib/matplotlib/dates.py | 35 +++++++++++++------ lib/matplotlib/patches.py | 28 +++++++++------ lib/matplotlib/pyplot.py | 4 +-- lib/matplotlib/spines.py | 11 +++--- .../testing/jpl_units/EpochConverter.py | 13 +++---- .../testing/jpl_units/UnitDblConverter.py | 4 +-- .../testing/jpl_units/UnitDblFormatter.py | 15 ++++---- lib/matplotlib/ticker.py | 3 +- lib/mpl_toolkits/axisartist/axisline_style.py | 6 ++-- 12 files changed, 85 insertions(+), 59 deletions(-) diff --git a/.flake8 b/.flake8 index 7ed0d70189b0..c5d96e57f370 100644 --- a/.flake8 +++ b/.flake8 @@ -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, diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index a367dd729f9f..ee1aa93d45b6 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -1249,23 +1249,24 @@ def get_backend(): def interactive(b): """ - 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'] diff --git a/lib/matplotlib/colors.py b/lib/matplotlib/colors.py index 049a2d0aada7..baec148e8f15 100644 --- a/lib/matplotlib/colors.py +++ b/lib/matplotlib/colors.py @@ -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: diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index 3640dcfedb78..711b19cb27be 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -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])) @@ -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) diff --git a/lib/matplotlib/patches.py b/lib/matplotlib/patches.py index cff18c78ae2a..9f90f2b9796c 100644 --- a/lib/matplotlib/patches.py +++ b/lib/matplotlib/patches.py @@ -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) @@ -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])) @@ -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__() diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 5d4cc228b861..f810969396a1 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -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() @@ -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: diff --git a/lib/matplotlib/spines.py b/lib/matplotlib/spines.py index 709bcefe419e..dc4d52b8425a 100644 --- a/lib/matplotlib/spines.py +++ b/lib/matplotlib/spines.py @@ -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]), diff --git a/lib/matplotlib/testing/jpl_units/EpochConverter.py b/lib/matplotlib/testing/jpl_units/EpochConverter.py index 0cd9f4e96575..2ada33a4a6f0 100644 --- a/lib/matplotlib/testing/jpl_units/EpochConverter.py +++ b/lib/matplotlib/testing/jpl_units/EpochConverter.py @@ -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 @@ -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. """ @@ -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 diff --git a/lib/matplotlib/testing/jpl_units/UnitDblConverter.py b/lib/matplotlib/testing/jpl_units/UnitDblConverter.py index a43a92a892b7..7098b9b29db7 100644 --- a/lib/matplotlib/testing/jpl_units/UnitDblConverter.py +++ b/lib/matplotlib/testing/jpl_units/UnitDblConverter.py @@ -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 = { diff --git a/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py b/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py index 7966e572f919..da262eae3e2d 100644 --- a/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py +++ b/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py @@ -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) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index b257adb5237e..17bfefa0faae 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -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( diff --git a/lib/mpl_toolkits/axisartist/axisline_style.py b/lib/mpl_toolkits/axisartist/axisline_style.py index 8771e3c9d74d..f2972968d17f 100644 --- a/lib/mpl_toolkits/axisartist/axisline_style.py +++ b/lib/mpl_toolkits/axisartist/axisline_style.py @@ -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