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

Skip to content

Commit d03e4ac

Browse files
authored
Merge pull request #12229 from anntzer/lessACCEPTS
Less ACCEPTS, more numpydoc.
2 parents 2125562 + 50fc4c8 commit d03e4ac

File tree

10 files changed

+67
-31
lines changed

10 files changed

+67
-31
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Additional positional arguments to `Axis.set_ticklabels`
2+
````````````````````````````````````````````````````````
3+
Passing positional arguments to `Axis.set_ticklabels` beyond `ticklabels`
4+
itself has no effect, and support for them is deprecated.

lib/matplotlib/artist.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,9 @@ def get_valid_values(self, attr):
12271227
# Much faster than list(inspect.signature(func).parameters)[1],
12281228
# although barely relevant wrt. matplotlib's total import time.
12291229
param_name = func.__code__.co_varnames[1]
1230-
match = re.search("(?m)^ *{} : (.+)".format(param_name), docstring)
1230+
# We could set the presence * based on whether the parameter is a
1231+
# varargs (it can't be a varkwargs) but it's not really worth the it.
1232+
match = re.search("(?m)^ *\*?{} : (.+)".format(param_name), docstring)
12311233
if match:
12321234
return match.group(1)
12331235

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4881,7 +4881,7 @@ def fill(self, *args, **kwargs):
48814881
48824882
Parameters
48834883
----------
4884-
args : sequence of x, y, [color]
4884+
*args : sequence of x, y, [color]
48854885
Each polygon is defined by the lists of *x* and *y* positions of
48864886
its nodes, optionally followed by a *color* specifier. See
48874887
:mod:`matplotlib.colors` for supported color specifiers. The

lib/matplotlib/axes/_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ def margins(self, *margins, x=None, y=None, tight=True):
22482248
22492249
Parameters
22502250
----------
2251-
args : float, optional
2251+
*margins : float, optional
22522252
If a single positional argument is provided, it specifies
22532253
both margins of the x-axis and y-axis limits. If two
22542254
positional arguments are provided, they will be interpreted

lib/matplotlib/axis.py

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,9 +1539,11 @@ def convert_units(self, x):
15391539

15401540
def set_units(self, u):
15411541
"""
1542-
set the units for axis
1542+
Set the units for axis.
15431543
1544-
ACCEPTS: a units tag
1544+
Parameters
1545+
----------
1546+
u : units tag
15451547
"""
15461548
pchanged = False
15471549
if u is None:
@@ -1558,14 +1560,21 @@ def set_units(self, u):
15581560
self.stale = True
15591561

15601562
def get_units(self):
1561-
'return the units for axis'
1563+
"""Return the units for axis."""
15621564
return self.units
15631565

15641566
def set_label_text(self, label, fontdict=None, **kwargs):
15651567
"""
15661568
Set the text value of the axis label.
15671569
1568-
ACCEPTS: A string value for the label
1570+
Parameters
1571+
----------
1572+
label : str
1573+
Text string.
1574+
fontdict : dict
1575+
Text properties.
1576+
**kwargs :
1577+
Merged into fontdict.
15691578
"""
15701579
self.isDefault_label = False
15711580
self.label.set_text(label)
@@ -1601,7 +1610,7 @@ def set_minor_formatter(self, formatter):
16011610
"""
16021611
if not isinstance(formatter, mticker.Formatter):
16031612
raise TypeError("formatter argument should be instance of "
1604-
"matplotlib.ticker.Formatter")
1613+
"matplotlib.ticker.Formatter")
16051614
self.isDefault_minfmt = False
16061615
self.minor.formatter = formatter
16071616
formatter.set_axis(self)
@@ -1617,7 +1626,7 @@ def set_major_locator(self, locator):
16171626
"""
16181627
if not isinstance(locator, mticker.Locator):
16191628
raise TypeError("formatter argument should be instance of "
1620-
"matplotlib.ticker.Locator")
1629+
"matplotlib.ticker.Locator")
16211630
self.isDefault_majloc = False
16221631
self.major.locator = locator
16231632
locator.set_axis(self)
@@ -1633,7 +1642,7 @@ def set_minor_locator(self, locator):
16331642
"""
16341643
if not isinstance(locator, mticker.Locator):
16351644
raise TypeError("formatter argument should be instance of "
1636-
"matplotlib.ticker.Locator")
1645+
"matplotlib.ticker.Locator")
16371646
self.isDefault_minloc = False
16381647
self.minor.locator = locator
16391648
locator.set_axis(self)
@@ -1651,21 +1660,29 @@ def set_pickradius(self, pickradius):
16511660

16521661
def set_ticklabels(self, ticklabels, *args, minor=False, **kwargs):
16531662
"""
1654-
Set the text values of the tick labels. Return a list of Text
1655-
instances. Use *kwarg* *minor=True* to select minor ticks.
1656-
All other kwargs are used to update the text object properties.
1657-
As for get_ticklabels, label1 (left or bottom) is
1658-
affected for a given tick only if its label1On attribute
1659-
is True, and similarly for label2. The list of returned
1660-
label text objects consists of all such label1 objects followed
1661-
by all such label2 objects.
1663+
Set the text values of the tick labels.
16621664
1663-
The input *ticklabels* is assumed to match the set of
1664-
tick locations, regardless of the state of label1On and
1665-
label2On.
1665+
Parameters
1666+
----------
1667+
ticklabels : sequence of str or of `Text`\s
1668+
List of texts for tick labels; must include values for non-visible
1669+
labels.
1670+
minor : bool
1671+
If True, set minor ticks instead of major ticks.
1672+
**kwargs
1673+
Text properties.
16661674
1667-
ACCEPTS: sequence of strings or Text objects
1668-
"""
1675+
Returns
1676+
-------
1677+
labels : list of `Text`\s
1678+
For each tick, includes ``tick.label1`` if it is visible, then
1679+
``tick.label2`` if it is visible, in that order.
1680+
"""
1681+
if args:
1682+
cbook.warn_deprecated(
1683+
"3.1", "Additional positional arguments to set_ticklabels are "
1684+
"ignored, and deprecated since Matplotlib 3.1; passing them "
1685+
"will raise a TypeError in Matplotlib 3.3.")
16691686
get_labels = []
16701687
for t in ticklabels:
16711688
# try calling get_text() to check whether it is Text object
@@ -1705,7 +1722,10 @@ def set_ticks(self, ticks, minor=False):
17051722
"""
17061723
Set the locations of the tick marks from sequence ticks
17071724
1708-
ACCEPTS: sequence of floats
1725+
Parameters
1726+
----------
1727+
ticks : sequence of floats
1728+
minor : bool
17091729
"""
17101730
# XXX if the user changes units, the information will be lost here
17111731
ticks = self.convert_units(ticks)

