8000 Bunch of docstring cleanups. · matplotlib/matplotlib@8e64156 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8e64156

Browse files
committed
Bunch of docstring cleanups.
1 parent dd18211 commit 8e64156

File tree

16 files changed

+74
-98
lines changed

16 files changed

+74
-98
lines changed

doc/sphinxext/gallery_order.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Configuration for the order of gallery sections and examples.
33
Paths are relative to the conf.py file.
4-
54
"""
65

76
from sphinx_gallery.sorting import ExplicitOrder

examples/images_contours_and_fields/tricontour_smooth_delaunay.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Tricontour Smooth Delaunay
44
==========================
55
6-
Demonstrates high-resolution tricontouring of a random set of points ;
6+
Demonstrates high-resolution tricontouring of a random set of points;
77
a `matplotlib.tri.TriAnalyzer` is used to improve the plot quality.
88
99
The initial data points and triangular grid for this demo are:
@@ -34,14 +34,14 @@
3434
# Analytical test function
3535
#-----------------------------------------------------------------------------
3636
def experiment_res(x, y):
37-
""" An analytic function representing experiment results """
38-
x = 2. * x
37+
"""An analytic function representing experiment results."""
38+
x = 2 * x
3939
r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2)
4040
theta1 = np.arctan2(0.5 - x, 0.5 - y)
4141
r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2)
4242
theta2 = np.arctan2(-x - 0.2, -y - 0.2)
43-
z = (4 * (np.exp((r1 / 10)**2) - 1) * 30. * np.cos(3 * theta1) +
44-
(np.exp((r2 / 10)**2) - 1) * 30. * np.cos(5 * theta2) +
43+
z = (4 * (np.exp((r1/10)**2) - 1) * 30 * np.cos(3 * theta1) +
44+
(np.exp((r2/10)**2) - 1) * 30 * np.cos(5 * theta2) +
4545
2 * (x**2 + y**2))
4646
return (np.max(z) - z) / (np.max(z) - np.min(z))
4747

examples/images_contours_and_fields/tricontour_smooth_user.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# Analytical test function
1717
#-----------------------------------------------------------------------------
1818
def function_z(x, y):
19-
""" A function of 2 variables """
2019
r1 = np.sqrt((0.5 - x)**2 + (0.5 - y)**2)
2120
theta1 = np.arctan2(0.5 - x, 0.5 - y)
2221
r2 = np.sqrt((-x - 0.2)**2 + (-y - 0.2)**2)

examples/images_contours_and_fields/trigradient_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# Electrical potential of a dipole
1818
#-----------------------------------------------------------------------------
1919
def dipole_potential(x, y):
20-
""" The electric dipole potential V """
20+
"""The electric dipole potential V, at position *x*, *y*."""
2121
r_sq = x**2 + y**2
2222
theta = np.arctan2(y, x)
2323
z = np.cos(theta)/r_sq

lib/matplotlib/backend_managers.py

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
"""
2-
`ToolManager`
3-
Class that makes the bridge between user interaction (key press,
4-
toolbar clicks, ..) and the actions in response to the user inputs.
5-
"""
6-
71
import logging
82

93
import matplotlib.cbook as cbook
@@ -15,7 +9,7 @@
159

1610

1711
class ToolEvent(object):
18-
"""Event for tool manipulation (add/remove)"""
12+
"""Event for tool manipulation (add/remove)."""
1913
def __init__(self, name, sender, tool, data=None):
2014
self.name = name
2115
self.sender = sender
@@ -24,17 +18,17 @@ def __init__(self, name, sender, tool, data=None):
2418

2519

2620
class ToolTriggerEvent(ToolEvent):
27-
"""Event to inform that a tool has been triggered"""
21+
"""Event to inform that a tool has been triggered."""
2822
def __init__(self, name, sender, tool, canvasevent=None, data=None):
2923
ToolEvent.__init__(self, name, sender, tool, data)
3024
self.canvasevent = canvasevent
3125

3226

3327
class ToolManagerMessageEvent(object):
3428
"""
35-
Event carrying messages from toolmanager
29+
Event carrying messages from toolmanager.
3630
37-
Messages usually get displayed to the user by the toolbar
31+
Messages usually get displayed to the user by the toolbar.
3832
"""
3933
def __init__(self, name, sender, message):
4034
self.name = name
@@ -44,7 +38,8 @@ def __init__(self, name, sender, message):
4438

4539
class ToolManager(object):
4640
"""
47-
Helper class that groups all the user interactions for a Figure.
41+
Manager for actions triggered by user interactions (key press, toolbar
42+
clicks, ...) on a Figure.
4843
4944
Attributes
5045
----------
@@ -76,14 +71,14 @@ def __init__(self, figure=None):
7671

