8000 Merge pull request #13947 from meeseeksmachine/auto-backport-of-pr-13… · matplotlib/matplotlib@02f00f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 02f00f2

Browse files
authored
Merge pull request #13947 from meeseeksmachine/auto-backport-of-pr-13897-on-v3.1.x
Backport PR #13897 on branch v3.1.x (numpydocification.)
2 parents a69d48e + d53dab5 commit 02f00f2

File tree

13 files changed

+186
-198
lines changed

13 files changed

+186
-198
lines changed

lib/matplotlib/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ def _create_tmp_config_or_cache_dir():
522522

523523
def _get_xdg_config_dir():
524524
"""
525-
Returns the XDG configuration directory, according to the `XDG
525+
Return the XDG configuration directory, according to the `XDG
526526
base directory spec
527527
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
528528
"""
@@ -534,7 +534,7 @@ def _get_xdg_config_dir():
534534

535535
def _get_xdg_cache_dir():
536536
"""
537-
Returns the XDG cache directory, according to the `XDG
537+
Return the XDG cache directory, according to the `XDG
538538
base directory spec
539539
<http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html>`_.
540540
"""

lib/matplotlib/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ def grab_frame(self, **savefig_kwargs):
384384
dpi=self.dpi, **savefig_kwargs)
385385

386386
def _frame_sink(self):
387-
'''Returns the place to which frames should be written.'''
387+
'''Return the place to which frames should be written.'''
388388
return self._proc.stdin
389389

390390
def _args(self):
@@ -413,7 +413,7 @@ def cleanup(self):
413413
@classmethod
414414
def bin_path(cls):
415415
'''
416-
Returns the binary path to the commandline tool used by a specific
416+
Return the binary path to the commandline tool used by a specific
417417
subclass. This is a class method so that the tool can be looked for
418418
before making a particular MovieWriter subclass available.
419419
'''

lib/matplotlib/artist.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,10 +1560,8 @@ def setp(obj, *args, **kwargs):
15601560

15611561
def kwdoc(artist):
15621562
r"""
1563-
Inspect an `~matplotlib.artist.Artist` class and return
1564-
information about its settable properties and their current values.
1565-
1566-
It use the class `.ArtistInspector`.
1563+
Inspect an `~matplotlib.artist.Artist` class (using `.ArtistInspector`) and
1564+
return information about its settable properties and their current values.
15671565
15681566
Parameters
15691567
----------
@@ -1572,11 +1570,9 @@ def kwdoc(artist):
15721570
Returns
15731571
-------
15741572
string
1575-
Returns a string with a list or rst table with the settable properties
1576-
of the *artist*. The formatting depends on the value of
1577-
:rc:`docstring.hardcopy`. False result in a list that is intended for
1578-
easy reading as a docstring and True result in a rst table intended
1579-
for rendering the documentation with sphinx.
1573+
The settable properties of *artist*, as plain text if
1574+
:rc:`docstring.hardcopy` is False and as a rst table (intended for
1575+
use in Sphinx) if it is True.
15801576
"""
15811577
hardcopy = matplotlib.rcParams['docstring.hardcopy']
15821578
if hardcopy:

lib/matplotlib/axes/_base.py

Lines changed: 94 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -683,23 +683,23 @@ def get_xaxis_transform(self, which='grid'):
683683