lib/matplotlib/figure.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,15 +979,21 @@ def set_figwidth(self, val, forward=True):
979979
"""
980980
Set the width of the figure in inches.
981981
982-
.. ACCEPTS: float
982+
Parameters
983+
----------
984+
val : float
985+
forward : bool
983986
"""
984987
self.set_size_inches(val, self.get_figheight(), forward=forward)
985988

986989
def set_figheight(self, val, forward=True):
987990
"""
988991
Set the height of the figure in inches.
989992
990-
.. ACCEPTS: float
993+
Parameters
994+
----------
995+
val : float
996+
forward : bool
991997
"""
992998
self.set_size_inches(self.get_figwidth(), val, forward=forward)
993999

lib/matplotlib/lines.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ def set_data(self, *args):
650650
"""
651651
Set the x and y data.
652652
653-
ACCEPTS: 2D array (rows are x, y) or two 1D arrays
653+
Parameters
654+
----------
655+
*args : (N, 2) array or two 1D arrays
654656
"""
655657
if len(args) == 1:
656658
x, y = args[0]

lib/matplotlib/patches.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,11 @@ def set_alpha(self, alpha):
337337

338338
def set_linewidth(self, w):
339339
"""
340-
Set the patch linewidth in points
340+
Set the patch linewidth in points.
341341
342-
ACCEPTS: float or None for default
342+
Parameters
343+
----------
344+
w : float or None
343345
"""
344346
if w is None:
345347
w = mpl.rcParams['patch.linewidth']
@@ -2516,7 +2518,6 @@ def set_boxstyle(self, boxstyle=None, **kw):
25162518
%(AvailableBoxstyles)s
25172519
25182520
ACCEPTS: %(ListBoxstyles)s
2519-
25202521
"""
25212522
if boxstyle is None:
25222523
return BoxStyle.pprint_styles()

lib/matplotlib/tests/test_artist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ def test_None_zorder():
262262
('ACCEPTS: Some description.', 'Some description. '),
263263
('.. ACCEPTS: Some description.', 'Some description. '),
264264
('arg : int', 'int'),
265+
('*arg : int', 'int'),
265266
('arg : int\nACCEPTS: Something else.', 'Something else. '),
266267
])
267268
def test_artist_inspector_get_valid_values(accept_clause, expected):

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def __init__(self, fig, *args, horizontal=None, vertical=None,
361361
Parameters
362362
----------
363363
fig : :class:`matplotlib.figure.Figure`
364-
args : tuple (*numRows*, *numCols*, *plotNum*)
364+
*args : tuple (*numRows*, *numCols*, *plotNum*)
365365
The array of subplots in the figure has dimensions *numRows*,
366366
*numCols*, and *plotNum* is the number of the subplot
367367
being created. *plotNum* starts at 1 in the upper left

0 commit comments

Comments
 (0)