7772
@property
7873
def canvas(self):
79-
"""Canvas managed by FigureManager"""
74+
"""Canvas managed by FigureManager."""
8075
if not self._figure:
8176
return None
8277
return self._figure.canvas
8378

8479
@property
8580
def figure(self):
86-
"""Figure that holds the canvas"""
81+
"""Figure that holds the canvas."""
8782
return self._figure
8883

8984
@figure.setter
@@ -138,19 +133,18 @@ def func(event)
138133

139134
def toolmanager_disconnect(self, cid):
140135
"""
141-
Disconnect callback id *cid*
136+
Disconnect callback id *cid*.
142137
143138
Example usage::
144139
145-
cid = toolmanager.toolmanager_connect('tool_trigger_zoom',
146-
on_press)
140+
cid = toolmanager.toolmanager_connect('tool_trigger_zoom', onpress)
147141
#...later
148142
toolmanager.toolmanager_disconnect(cid)
149143
"""
150144
return self._callbacks.disconnect(cid)
151145

< F438 /code>
152146
def message_event(self, message, sender=None):
153-
""" Emit a `ToolManagerMessageEvent`"""
147+
"""Emit a `ToolManagerMessageEvent`."""
154148
if sender is None:
155149
sender = self
156150

@@ -160,13 +154,12 @@ def message_event(self, message, sender=None):
160154

161155
@property
162156
def active_toggle(self):
163-
"""Currently toggled tools"""
164-
157+
"""Currently toggled tools."""
165158
return self._toggled
166159

167160
def get_tool_keymap(self, name):
168161
"""
169-
Get the keymap associated with the specified tool
162+
Get the keymap associated with the specified tool.
170163
171164
Parameters
172165
----------
@@ -187,7 +180,7 @@ def _remove_keys(self, name):
187180

188181
def update_keymap(self, name, *keys):
189182
"""
190-
Set the keymap to associate with the specified tool
183+
Set the keymap to associate with the specified tool.
191184
192185
Parameters
193186
----------
@@ -210,7 +203,7 @@ def update_keymap(self, name, *keys):
210203

211204
def remove_tool(self, name):
212205
"""
213-
Remove tool from `ToolManager`
206+
Remove tool named *name*.
214207
215208
Parameters
216209
----------
@@ -235,16 +228,16 @@ def remove_tool(self, name):
235228

236229
def add_tool(self, name, tool, *args, **kwargs):
237230
"""
238-
Add *tool* to `ToolManager`
231+
Add *tool* to `ToolManager`.
239232
240-
If successful adds a new event `tool_trigger_name` where **name** is
241-
the **name** of the tool, this event is fired everytime
242-
the tool is triggered.
233+
If successful, adds a new event ``tool_trigger_{name}`` where ``name``
234+
is the *name* of the tool; the event is fired everytime the tool is
235+
triggered.
243236
244237
Parameters
245238
----------
246239
name : str
247-
Name of the tool, treated as the ID, has to be unique
240+
Name of the tool, treated as the ID, has to be unique.
248241
tool : class_like, i.e. str or type
249242
Reference to find the class of the Tool to added.
250243
@@ -296,8 +289,8 @@ def _tool_added_event(self, tool):
296289

