10000 Fix pydocstyle D403 in examples · matplotlib/matplotlib@3a8d600 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a8d600

Browse filesBrowse files
committed
Fix pydocstyle D403 in examples
1 parent efafb6c commit 3a8d600

File tree

14 files changed

+46
-41
lines changed

14 files changed

+46
-41
lines changed

examples/event_handling/path_editor.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,17 @@ def draw_callback(self, event):
7777
self.canvas.blit(self.ax.bbox)
7878

7979
def pathpatch_changed(self, pathpatch):
80-
'this method is called whenever the pathpatchgon object is called'
80+
"""This method is called whenever the pathpatchgon object is called."""
8181
# only copy the artist props to the line (except visibility)
8282
vis = self.line.get_visible()
8383
plt.Artist.update_from(self.line, pathpatch)
8484
self.line.set_visible(vis) # don't use the pathpatch visibility state
8585

8686
def get_ind_under_point(self, event):
87-
'get the index of the vertex under point if within epsilon tolerance'
88-
87+
"""
88+
Return the index of the point closest to the event position or *None*
89+
if no point is within ``self.epsilon`` to the event position.
90+
"""
8991
# display coords
9092
xy = np.asarray(self.pathpatch.get_path().vertices)
9193
xyt = self.pathpatch.get_transform().transform(xy)
@@ -99,7 +101,7 @@ def get_ind_under_point(self, event):
99101
return ind
100102

101103
def button_press_callback(self, event):
102-
'whenever a mouse button is pressed'
104+
"""Callback for mouse button presses."""
103105
if not self.showverts:
104106
return
105107
if event.inaxes is None:
@@ -109,15 +111,15 @@ def button_press_callback(self, event):
109111
self._ind = self.get_ind_under_point(event)
110112

111113
def button_release_callback(self, event):
112-
'whenever a mouse button is released'
114+
"""Callback for mouse button releases."""
113115
if not self.showverts:
114116
return
115117
if event.button != 1:
116118
return
117119
self._ind = None
118120

119121
def key_press_callback(self, event):
120-
'whenever a key is pressed'
122+
"""Callback for key presses."""
121123
if not event.inaxes:
122124
return
123125
if event.key == 't':
@@ -129,7 +131,7 @@ def key_press_callback(self, event):
129131
self.canvas.draw()
130132

131133
def motion_notify_callback(self, event):
132-
'on mouse movement'
134+
"""Callback for mouse movements."""
133< B41A /td>135
if not self.showverts:
134136
return
135137
if self._ind is None:

examples/event_handling/pick_event_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ def pick_custom_hit():
117117

118118
def line_picker(line, mouseevent):
119119
"""
120-
find the points within a certain distance from the mouseclick in
120+
Find the points within a certain distance from the mouseclick in
121121
data coords and attach some extra attributes, pickx and picky
122-
which are the data points that were picked
122+
which are the data points that were picked.
123123
"""
124124
if mouseevent.xdata is None:
125125
return False, dict()

examples/event_handling/poly_editor.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ def draw_callback(self, event):
9090
# updated
9191

9292
def poly_changed(self, poly):
93-
'this method is called whenever the polygon object is called'
93+
"""This method is called whenever the pathpatchgon object is called."""
9494
# only copy the artist props to the line (except visibility)
9595
vis = self.line.get_visible()
9696
Artist.update_from(self.line, poly)
9797
self.line.set_visible(vis) # don't use the poly visibility state
9898

9999
def get_ind_under_point(self, event):
100-
'get the index of the vertex under point if within epsilon tolerance'
101-
100+
"""
101+
Return the index of the point closest to the event position or *None*
102+
if no point is within ``self.epsilon`` to the event position.
103+
"""
102104
# display coords
103105
xy = np.asarray(self.poly.xy)
104106
xyt = self.poly.get_transform().transform(xy)
@@ -113,7 +115,7 @@ def get_ind_under_point(self, event):
113115
return ind
114116

115117
def button_press_callback(self, event):
116-
'whenever a mouse button is pressed'
118+
"""Callback for mouse button presses."""
117119
if not self.showverts:
118120
return
119121
if event.inaxes is None:
@@ -123,15 +125,15 @@ def button_press_callback(self, event):
123125
self._ind = self.get_ind_under_point(event)
124126

125127
def button_release_callback(self, event):
126-
'whenever a mouse button is released'
128+
"""Callback for mouse button releases."""
127129
if not self.showverts:
128130
return
129131
if event.button != 1:
130132
return
131133
self._ind = None
132134

133135
def key_press_callback(self, event):
134-
'whenever a key is pressed'
136+
"""Callback for key presses."""
135137
if not event.inaxes:
136138
return
137139
if event.key == 't':
@@ -163,7 +165,7 @@ def key_press_callback(self, event):
163165
self.canvas.draw_idle()
164166

165167
def motion_notify_callback(self, event):
166-
'on mouse movement'
168+
"""Callback for mouse movements."""
167169
if not self.showverts:
168170
return
169171
if self._ind is None:

examples/lines_bars_and_markers/filled_step.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ def stack_hist(ax, stacked_data, sty_cycle, bottoms=None,
8080
hist_func=None, labels=None,
8181
plot_func=None, plot_kwargs=None):
8282
"""
83+
Parameters
84+
----------
8385
ax : axes.Axes
8486
The axes to add artists too
8587

examples/lines_bars_and_markers/markevery_demo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444

4545

4646
def trim_axs(axs, N):
47-
"""little helper to massage the axs list to have correct length..."""
47+
"""
48+
Reduce *axs* to *N* Axes. All further Axes are removed from the figure.
49+
"""
4850
axs = axs.flat
4951
for ax in axs[N:]:
5052
ax.remove()

examples/statistics/barchart_demo.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@
3333

3434

3535
def attach_ordinal(num):
36-
"""helper function to add ordinal string to integers
37-
38-
1 -> 1st
39-
56 -> 56th
40-
"""
36+
"""Convert an integer to an ordinal string, e.g. 2 -> '2nd'."""
4137
suffixes = {str(i): v
4238
for i, v in enumerate(['th', 'st', 'nd', 'rd', 'th',
4339
'th', 'th', 'th', 'th', 'th'])}

examples/subplots_axes_and_figures/secondary_axis.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,13 @@ def inverse(x):
119119

120120

121121
def date2yday(x):
122-
"""
123-
x is in matplotlib datenums, so they are floats.
124-
"""
122+
"""Convert matplotlib datenum to days since 2018-01-01."""
125123
y = x - mdates.date2num(datetime.datetime(2018, 1, 1))
126124
return y
127125

128126

129127
def yday2date(x):
130-
"""
131-
return a matplotlib datenum (x is days since start of year)
132-
"""
128+
"""Return a matplotlib datenum for *x* days after 2018-01-01."""
133129
y = x + mdates.date2num(datetime.datetime(2018, 1, 1))
134130
return y
135131

examples/tests/backend_driver_sgskip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310

311311

312312
def report_missing(dir, flist):
313-
'report the py files in dir that are not in flist'
313+
"""Report the .py files in *dir* that are not in *flist*."""
314314
globstr = os.path.join(dir, '*.py')
315315
fnames = glob.glob(globstr)
316316

examples/text_labels_and_annotations/demo_text_path.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, path, bbox_image, **kwargs):
3636
self._init_bbox_image(bbox_image)
3737

3838
def set_facecolor(self, color):
39-
"""simply ignore facecolor"""
39+
"""Simply ignore facecolor."""
4040
mpatches.PathPatch.set_facecolor(self, "none")
4141

4242
def _init_bbox_image(self, im):

examples/units/basic_units.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ def rad_fn(x, pos=None):
319319
class BasicUnitConverter(units.ConversionInterface):
320320
@staticmethod
321321
def axisinfo(unit, axis):
322-
'return AxisInfo instance for x and unit'
322+
"""Return AxisInfo instance for x and unit."""
323323

324324
if unit == radians:
325325
return units.AxisInfo(
@@ -364,7 +364,7 @@ def convert(val, unit, axis):
364364

365365
@staticmethod
366366
def default_units(x, axis):
367-
'return the default unit for x or None'
367+
"""Return the default unit for x or None."""
368368
if np.iterable(x):
369369
for thisx in x:
370370
return thisx.unit

examples/units/evans_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def value(self, unit):
3030
class FooConverter(units.ConversionInterface):
3131
@staticmethod
3232
def axisinfo(unit, axis):
33-
'return the Foo AxisInfo'
33+
"""Return the Foo AxisInfo."""
3434
if unit == 1.0 or unit == 2.0:
3535
return units.AxisInfo(
3636
majloc=ticker.IndexLocator(8, 0),
@@ -44,8 +44,9 @@ def axisinfo(unit, axis):
4444
@staticmethod
4545
def convert(obj, unit, axis):
4646
"""
47-
convert obj using unit. If obj is a sequence, return the
48-
converted sequence
47+
Convert obj using unit.
48+
49+
If obj is a sequence, return the converted sequence.
4950
"""
5051
if units.ConversionInterface.is_numlike(obj):
5152
return obj
@@ -57,7 +58,7 @@ def convert(obj, unit, axis):
5758

5859
@staticmethod
5960
def default_units(x, axis):
60-
'return the default unit for x or None'
61+
"""Return the default unit for x or None."""
6162
if np.iterable(x):
6263
for thisx in x:
6364
return thisx.unit

examples/widgets/menu.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ def set_hover_props(self, b):
109109
self.rect.set(facecolor=props.bgcolor, alpha=props.alpha)
110110

111111
def set_hover(self, event):
112-
'check the hover status of event and return true if status is changed'
112+
"""
113+
Update the hover status of event and return whether it was changed.
114+
"""
113115
b, junk = self.rect.contains(event)
114116

115117
changed = (b != self.hover)

examples/widgets/rectangle_selector.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717

1818
def line_select_callback(eclick, erelease):
19-
'eclick and erelease are the press and release events'
19+
"""
20+
Callback for line selection.
21+
22+
*eclick* and *erelease* are the press and release events.
23+
"""
2024
x1, y1 = eclick.xdata, eclick.ydata
2125
x2, y2 = erelease.xdata, erelease.ydata
2226
print("(%3.2f, %3.2f) --> (%3.2f, %3.2f)" % (x1, y1, x2, y2))

tutorials/colors/colormap-manipulation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@
7979

8080

8181
def plot_examples(cms):
82-
"""
83-
helper function to plot two colormaps
84-
"""
82+
"""Helper function to plot two colormaps."""
8583
np.random.seed(19680801)
8684
data = np.random.randn(30, 30)
8785

0 commit comments

Comments
 (0)
0