Skip to content

Commit 3ae86f1

Browse files
authored
Merge pull request #14337 from timhoffm/pydocstyle-D403
Docstring cleanup
2 parents 9299bcc + b956fa4 commit 3ae86f1

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
@@ -1091,12 +1091,12 @@ def get_ticklabel_extents(self, renderer):
10911091
return bbox, bbox2
10921092

10931093
def set_smart_bounds(self, value):
1094-
"""set the axis to have smart bounds"""
1094+
"""Set the axis to have smart bounds."""
10951095
self._smart_bounds = value
10961096
self.stale = True
10971097

10981098
def get_smart_bounds(self):
1099-
"""get whether the axis has smart bounds"""
1099+
"""Return whether the axis has smart bounds."""
11001100
return self._smart_bounds
11011101

11021102
def _update_ticks(self):

lib/matplotlib/backends/_backend_tk.py

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

271271
def get_tk_widget(self):
272-
"""returns the Tk widget used to implement FigureCanvasTkAgg.
272+
"""Return the Tk widget used to implement FigureCanvasTkAgg.
273273
Although the initial implementation uses a Tk canvas, this routine
274274
is intended to hide that fact.
275275
"""

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
@@ -131,7 +131,7 @@ def validate_bool(b):
131131

132132

133133
def validate_bool_maybe_none(b):
134-
'Convert b to a boolean or raise'
134+
"""Convert b to a boolean or raise."""
135135
if isinstance(b, str):
136136
b = b.lower()
137137
if b is None or b == 'none':
@@ -145,7 +145,7 @@ def validate_bool_maybe_none(b):
145145

146146

147147
def validate_float(s):
148-
"""convert s to float or raise"""
148+
"""Convert s to float or raise."""
149149
try:
150150
return float(s)
151151
except ValueError:
@@ -154,7 +154,7 @@ def validate_float(s):
154154

155155

156156
def validate_float_or_None(s):
157-
"""convert s to float, None or raise"""
157+
"""Convert s to float, None or raise."""
158158
# values directly from the rc file can only be strings,
159159
# so we need to recognize the string "None" and convert
160160
# it into the object. We will be case-sensitive here to
@@ -169,7 +169,7 @@ def validate_float_or_None(s):
169169

170170

171171
def validate_string_or_None(s):
172-
"""convert s to string or raise"""
172+
"""Convert s to string or raise."""
173173
if s is None:
174174
return None
175175
try:
@@ -205,7 +205,7 @@ def validate_axisbelow(s):
205205

206206

207207
def validate_dpi(s):
208-
"""confirm s is string 'figure' or convert s to float or raise"""
208+
"""Confirm s is string 'figure' or convert s to float or raise."""
209209
if s == 'figure':
210210
return s
211211
try:
@@ -216,15 +216,15 @@ def validate_dpi(s):
216216

217217

218218
def validate_int(s):
219-
"""convert s to int or raise"""
219+
"""Convert s to int or raise."""
220220
try:
221221
return int(s)
222222
except ValueError:
223223
raise ValueError('Could not convert "%s" to int' % s)
224224

225225

226226
def validate_int_or_None(s):
227-
"""if not None, tries to validate as an int"""
227+
"""Return None if s is None or return ``int(s)``, otherwise raise."""
228228
if s == 'None':
229229
s = None
230230
if s is None:
@@ -237,8 +237,8 @@ def validate_int_or_None(s):
237237

238238
def validate_fonttype(s):
239239
"""
240-
confirm that this is a Postscript of PDF font type that we know how to
241-
convert to
240+
Confirm that this is a Postscript or PDF font type that we know how to
241+
convert to.
242242
"""
243243
fonttypes = {'type3': 3,
244244
'truetype': 42}
@@ -305,7 +305,7 @@ def __init__(self, n=None, allow_none=False):
305305
self.allow_none = allow_none
306306

307307
def __call__(self, s):
308-
"""return a seq of n floats or raise"""
308+
"""Return a list of *n* floats or raise."""
309309
if isinstance(s, str):
310310
s = [x.strip() for x in s.split(',')]
311311
err_msg = _str_err_msg
@@ -329,7 +329,7 @@ def __init__(self, n=None):
329329
self.n = n
330330

331331
def __call__(self, s):
332-
"""return a seq of n ints or raise"""
332+
"""Return a list of *n* ints or raise."""
333333
if isinstance(s, str):
334334
s = [x.strip() for x in s.split(',')]
335335
err_msg = _str_err_msg
@@ -346,7 +346,7 @@ def __call__(self, s):
346346

347347

348348
def validate_color_or_inherit(s):
349-
'return a valid color arg'
349+
"""Return a valid color arg."""
350350
if s == 'inherit':
351351
return s
352352
return validate_color(s)
@@ -375,7 +375,7 @@ def validate_color_for_prop_cycle(s):
375375

376376

377377
def validate_color(s):
378-
'return a valid color arg'
378+
"""Return a valid color arg."""
379379
try:
380380
if s.lower() == 'none':
381381
return 'none'
@@ -867,7 +867,7 @@ def cycler(*args, **kwargs):
867867

868868

869869
def validate_cycler(s):
870-
'return a Cycler object from a string repr or the object itself'
870+
"""Return a Cycler object from a string repr or the object itself."""
871871
if isinstance(s, str):
872872
try:
873873
# 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
@@ -80,7 +80,7 @@ def __init__(self, axes, spine_type, path, **kwargs):
8080
self._patch_transform = mtransforms.IdentityTransform()
8181

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

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

9393
def get_smart_bounds(self):
94-
"""get whether the spine has smart bounds"""
94+
"""Return whether the spine has smart bounds."""
9595
return self._smart_bounds
9696

9797
def set_patch_arc(self, center, radius, theta1, theta2):
98-
"""set the spine to be arc-like"""
98+
"""Set the spine to be arc-like."""
9999
self._patch_type = 'arc'
100100
self._center = center
101101
self._width = radius * 2
@@ -108,7 +108,7 @@ def set_patch_arc(self, center, radius, theta1, theta2):
108108
self.stale = True
109109

110110
def set_patch_circle(self, center, radius):
111-
"""set the spine to be circular"""
111+
"""Set the spine to be circular."""
112112
self._patch_type = 'circle'
113113
self._center = center
114114
self._width = radius * 2
@@ -118,7 +118,7 @@ def set_patch_circle(self, center, radius):
118118
self.stale = True
119119

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

@@ -213,7 +213,7 @@ def _ensure_position_is_set(self):
213213
self.set_position(self._position)
214214

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

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

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

255255
def _adjust_location(self):
256-
"""automatically set spine bounds to the view interval"""
256+
"""Automatically set spine bounds to the view interval."""
257257

258258
if self.spine_type == 'circle':
259259
return
@@ -368,7 +368,7 @@ def draw(self, renderer):
368368
return ret
369369

370370
def _calc_offset_transform(self):
371-
"""calculate the offset transform performed by the spine"""
371+
"""Calculate the offset transform performed by the spine."""
372372
self._ensure_position_is_set()
373373
position = self._position
374374
if isinstance(position, str):
@@ -442,7 +442,7 @@ def _calc_offset_transform(self):
442442
mtransforms.IdentityTransform())
443443

444444
def set_position(self, position):
445-
"""set the position of the spine
445+
"""Set the position of the spine.
446446
447447
Spine position is specified by a 2 tuple of (position type,
448448
amount). The position types are:
@@ -481,12 +481,12 @@ def set_position(self, position):
481481
self.stale = True
482482

483483
def get_position(self):
484-
"""get the spine position"""
484+
"""Return the spine position."""
485485
self._ensure_position_is_set()
486486
return self._position
487487

488488
def get_spine_transform(self):
489-
"""get the spine transform"""
489+
"""Return the spine transform."""
490490
self._ensure_position_is_set()
491491
what, how = self._spine_transform
492492

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
@@ -614,7 +614,7 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
614614
def append_axes(self, position, size, pad=None, add_to_figure=True,
615615
**kwargs):
616616
"""
617-
create an axes at the given *position* with the same height
617+
Create an axes at the given *position* with the same height
618618
(or width) of the main axes.
619619
620620
*position*
@@ -713,9 +713,8 @@ def _calc_offsets(appended_sizes, karray):
713713

714714
def new_locator(self, nx, nx1=None):
715715
"""
716-
returns a new locator
717-
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
718-
specified cell.
716+
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
717+
the specified cell.
719718
720719
Parameters
721720
----------
@@ -806,9 +805,8 @@ class VBoxDivider(HBoxDivider):
806805

807806
def new_locator(self, ny, ny1=None):
808807
"""
809-
returns a new locator
810-
(:class:`mpl_toolkits.axes_grid.axes_divider.AxesLocator`) for
811-
specified cell.
808+
Create a new `~mpl_toolkits.axes_grid.axes_divider.AxesLocator` for
809+
the specified cell.
812810
813811
Parameters
814812
----------

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)