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

Skip to content

Commit 31ab802

Browse files
authored
Merge pull request #14341 from meeseeksmachine/auto-backport-of-pr-14337-on-v3.1.x
Backport PR #14337 on branch v3.1.x (Docstring cleanup)
2 parents 3f49836 + 3826e2b commit 31ab802

File tree

9 files changed

+53
-55
lines changed

9 files changed

+53
-55
lines changed

lib/matplotlib/axis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,12 @@ def get_ticklabel_extents(self, renderer):
10641064
return bbox, bbox2
10651065

10661066
def set_smart_bounds(self, value):
1067-
"""set the axis to have smart bounds"""
1067+
"""Set the axis to have smart bounds."""
10681068
self._smart_bounds = value
10691069
self.stale = True
10701070

10711071
def get_smart_bounds(self):
1072-
"""get whether the axis has smart bounds"""
1072+
"""Return whether the axis has smart bounds."""
10731073
return self._smart_bounds
10741074

10751075
def _update_ticks(self):

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def idle_draw(*args):
339339
self._idle_callback = self._tkcanvas.after_idle(idle_draw)
340340

341341
def get_tk_widget(self):
342-
"""returns the Tk widget used to implement FigureCanvasTkAgg.
342+
"""Return the Tk widget used to implement FigureCanvasTkAgg.
343343
Although the initial implementation uses a Tk canvas, this routine
344344
is intended to hide that fact.
345345
"""

lib/matplotlib/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_subplot_params(self, figure=None, fig=None):
6363

6464
def new_subplotspec(self, loc, rowspan=1, colspan=1):
6565
"""
66-
create and return a SubplotSpec instance.
66+
Create and return a SubplotSpec instance.
6767
"""
6868
loc1, loc2 = loc
6969
subplotspec = self[loc1:loc1+rowspan, loc2:loc2+colspan]

lib/matplotlib/rcsetup.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def validate_bool(b):
128128

129129

130130
def validate_bool_maybe_none(b):
131-
'Convert b to a boolean or raise'
131+
"""Convert b to a boolean or raise."""
132132
if isinstance(b, str):
133133
b = b.lower()
134134
if b is None or b == 'none':
@@ -142,7 +142,7 @@ def validate_bool_maybe_none(b):
142142

143143

144144
def validate_float(s):
145-
"""convert s to float or raise"""
145+
"""Convert s to float or raise."""
146146
try:
147147
return float(s)
148148
except ValueError:
@@ -151,7 +151,7 @@ def validate_float(s):
151151

152152

153153
def validate_float_or_None(s):
154-
"""convert s to float, None or raise"""
154+
"""Convert s to float, None or raise."""
155155
# values directly from the rc file can only be strings,
156156
# so we need to recognize the string "None" and convert
157157
# it into the object. We will be case-sensitive here to
@@ -166,7 +166,7 @@ def validate_float_or_None(s):
166166

167167

168168
def validate_string_or_None(s):
169-
"""convert s to string or raise"""
169+
"""Convert s to string or raise."""
170170
if s is None:
171171
return None
172172
try:
@@ -202,7 +202,7 @@ def validate_axisbelow(s):
202202

203203

204204
def validate_dpi(s):
205-
"""confirm s is string 'figure' or convert s to float or raise"""
205+
"""Confirm s is string 'figure' or convert s to float or raise."""
206206
if s == 'figure':
207207
return s
208208
try:
@@ -213,15 +213,15 @@ def validate_dpi(s):
213213

214214

215215
def validate_int(s):
216-
"""convert s to int or raise"""
216+
"""Convert s to int or raise."""
217217
try:
218218
return int(s)
219219
except ValueError:
220220
raise ValueError('Could not convert "%s" to int' % s)
221221

222222

223223
def validate_int_or_None(s):
224-
"""if not None, tries to validate as an int"""
224+
"""Return None if s is None or return ``int(s)``, otherwise raise."""
225225
if s == 'None':
226226
s = None
227227
if s is None:
@@ -234,8 +234,8 @@ def validate_int_or_None(s):
234234

235235
def validate_fonttype(s):
236236
"""
237-
confirm that this is a Postscript of PDF font type that we know how to
238-
convert to
237+
Confirm that this is a Postscript or PDF font type that we know how to
238+
convert to.
239239
"""
240240
fonttypes = {'type3': 3,
241241
'truetype': 42}
@@ -302,7 +302,7 @@ def __init__(self, n=None, allow_none=False):
302302
self.allow_none = allow_none
303303

304304
def __call__(self, s):
305-
"""return a seq of n floats or raise"""
305+
"""Return a list of *n* floats or raise."""
306306
if isinstance(s, str):
307307
s = [x.strip() for x in s.split(',')]
308308
err_msg = _str_err_msg
@@ -326,7 +326,7 @@ def __init__(self, n=None):
326326
self.n = n
327327

328328
def __call__(self, s):
329-
"""return a seq of n ints or raise"""
329+
"""Return a list of *n* ints or raise."""
330330
if isinstance(s, str):
331331
s = [x.strip() for x in s.split(',')]
332332
err_msg = _str_err_msg
@@ -343,7 +343,7 @@ def __call__(self, s):
343343

344344

345345
def validate_color_or_inherit(s):
346-
'return a valid color arg'
346+
"""Return a valid color arg."""
347347
if s == 'inherit':
348348
return s
349349
return validate_color(s)
@@ -372,7 +372,7 @@ def validate_color_for_prop_cycle(s):
372372

373373

374374
def validate_color(s):
375-
'return a valid color arg'
375+
"""Return a valid color arg."""
376376
try:
377377
if s.lower() == 'none':
378378
return 'none'
@@ -864,7 +864,7 @@ def cycler(*args, **kwargs):
864864

865865

866866
def validate_cycler(s):
867-
'return a Cycler object from a string repr or the object itself'
867+
"""Return a Cycler object from a string repr or the object itself."""
868868
if isinstance(s, str):
869869
try:
870870
# TODO: We might want to rethink this...

lib/matplotlib/spines.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
7979
self._patch_transform = mtransforms.IdentityTransform()
8080

8181
def set_smart_bounds(self, value):
82-
"""set the spine and associated axis to have smart bounds"""
82+
"""Set the spine and associated axis to have smart bounds."""
8383
self._smart_bounds = value
8484

8585
# also set the axis if possible
@@ -90,11 +90,11 @@ def set_smart_bounds(self, value):
9090
self.stale = True
9191

9292
def get_smart_bounds(self):
93-
"""get whether the spine has smart bounds"""
93+
"""Return whether the spine has smart bounds."""
9494
return self._smart_bounds
9595

9696
def set_patch_arc(self, center, radius, theta1, theta2):
97-
"""set the spine to be arc-like"""
97+
"""Set the spine to be arc-like."""
9898
self._patch_type = 'arc'
9999
self._center = center
100100
self._width = radius * 2
@@ -107,7 +107,7 @@ def set_patch_arc(self, center, radius, theta1, theta2):
107107
self.stale = True
108108

109109
def set_patch_circle(self, center, radius):
110-
"""set the spine to be circular"""
110+
"""Set the spine to be circular."""
111111
self._patch_type = 'circle'
112112
self._center = center
113113
self._width = radius * 2
@@ -117,7 +117,7 @@ def set_patch_circle(self, center, radius):
117117
self.stale = True
118118

119119
def set_patch_line(self):
120-
"""set the spine to be linear"""
120+
"""Set the spine to be linear."""
121121
self._patch_type = 'line'
122122
self.stale = True
123123

@@ -212,7 +212,7 @@ def _ensure_position_is_set(self):
212212
self.set_position(self._position)
213213

214214
def register_axis(self, axis):
215-
"""register an axis
215+
"""Register an axis.
216216
217217
An axis should be registered with its corresponding spine from
218218
the Axes instance. This allows the spine to clear any axis
@@ -224,14 +224,14 @@ def register_axis(self, axis):
224224
self.stale = True
225225

226226
def cla(self):
227-
"""Clear the current spine"""
227+
"""Clear the current spine."""
228228
self._position = None # clear position
229229
if self.axis is not None:
230230
self.axis.cla()
231231

232232
@cbook.deprecated("3.1")
233233
def is_frame_like(self):
234-
"""return True if directly on axes frame
234+
"""Return True if directly on axes frame.
235235
236236
This is useful for determining if a spine is the edge of an
237237
old style MPL plot. If so, this function will return True.
@@ -252,7 +252,7 @@ def is_frame_like(self):
252252
return False
253253

254254
def _adjust_location(self):
255-
"""automatically set spine bounds to the view interval"""
255+
"""Automatically set spine bounds to the view interval."""
256256

257257
if self.spine_type == 'circle':
258258
return
@@ -367,7 +367,7 @@ def draw(self, renderer):
367367
return ret
368368

369369
def _calc_offset_transform(self):
370-
"""calculate the offset transform performed by the spine"""
370+
"""Calculate the offset transform performed by the spine."""
371371
self._ensure_position_is_set()
372372
position = self._position
373373
if isinstance(position, str):
@@ -441,7 +441,7 @@ def _calc_offset_transform(self):
441441
mtransforms.IdentityTransform())
442442

443443
def set_position(self, position):
444-
"""set the position of the spine
444+
"""Set the position of the spine.
445445
446446
Spine position is specified by a 2 tuple of (position type,
447447
amount). The position types are:
@@ -480,12 +480,12 @@ def set_position(self, position):
480480
self.stale = True
481481

482482
def get_position(self):
483-
"""get the spine position"""
483+
"""Return the spine position."""
484484
self._ensure_position_is_set()
485485
return self._position
486486

487487
def get_spine_transform(self):
488-
"""get the spine transform"""
488+
"""Return the spine transform."""
489489
self._ensure_position_is_set()
490490
what, how = self._spine_transform
491491

lib/matplotlib/widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ def set_active(self, index):
638638

639639
def get_status(self):
640640
"""
641-
returns a tuple of the status (True/False) of all of the check buttons
641+
Return a tuple of the status (True/False) of all of the check buttons.
642642
"""
643643
return [l1.get_visible() for (l1, l2) in self.lines]
644644

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
604604
def append_axes(self, position, size, pad=None, add_to_figure=True,
605605
**kwargs):
606606
"""
607-
create an axes at the given *position* with the same height
607+
Create an axes at the given *position* with the same height
608608
(or width) of the main axes.
609609
610610
*position*
@@ -703,9 +703,8 @@ def _calc_offsets(appended_sizes, karray):
703703