297290
def _handle_toggle(self, tool, sender, canvasevent, data):
298291
"""
299-
Toggle tools, need to untoggle prior to using other Toggle tool
300-
Called from trigger_tool
292+
Toggle tools, need to untoggle prior to using other Toggle tool.
293+
Called from trigger_tool.
301294
302295
Parameters
303296
----------
@@ -356,10 +349,9 @@ def _get_cls_to_instantiate(self, callback_class):
356349
else:
357350
return None
358351

359-
def trigger_tool(self, name, sender=None, canvasevent=None,
360-
data=None):
352+
def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
361353
"""
362-
Trigger a tool and emit the tool_trigger_[name] event
354+
Trigger a tool and emit the ``tool_trigger_{name}`` event.
363355
364356
Parameters
365357
----------
@@ -386,11 +378,7 @@ def trigger_tool(self, name, sender=None, canvasevent=None,
386378
self._callbacks.process(s, event)
387379

388380
def _trigger_tool(self, name, sender=None, canvasevent=None, data=None):
389-
"""
390-
Trigger on a tool
391-
392-
Method to actually trigger the tool
393-
"""
381+
"""Actually trigger a tool."""
394382
tool = self.get_tool(name)
395383

396384
if isinstance(tool, tools.ToolToggleBase):
@@ -411,13 +399,12 @@ def _key_press(self, event):
411399

412400
@property
413401
def tools(self):
414-
"""Return the tools controlled by `ToolManager`"""
415-
402+
"""Return the controlled tools."""
416403
return self._tools
417404

418405
def get_tool(self, name, warn=True):
419406
"""
420-
Return the tool object, also accepts the actual tool for convenience
407+
Return the tool object, also accepts the actual tool for convenience.
421408
422409
Parameters
423410
----------

lib/matplotlib/bezier.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class NonIntersectingPathException(ValueError):
1616

1717
def get_intersection(cx1, cy1, cos_t1, sin_t1,
1818
cx2, cy2, cos_t2, sin_t2):
19-
""" return a intersecting point between a line through (cx1, cy1)
20-
and having angle t1 and a line through (cx2, cy2) and angle t2.
19+
"""
20+
Return the intersection between the line through (*cx1*, *cy1*) at angle
21+
*t1* and the line through (*cx2, cy2) at angle *t2*.
2122
"""
2223

2324
# line1 => sin_t1 * (x - cx1) - cos_t1 * (y - cy1) = 0.
@@ -397,13 +398,12 @@ def get_parallels(bezier2, width):
397398

398399

399400
def find_control_points(c1x, c1y, mmx, mmy, c2x, c2y):
400-
""" Find control points of the bezier line through c1, mm, c2. We
401-
simply assume that c1, mm, c2 which have parametric value 0, 0.5, and 1.
402401
"""
403-
402+
Find control points of the Bezier curve passing through (*c1x*, *c1y*),
403+
(*mmx*, *mmy*), and (*c2x*, *c2y*), at parametric values 0, 0.5, and 1.
404+
"""
404405
cmx = .5 * (4 * mmx - (c1x + c2x))
405406
cmy = .5 * (4 * mmy - (c1y + c2y))
406-
407407
return [(c1x, c1y), (cmx, cmy), (c2x, c2y)]
408408

409409

lib/matplotlib/colors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,13 +1531,11 @@ def __init__(self, azdeg=315, altdeg=45, hsv_min_val=0, hsv_max_val=1,
15311531

15321532
@property
15331533
def direction(self):
1534-
""" The unit vector direction towards the light source """
1535-
1534+
"""The unit vector direction towards the light source."""
15361535
# Azimuth is in degrees clockwise from North. Convert to radians
15371536
# counterclockwise from East (mathematical notation).
15381537
az = np.radians(90 - self.azdeg)
15391538
alt = np.radians(self.altdeg)
1540-
15411539
return np.array([
15421540
np.cos(az) * np.cos(alt),
15431541
np.sin(az) * np.cos(alt),

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def __init__(self, *args, **kwargs):
897897
self.fontmap[name] = fullpath
898898

899899
def _get_glyph(self, fontname, font_class, sym, fontsize, math=True):
900-
""" Override prime symbol to use Bakoma """
900+
# Override prime symbol to use Bakoma.
901901
if sym == r'\prime':
902902
return self.bakoma._get_glyph(
903903
fontname, font_class, sym, fontsize, math)

lib/matplotlib/table.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,8 @@ def get_window_extent(self, renderer):
463463
return Bbox.union(boxes)
464464

465465
def _do_cell_alignment(self):
466-
""" Calculate row heights and column widths.
467-
468-
Position cells accordingly.
466+
"""
467+
Calculate row heights and column widths; position cells accordingly.
469468
"""
470469
# Calculate row/column widths
471470
widths = {}
@@ -523,7 +522,7 @@ def _auto_set_column_width(self, col, renderer):
523522
cell.set_width(max_width)
524523

525524
def auto_set_font_size(self, value=True):
526-
""" Automatically set font size. """
525+
"""Automatically set font size."""
527526
self._autoFontsize = value
528527
self.stale = True
529528

lib/matplotlib/tests/test_image.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def test_interp_nearest_vs_none():
8181

8282

8383
def do_figimage(suppressComposite):
84-
""" Helper for the next two tests """
84+
"""Helper for the next two tests."""
8585
fig = plt.figure(figsize=(2, 2), dpi=100)
8686
fig.suppressComposite = suppressComposite
8787
x, y = np.ix_(np.arange(100) / 100.0, np.arange(100) / 100)
@@ -95,19 +95,14 @@ def do_figimage(suppressComposite):
9595
fig.figimage(img[::-1, ::-1], xo=100, yo=100, origin='lower')
9696

9797

98-
@image_comparison(baseline_images=['figimage-0'],
99-
extensions=['png', 'pdf'])
98+
@image_comparison(baseline_images=['figimage-0'], extensions=['png', 'pdf'])
10099
def test_figimage0():
101-
'test the figimage method'
102-
103100
suppressComposite = False
104101
do_figimage(suppressComposite)
105102

106103

107-
@image_comparison(baseline_images=['figimage-1'],
108-
extensions=['png', 'pdf'])
104+
@image_comparison(baseline_images=['figimage-1'], extensions=['png', 'pdf'])
109105
def test_figimage1():
110-
'test the figimage method'
111106
suppressComposite = True
112107
do_figimage(suppressComposite)
113108

0 commit comments

Comments
 (0)
0