684684
def get_xaxis_text1_transform(self, pad_points):
685685
"""
686-
Get the transformation used for drawing x-axis labels, which
687-
will add the given amount of padding (in points) between the
688-
axes and the label. The x-direction is in data coordinates
689-
and the y-direction is in axis coordinates. Returns a
690-
3-tuple of the form::
691-
692-
(transform, valign, halign)
693-
694-
where *valign* and *halign* are requested alignments for the
695-
text.
696-
697-
.. note::
686+
Returns
687+
-------
688+
transform : Transform
689+
The transform used for drawing x-axis labels, which will add
690+
*pad_points* of padding (in points) between the axes and the label.
691+
The x-direction is in data coordinates and the y-direction is in
692+
axis corrdinates
693+
valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
694+
The text vertical alignment.
695+
halign : {'center', 'left', 'right'}
696+
The text horizontal alignment.
698697
699-
This transformation is primarily used by the
700-
`~matplotlib.axis.Axis` class, and is meant to be
701-
overridden by new kinds of projections that may need to
702-
place axis elements in different locations.
698+
Notes
699+
-----
700+
This transformation is primarily used by the `~matplotlib.axis.Axis`
701+
class, and is meant to be overridden by new kinds of projections that
702+
may need to place axis elements in different locations.
703703
"""
704704
labels_align = rcParams["xtick.alignment"]
705705
return (self.get_xaxis_transform(which='tick1') +
@@ -709,23 +709,23 @@ def get_xaxis_text1_transform(self, pad_points):
709709

710710
def get_xaxis_text2_transform(self, pad_points):
711711
"""
712-
Get the transformation used for drawing the secondary x-axis
713-
labels, which will add the given amount of padding (in points)
714-
between the axes and the label. The x-direction is in data
715-
coordinates and the y-direction is in axis coordinates.
716-
Returns a 3-tuple of the form::
717-
718-
(transform, valign, halign)
719-
720-
where *valign* and *halign* are requested alignments for the
721-
text.
722-
723-
.. note::
712+
Returns
713+
-------
714+
transform : Transform
715+
The transform used for drawing secondary x-axis labels, which will
716+
add *pad_points* of padding (in points) between the axes and the
717+
label. The x-direction is in data coordinates and the y-direction
718+
is in axis corrdinates
719+
valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
720+
The text vertical alignment.
721+
halign : {'center', 'left', 'right'}
722+
The text horizontal alignment.
724723
725-
This transformation is primarily used by the
726-
`~matplotlib.axis.Axis` class, and is meant to be
727-
overridden by new kinds of projections that may need to
728-
place axis elements in different locations.
724+
Notes
725+
-----
726+
This transformation is primarily used by the `~matplotlib.axis.Axis`
727+
class, and is meant to be overridden by new kinds of projections that
728+
may need to place axis elements in different locations.
729729
"""
730730
labels_align = rcParams["xtick.alignment"]
731731
return (self.get_xaxis_transform(which='tick2') +
@@ -759,23 +759,23 @@ def get_yaxis_transform(self, which='grid'):
759759

760760
def get_yaxis_text1_transform(self, pad_points):
761761
"""
762-
Get the transformation used for drawing y-axis labels, which
763-
will add the given amount of padding (in points) between the
764-
axes and the label. The x-direction is in axis coordinates
765-
and the y-direction is in data coordinates. Returns a 3-tuple
766-
of the form::
767-
768-
(transform, valign, halign)
769-
770-
where *valign* and *halign* are requested alignments for the
771-
text.
772-
773-
.. note::
762+
Returns
763+
-------
764+
transform : Transform
765+
The transform used for drawing y-axis labels, which will add
766+
*pad_points* of padding (in points) between the axes and the label.
767+
The x-direction is in axis coordinates and the y-direction is in
768+
data corrdinates
769+
valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
770+
The text vertical alignment.
771+
halign : {'center', 'left', 'right'}
772+
The text horizontal alignment.
774773
775-
This transformation is primarily used by the
776-
`~matplotlib.axis.Axis` class, and is meant to be
777-
overridden by new kinds of projections that may need to
778-
place axis elements in different locations.
774+
Notes
775+
-----
776+
This transformation is primarily used by the `~matplotlib.axis.Axis`
777+
class, and is meant to be overridden by new kinds of projections that
778+
may need to place axis elements in different locations.
779779
"""
780780
labels_align = rcParams["ytick.alignment"]
781781
return (self.get_yaxis_transform(which='tick1') +
@@ -785,23 +785,23 @@ def get_yaxis_text1_transform(self, pad_points):
785785

786786
def get_yaxis_text2_transform(self, pad_points):
787787
"""
788-
Get the transformation used for drawing the secondary y-axis
789-
labels, which will add the given amount of padding (in points)
790-
between the axes and the label. The x-direction is in axis
791-
coordinates and the y-direction is in data coordinates.
792-
Returns a 3-tuple of the form::
793-
794-
(transform, valign, halign)
795-
796-
where *valign* and *halign* are requested alignments for the
797-
text.
798-
799-
.. note::
788+
Returns
789+
-------
790+
transform : Transform
791+
The transform used for drawing secondart y-axis labels, which will
792+
add *pad_points* of padding (in points) between the axes and the
793+
label. The x-direction is in axis coordinates and the y-direction
794+
is in data corrdinates
795+
valign : {'center', 'top', 'bottom', 'baseline', 'center_baseline'}
796+
The text vertical alignment.
797+
halign : {'center', 'left', 'right'}
798+
The text horizontal alignment.
800799
801-
This transformation is primarily used by the
802-
`~matplotlib.axis.Axis` class, and is meant to be
803-
overridden by new kinds of projections that may need to
804-
place axis elements in different locations.
800+
Notes
801+
-----
802+
This transformation is primarily used by the `~matplotlib.axis.Axis`
803+
class, and is meant to be overridden by new kinds of projections that
804+
may need to place axis elements in different locations.
805805
"""
806806
labels_align = rcParams["ytick.alignment"]
807807
return (self.get_yaxis_transform(which='tick2') +
@@ -924,33 +924,35 @@ def _set_artist_props(self, a):
924924

925925
def _gen_axes_patch(self):
926926
"""
927-
Returns the patch used to draw the background of the axes. It
928-
is also used as the clipping path for any data elements on the
929-
axes.
930-
931-
In the standard axes, this is a rectangle, but in other
932-
projections it may not be.
933-
934-
.. note::
927+
Returns
928+
-------
929+
Patch
930+
The patch used to draw the background of the axes. It is also used
931+
as the clipping path for any data elements on the axes.
935932
936-
Intended to be overridden by new projection types.
933+
In the standard axes, this is a rectangle, but in other projections
934+
it may not be.
937935
936+
Notes
937+
-----
938+
Intended to be overridden by new projection types.
938939
"""
939940
return mpatches.Rectangle((0.0, 0.0), 1.0, 1.0)
940941

941942
def _gen_axes_spines(self, locations=None, offset=0.0, units='inches'):
942943
"""
943-
Returns a dict whose keys are spine names and values are
944-
Line2D or Patch instances. Each element is used to draw a
945-
spine of the axes.
946-
947-
In the standard axes, this is a single line segment, but in
948-
other projections it may not be.
944+
Returns
945+
-------
946+
dict
947+
Mapping of spine names to `Line2D` or `Patch` instances that are
948+
used to draw axes spines.
949949
950-
.. note::
951-
952-
Intended to be overridden by new projection types.
950+
In the standard axes, spines are single line segments, but in other
951+
projections they may not be.
953952
953+
Notes
954+
-----
955+
Intended to be overridden by new projection types.
954956
"""
955957
return OrderedDict((side, mspines.Spine.linear_spine(self, side))
956958
for side in ['left', 'right', 'bottom', 'top'])
@@ -1411,10 +1413,11 @@ def set_anchor(self, anchor, share=False):
14111413

14121414
def get_data_ratio(self):
14131415
"""
1414-
Returns the aspect ratio of the raw data.
1416+
Return the aspect ratio of the raw data.
14151417
1416-
This method is intended to be overridden by new projection
1417-
types.
1418+
Notes
1419+
-----
1420+
This method is intended to be overridden by new projection types.
14181421
"""
14191422
xmin, xmax = self.get_xbound()
14201423
ymin, ymax = self.get_ybound()
@@ -1426,8 +1429,11 @@ def get_data_ratio(self):
14261429

14271430
def get_data_ratio_log(self):
14281431
"""
1429-
Returns the aspect ratio of the raw data in log scale.
1430-
Will be used when both axis scales are in log.
1432+
Return the aspect ratio of the raw data in log scale.
1433+
1434+
Notes
1435+
-----
1436+
Will be used when both axis are in log scale.
14311437
"""
14321438
xmin, xmax = self.get_xbound()
14331439
ymin, ymax = self.get_ybound()
@@ -4251,7 +4257,7 @@ def contains(self, mouseevent):
42514257

42524258
def contains_point(self, point):
42534259
"""
4254-
Returns whether *point* (pair of pixel coordinates) is inside the axes
4260+
Return whether *point* (pair of pixel coordinates) is inside the axes
42554261
patch.
42564262
"""
42574263
return self.patch.contains_point(point, radius=1.0)

lib/matplotlib/cbook/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def is_writable_file_like(obj):
368368

369369
def file_requires_unicode(x):
370370
"""
371-
Returns whether the given writable file-like object requires Unicode to be
371+
Return whether the given writable file-like object requires Unicode to be
372372
written to it.
373373
"""
374374
try:
@@ -494,7 +494,7 @@ def get_sample_data(fname, asfileobj=True):
494494

495495
def flatten(seq, scalarp=is_scalar_or_string):
496496
"""
497-
Returns a generator of flattened nested containers
497+
Return a generator of flattened nested containers
498498
499499
For example:
500500
@@ -943,7 +943,7 @@ def join(self, a, *args):
943943
self.clean()
944944

945945
def joined(self, a, b):
946-
"""Returns True if *a* and *b* are members of the same set."""
946+
"""Return whether *a* and *b* are members of the same set."""
947947
self.clean()
948948
return (self._mapping.get(weakref.ref(a), object())
949949
is self._mapping.get(weakref.ref(b)))
@@ -966,7 +966,7 @@ def __iter__(self):
966966
yield [x() for x in group]
967967

968968
def get_siblings(self, a):
969-
"""Returns all of the items joined with *a*, including itself."""
969+
"""Return all of the items joined with *a*, including itself."""
970970
self.clean()
971971
siblings = self._mapping.get(weakref.ref(a), [weakref.ref(a)])
972972
return [x() for x in siblings]

lib/matplotlib/colorbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,11 @@ def __init__(self, ax, cmap=None,
460460
self.draw_all()
461461

462462
def _extend_lower(self):
463-
"""Returns whether the lower limit is open ended."""
463+
"""Return whether the lower limit is open ended."""
464464
return self.extend in ('both', 'min')
465465

466466
def _extend_upper(self):
467-
"""Returns whether the uper limit is open ended."""
467+
"""Return whether the uper limit is open ended."""
468468
return self.extend in ('both', 'max')
469469

470470
def _patch_ax(self):

lib/matplotlib/font_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,9 +1310,9 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
13101310
@lru_cache()
13111311
def is_opentype_cff_font(filename):
13121312
"""
1313-
Returns True if the given font is a Postscript Compact Font Format
1314-
Font embedded in an OpenType wrapper. Used by the PostScript and
1315-
PDF backends that can not subset these fonts.
1313+
Return whether the given font is a Postscript Compact Font Format Font
1314+
embedded in an OpenType wrapper. Used by the PostScript and PDF backends
1315+
that can not subset these fonts.
13161316
"""
13171317
if os.path.splitext(filename)[1].lower() == '.otf':
13181318
with open(filename, 'rb') as fd:

lib/matplotlib/lines.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ def _scale_dashes(offset, dashes, lw):
7272

7373
def segment_hits(cx, cy, x, y, radius):
7474
"""
75-
Determine if any line segments are within radius of a
76-
point. Returns the list of line segments that are within that
77-
radius.
75+
Return the indices of the segments in the polyline with coordinates (*cx*,
76+
*cy*) that are within a distance *radius* of the point (*x*, *y*).
7877
"""
7978
# Process single points specially
80-
if len(x) < 2:
79+
if len(x) <= 1:
8180
res, = np.nonzero((cx - x) ** 2 + (cy - y) ** 2 <= radius ** 2)
8281
return res
8382

0 commit comments

Comments
 (0)
0