704704
def new_locator(self, nx, nx1=None):
705705
"""
706-
returns a new locator
707-
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
708-
specified cell.
706+
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
707+
the specified cell.
709708
710709
Parameters
711710
----------
@@ -796,9 +795,8 @@ class VBoxDivider(HBoxDivider):
796795

797796
def new_locator(self, ny, ny1=None):
798797
"""
799-
returns a new locator
800-
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
801-
specified cell.
798+
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
799+
the specified cell.
802800
803801
Parameters
804802
----------

lib/mpl_toolkits/axes_grid1/axes_rgb.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True):
88
"""
9-
pad : fraction of the axes height.
9+
Parameters
10+
----------
11+
pad : float
12+
Fraction of the axes height.
1013
"""
1114

1215
divider = make_axes_locatable(ax)

lib/mpl_toolkits/axes_grid1/parasite_axes.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,11 @@ def pick(self, mouseevent):
251251

252252
def twinx(self, axes_class=None):
253253
"""
254-
create a twin of Axes for generating a plot with a sharex
255-
x-axis but independent y axis. The y-axis of self will have
256-
ticks on left and the returned axes will have ticks on the
257-
right
258-
"""
254+
Create a twin of Axes with a shared x-axis but independent y-axis.
259255
256+
The y-axis of self will have ticks on the left and the returned axes
257+
will have ticks on the right.
258+
"""
260259
if axes_class is None:
261260
axes_class = self._get_base_axes()
262261

@@ -280,12 +279,11 @@ def _remove_twinx(self, ax):
280279

281280
def twiny(self, axes_class=None):
282281
"""
283-
create a twin of Axes for generating a plot with a shared
284-
y-axis but independent x axis. The x-axis of self will have
285-
ticks on bottom and the returned axes will have ticks on the
286-
top
287-
"""
282+
Create a twin of Axes with a shared y-axis but independent x-axis.
288283
284+
The x-axis of self will have ticks on the bottom and the returned axes
285+
will have ticks on the top.
286+
"""
289287
if axes_class is None:
290288
axes_class = self._get_base_axes()
291289

@@ -309,12 +307,11 @@ def _remove_twiny(self, ax):
309307

310308
def twin(self, aux_trans=None, axes_class=None):
311309
"""
312-
create a twin of Axes for generating a plot with a sharex
313-
x-axis but independent y axis. The y-axis of self will have
314-
ticks on left and the returned axes will have ticks on the
315-
right
316-
"""
310+
Create a twin of Axes with no shared axis.
317311
312+
While self will have ticks on the left and bottom axis, the returned
313+
axes will have ticks on the top and right axis.
314+
"""
318315
if axes_class is None:
319316
axes_class = self._get_base_axes()
320317

0 commit comments

Comments
 (0)