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

Skip to content

Commit 3bc6a34

Browse files
committed
Fix most instances of D404 ("docstring should not start with 'this').
... and associated rewordings.
1 parent 291d5d7 commit 3bc6a34

37 files changed

+184
-205
lines changed

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This is an object-oriented plotting library.
2+
An object-oriented plotting library.
33
44
A procedural interface is provided by the companion pyplot module,
55
which may be imported directly, e.g.::

lib/matplotlib/_constrained_layout.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
"""
2-
This module provides the routine to adjust subplot layouts so that there are
3-
no overlapping axes or axes decorations. All axes decorations are dealt with
4-
(labels, ticks, titles, ticklabels) and some dependent artists are also dealt
5-
with (colorbar, suptitle, legend).
6-
7-
Layout is done via :meth:`~matplotlib.gridspec`, with one constraint per
8-
gridspec, so it is possible to have overlapping axes if the gridspecs
9-
overlap (i.e. using :meth:`~matplotlib.gridspec.GridSpecFromSubplotSpec`).
10-
Axes placed using ``figure.subplots()`` or ``figure.add_subplots()`` will
11-
participate in the layout. Axes manually placed via ``figure.add_axes()``
12-
will not.
2+
Adjust subplot layouts so that there are no overlapping axes or axes
3+
decorations. All axes decorations are dealt with (labels, ticks, titles,
4+
ticklabels) and some dependent artists are also dealt with (colorbar, suptitle,
5+
legend).
136
14-
See Tutorial: :doc:`/tutorials/intermediate/constrainedlayout_guide`
7+
Layout is done via `~matplotlib.gridspec`, with one constraint per gridspec,
8+
so it is possible to have overlapping axes if the gridspecs overlap (i.e.
9+
using `~matplotlib.gridspec.GridSpecFromSubplotSpec`). Axes placed using
10+
``figure.subplots()`` or ``figure.add_subplots()`` will participate in the
11+
layout. Axes manually placed via ``figure.add_axes()`` will not.
1512
13+
See Tutorial: :doc:`/tutorials/intermediate/constrainedlayout_guide`
1614
"""
1715

1816
# Development Notes:

lib/matplotlib/afm.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
"""
2-
This is a python interface to Adobe Font Metrics Files. Although a
3-
number of other python implementations exist, and may be more complete
4-
than this, it was decided not to go with them because they were either:
2+
A python interface to Adobe Font Metrics Files.
3+
4+
Although a number of other python implementations exist, and may be more
5+
complete than this, it was decided not to go with them because they were
6+
either:
57
68
1) copyrighted or used a non-BSD compatible license
79
2) had too many dependencies and a free standing lib was needed
810
3) did more than needed and it was easier to write afresh rather than
911
figure out how to get just what was needed.
1012
11-
It is pretty easy to use, and requires only built-in python libs:
13+
It is pretty easy to use, and has no external depedencies:
1214
1315
>>> import matplotlib as mpl
1416
>>> from pathlib import Path

lib/matplotlib/animation.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -890,12 +890,10 @@ def finish(self):
890890

891891
class Animation:
892892
"""
893-
This class wraps the creation of an animation using matplotlib.
893+
A base class for Animations.
894894
895-
It is only a base class which should be subclassed to provide
896-
needed behavior.
897-
898-
This class is not typically used directly.
895+
This class is not usable as is, and should be subclassed to provide needed
896+
behavior.
899897
900898
Parameters
901899
----------

lib/matplotlib/axes/_base.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,9 +2763,10 @@ def draw(self, renderer=None, inframe=False):
27632763

27642764
def draw_artist(self, a):
27652765
"""
2766-
This method can only be used after an initial draw which
2767-
caches the renderer. It is used to efficiently update Axes
2768-
data (axis ticks, labels, etc are not updated).
2766+
Efficiently redraw a single artist.
2767+
2768+
This method can only be used after an initial draw which caches the
2769+
renderer.
27692770
"""
27702771
if self.figure._cachedRenderer is None:
27712772
raise AttributeError("draw_artist can only be used after an "
@@ -2774,9 +2775,11 @@ def draw_artist(self, a):
27742775

27752776
def redraw_in_frame(self):
27762777
"""
2777-
This method can only be used after an initial draw which
2778-
caches the renderer. It is used to efficiently update Axes
2779-
data (axis ticks, labels, etc are not updated).
2778+
It is used to efficiently redraw Axes data (axis ticks, labels, etc.,
2779+
are not redrawn).
2780+
2781+
This method can only be used after an initial draw which caches the
2782+
renderer.
27802783
"""
27812784
if self.figure._cachedRenderer is None:
27822785
raise AttributeError("redraw_in_frame can only be used after an "

lib/matplotlib/axes/_subplots.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def _make_twin_axes(self, *args, **kwargs):
179179
@functools.lru_cache(None)
180180
def subplot_class_factory(axes_class=None):
181181
"""
182-
This makes a new class that inherits from `.SubplotBase` and the
182+
Make a new class that inherits from `.SubplotBase` and the
183183
given axes_class (which is assumed to be a subclass of `.axes.Axes`).
184184
This is perhaps a little bit roundabout to make a new class on
185185
the fly like this, but it means that a new Subplot class does
@@ -207,8 +207,9 @@ def subplot_class_factory(axes_class=None):
207207

208208
def _picklable_subplot_class_constructor(axes_class):
209209
"""
210-
This stub class exists to return the appropriate subplot class when called
211-
with an axes class. This is purely to allow pickling of Axes and Subplots.
210+
Stub factory that returns an empty instance of the appropriate subplot
211+
class when called with an axes class. This is purely to allow pickling of
212+
Axes and Subplots.
212213
"""
213214
subplot_class = subplot_class_factory(axes_class)
214215
return subplot_class.__new__(subplot_class)

lib/matplotlib/backend_bases.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,8 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
237237
coordinates, offsets, offsetTrans, facecolors,
238238
antialiased, edgecolors):
239239
"""
240-
This provides a fallback implementation of
241-
:meth:`draw_quad_mesh` that generates paths and then calls
242-
:meth:`draw_path_collection`.
240+
Fallback implementation of :meth:`draw_quad_mesh` that generates paths
241+
and then calls :meth:`draw_path_collection`.
243242
"""
244243

245244
from matplotlib.collections import QuadMesh
@@ -298,9 +297,8 @@ def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
298297
def _iter_collection_raw_paths(self, master_transform, paths,
299298
all_transforms):
300299
"""
301-
This is a helper method (along with :meth:`_iter_collection`) to make
302-
it easier to write a space-efficient :meth:`draw_path_collection`
303-
implementation in a backend.
300+
Helper method (along with :meth:`_iter_collection`) to implement
301+
:meth:`draw_path_collection` in a space-efficient manner.
304302
305303
This method yields all of the base path/transform
306304
combinations, given a master transform, a list of paths and
@@ -348,10 +346,8 @@ def _iter_collection(self, gc, master_transform, all_transforms,
348346
edgecolors, linewidths, linestyles,
349347
antialiaseds, urls, offset_position):
350348
"""
351-
This is a helper method (along with
352-
:meth:`_iter_collection_raw_paths`) to make it easier to write
353-
a space-efficient :meth:`draw_path_collection` implementation in a
354-
backend.
349+
Helper method (along with :meth:`_iter_collection_raw_paths`) to
350+
implement :meth:`draw_path_collection` in a space-efficient manner.
355351
356352
This method yields all of the path, offset and graphics
357353
context combinations to draw the path collection. The caller

lib/matplotlib/backends/backend_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This is a fully functional do nothing backend to provide a template to backend
2+
A fully functional, do-nothing backend intended as a template for backend
33
writers. It is fully functional in that you can select it as a backend e.g.
44
with ::
55

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,9 +1026,9 @@ def Destroy(self, *args, **kwargs):
10261026

10271027
class FigureManagerWx(FigureManagerBase):
10281028
"""
1029-
This class contains the FigureCanvas and GUI frame
1029+
A class contains the FigureCanvas and GUI frame.
10301030
1031-
It is instantiated by GcfWx whenever a new figure is created. GcfWx is
1031+
It is instantiated by Gcf whenever a new figure is created. Gcf is
10321032
responsible for managing multiple instances of FigureManagerWx.
10331033
10341034
Attributes

lib/matplotlib/backends/qt_editor/figureoptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def prepare_data(d, init):
170170
datalist.append((mappables, "Images, etc.", ""))
171171

172172
def apply_callback(data):
173-
"""This function will be called to apply changes"""
173+
"""A callback to apply changes."""
174174
orig_xlim = axes.get_xlim()
175175
orig_ylim = axes.get_ylim()
176176

lib/matplotlib/blocking_input.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""
2-
This provides several classes used for blocking interaction with figure
3-
windows:
2+
Classes used for blocking interaction with figure windows:
43
54
`BlockingInput`
65
Creates a callable object to retrieve events in a blocking way for

lib/matplotlib/cbook/__init__.py

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -758,40 +758,38 @@ def recurse(obj, start, all, current_path):
758758

759759
class Grouper:
760760
"""
761-
This class provides a lightweight way to group arbitrary objects
762-
together into disjoint sets when a full-blown graph data structure
763-
would be overkill.
761+
A disjoint-set data structure.
764762
765763
Objects can be joined using :meth:`join`, tested for connectedness
766764
using :meth:`joined`, and all disjoint sets can be retrieved by
767765
using the object as an iterator.
768766
769767
The objects being joined must be hashable and weak-referenceable.
770768
771-
For example:
772-
773-
>>> from matplotlib.cbook import Grouper
774-
>>> class Foo:
775-
... def __init__(self, s):
776-
... self.s = s
777-
... def __repr__(self):
778-
... return self.s
779-
...
780-
>>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef']
781-
>>> grp = Grouper()
782-
>>> grp.join(a, b)
783-
>>> grp.join(b, c)
784-
>>> grp.join(d, e)
785-
>>> sorted(map(tuple, grp))
786-
[(a, b, c), (d, e)]
787-
>>> grp.joined(a, b)
788-
True
789-
>>> grp.joined(a, c)
790-
True
791-
>>> grp.joined(a, d)
792-
False
793-
769+
Examples
770+
--------
771+
>>> from matplotlib.cbook import Grouper
772+
>>> class Foo:
773+
... def __init__(self, s):
774+
... self.s = s
775+
... def __repr__(self):
776+
... return self.s
777+
...
778+
>>> a, b, c, d, e, f = [Foo(x) for x in 'abcdef']
779+
>>> grp = Grouper()
780+
>>> grp.join(a, b)
781+
>>> grp.join(b, c)
782+
>>> grp.join(d, e)
783+
>>> sorted(map(tuple, grp))
784+
[(a, b, c), (d, e)]
785+
>>> grp.joined(a, b)
786+
True
787+
>>> grp.joined(a, c)
788+
True
789+
>>> grp.joined(a, d)
790+
False
794791
"""
792+
795793
def __init__(self, init=()):
796794
self._mapping = {weakref.ref(x): [weakref.ref(x)] for x in init}
797795

lib/matplotlib/cm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@ def get_cmap(name=None, lut=None):
150150

151151
class ScalarMappable:
152152
"""
153-
This is a mixin class to support scalar data to RGBA mapping.
154-
The ScalarMappable makes use of data normalization before returning
155-
RGBA colors from the given colormap.
153+
A mixin class to map scalar data to RGBA.
156154
155+
The ScalarMappable applies data normalization before returning RGBA colors
156+
from the given colormap.
157157
"""
158+
158159
def __init__(self, norm=None, cmap=None):
159160
"""
160161

lib/matplotlib/collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ def set_verts(self, verts, closed=True):
11181118
set_paths = set_verts
11191119

11201120
def set_verts_and_codes(self, verts, codes):
1121-
"""This allows one to initialize vertices with path codes."""
1121+
"""Initialize vertices with path codes."""
11221122
if len(verts) != len(codes):
11231123
raise ValueError("'codes' must be a 1D list or array "
11241124
"with the same length of 'verts'")

lib/matplotlib/colorbar.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ class _ColorbarLogLocator(ticker.LogLocator):
297297
"""
298298
def __init__(self, colorbar, *args, **kwargs):
299299
"""
300-
_ColorbarLogLocator(colorbar, *args, **kwargs)
301-
302300
This ticker needs to know the *colorbar* so that it can access
303301
its *vmin* and *vmax*. Otherwise it is the same as
304302
`~.ticker.LogLocator`. The ``*args`` and ``**kwargs`` are the

lib/matplotlib/colors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def to_hex(c, keep_alpha=False):
361361

362362
class ColorConverter:
363363
"""
364-
This class is only kept for backwards compatibility.
364+
A class only kept for backwards compatibility.
365365
366366
Its functionality is entirely provided by module-level functions.
367367
"""

lib/matplotlib/contour.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
These are classes to support contour plotting and labelling for the Axes class.
2+
Classes to support contour plotting and labelling for the Axes class.
33
"""
44

55
from numbers import Integral
@@ -313,21 +313,22 @@ def locate_label(self, linecontour, labelwidth):
313313

314314
def calc_label_rot_and_inline(self, slc, ind, lw, lc=None, spacing=5):
315315
"""
316-
This function calculates the appropriate label rotation given
317-
the linecontour coordinates in screen units, the index of the
318-
label location and the label width.
316+
Calculate the appropriate label rotation given the linecontour
317+
coordinates in screen units, the index of the label location and the
318+
label width.
319319
320-
It will also break contour and calculate inlining if *lc* is
321-
not empty (lc defaults to the empty list if None). *spacing*
322-
is the space around the label in pixels to leave empty.
320+
If *lc* is not None or empty, also break contours and compute
321+
inlining.
323322
324-
Do both of these tasks at once to avoid calculating path lengths
323+
*spacing* is the empty space to leave around the label, in pixels.
324+
325+
Both tasks are done together to avoid calculating path lengths
325326
multiple times, which is relatively costly.
326327
327-
The method used here involves calculating the path length
328-
along the contour in pixel coordinates and then looking
329-
approximately label width / 2 away from central point to
330-
determine rotation and then to break contour if desired.
328+
The method used here involves computing the path length along the
329+
contour in pixel coordinates and then looking approximately (label
330+
width / 2) away from central point to determine rotation and then to
331+
break contour if desired.
331332
"""
332333

333334
if lc is None:

lib/matplotlib/dates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ def __call__(self, x, pos=0):
563563

564564
class ConciseDateFormatter(ticker.Formatter):
565565
"""
566-
This class attempts to figure out the best format to use for the
566+
A `.Formatter` which attempts to figure out the best format to use for the
567567
date, and to make it as compact as possible, but still be complete. This is
568568
most useful when used with the `AutoDateLocator`::
569569
@@ -761,8 +761,8 @@ def format_data_short(self, value):
761761

762762
class AutoDateFormatter(ticker.Formatter):
763763
"""
764-
This class attempts to figure out the best format to use. This is
765-
most useful when used with the `AutoDateLocator`.
764+
A `.Formatter` which attempts to figure out the best format to use. This
765+
is most useful when used with the `AutoDateLocator`.
766766
767767
The AutoDateFormatter has a scale dictionary that maps the scale
768768
of the tick (the distance in days between one major tick) and a

lib/matplotlib/legend_handler.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
This module defines default legend handlers.
2+
Default legend handlers.
33
44
It is strongly encouraged to have read the :doc:`legend guide
55
</tutorials/intermediate/legend_guide>` before this documentation.
@@ -21,7 +21,6 @@
2121
derived from the base class (HandlerBase) with the following method::
2222
2323
def legend_artist(self, legend, orig_handle, fontsize, handlebox)
24-
2524
"""
2625

2726
from itertools import cycle

lib/matplotlib/lines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
2-
This module contains all the 2D line class which can draw with a
3-
variety of line styles, markers and colors.
2+
The 2D line class which can draw with a variety of line styles, markers and
3+
colors.
44
"""
55

66
# TODO: expose cap and join style attrs

lib/matplotlib/markers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
r"""
2-
This module contains functions to handle markers. Used by both the
3-
marker functionality of `~matplotlib.axes.Axes.plot` and
4-
`~matplotlib.axes.Axes.scatter`.
2+
Functions to handle markers; used by the marker functionality of
3+
`~matplotlib.axes.Axes.plot` and `~matplotlib.axes.Axes.scatter`.
54
65
All possible markers are defined here:
76

0 commit comments

Comments
 (0)