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

Skip to content

Commit 1a40221

Browse files
authored
Merge pull request #12026 from anntzer/style
whitespace(-mostly) style cleanup.
2 parents 256e49e + 4633cbd commit 1a40221

29 files changed

+234
-371
lines changed

.flake8

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,50 +31,49 @@ per-file-ignores =
3131
matplotlib/_cm.py: E202, E203, E302
3232
matplotlib/_mathtext_data.py: E203, E261
3333
matplotlib/backend_bases.py: E225
34-
matplotlib/backends/_backend_tk.py: E203, E222, E225, E231, E271, E301, E303, E401, E501, E701
35-
matplotlib/backends/backend_agg.py: E261, E302, E701
36-
matplotlib/backends/backend_cairo.py: E203, E221, E261, E303, E402
37-
matplotlib/backends/backend_gtk3.py: E203, E221, E222, E225, E251, E261, E501
34+
matplotlib/backends/_backend_tk.py: E203, E222, E225, E231, E271, E301, E401, E501, E701
35+
matplotlib/backends/backend_agg.py: E302, E701
36+
matplotlib/backends/backend_cairo.py: E203, E221, E402
37+
matplotlib/backends/backend_gtk3.py: E203, E221, E222, E225, E251, E501
3838
matplotlib/backends/backend_pgf.py: E303, E731
3939
matplotlib/backends/qt_editor/formlayout.py: E301, E501
40-
matplotlib/backends/tkagg.py: E231, E302, E701
41-
matplotlib/font_manager.py: E203, E221, E251, E261, E262, E302, E501
42-
matplotlib/fontconfig_pattern.py: E201, E203, E221, E222, E225, E302
40+
matplotlib/backends/tkagg.py: E231, E701
41+
matplotlib/font_manager.py: E203, E221, E251, E501
42+
matplotlib/fontconfig_pattern.py: E201, E203, E221, E222, E225
4343
matplotlib/mathtext.py: E201, E202, E203, E211, E221, E222, E225, E251, E301, E402
44-
matplotlib/projections/geo.py: E203, E221, E231, E261, E502
44+
matplotlib/projections/geo.py: E203, E221, E231, E502
4545
matplotlib/pylab.py: E501
4646
matplotlib/pyplot.py: E302, E701
47-
matplotlib/rcsetup.py: E203, E225, E261, E302, E501
47+
matplotlib/rcsetup.py: E203, E225, E501
4848
matplotlib/sphinxext/plot_directive.py: E402
4949
matplotlib/tests/test_image.py: E231
5050
matplotlib/tests/test_mathtext.py: E501
5151
matplotlib/transforms.py: E201, E202, E203, E501
5252
matplotlib/tri/triinterpolate.py: E201, E221
5353
matplotlib/type1font.py: E731
5454

55-
mpl_toolkits/__init__.py: E261
5655
mpl_toolkits/axes_grid/axes_rgb.py: E501
5756
mpl_toolkits/axes_grid1/axes_divider.py: E402, E501
5857
mpl_toolkits/axes_grid1/axes_grid.py: E225
5958
mpl_toolkits/axes_grid1/axes_rgb.py: E231
60-
mpl_toolkits/axes_grid1/axes_size.py: E261, E501
61-
mpl_toolkits/axes_grid1/colorbar.py: E225, E231, E261, E262, E302, E303, E501, E701
59+
mpl_toolkits/axes_grid1/axes_size.py: E501
60+
mpl_toolkits/axes_grid1/colorbar.py: E225, E231, E501
6261
mpl_toolkits/axes_grid1/inset_locator.py: E501
6362
mpl_toolkits/axes_grid1/mpl_axes.py: E501
64-
mpl_toolkits/axisartist/angle_helper.py: E201, E203, E221, E222, E225, E231, E251, E261, E262, E302, E303, E501
65-
mpl_toolkits/axisartist/axis_artist.py: E201, E202, E221, E225, E228, E231, E251, E261, E262, E302, E303, E402, E501, E701
66-
mpl_toolkits/axisartist/axisline_style.py: E231, E261, E262, E302, E303
67-
mpl_toolkits/axisartist/axislines.py: E225, E231, E261, E303, E501
68-
mpl_toolkits/axisartist/clip_path.py: E225, E302, E303, E501
69-
mpl_toolkits/axisartist/floating_axes.py: E225, E231, E261, E262, E302, E303, E402, E501
70-
mpl_toolkits/axisartist/grid_finder.py: E231, E261, E302, E303, E402
71-
mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E231, E261, E262, E271, E302, E303, E501
63+
mpl_toolkits/axisartist/angle_helper.py: E201, E203, E221, E222, E225, E231, E251, E501
64+
mpl_toolkits/axisartist/axis_artist.py: E201, E202, E221, E225, E228, E231, E251, E501, E701
65+
mpl_toolkits/axisartist/axisline_style.py: E231
66+
mpl_toolkits/axisartist/axislines.py: E225, E231, E501
67+
mpl_toolkits/axisartist/clip_path.py: E225, E501
68+
mpl_toolkits/axisartist/floating_axes.py: E225, E231, E402, E501
69+
mpl_toolkits/axisartist/grid_finder.py: E231
70+
mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E231, E501
7271
mpl_toolkits/mplot3d/art3d.py: E203, E222, E225, E231
7372
mpl_toolkits/mplot3d/axes3d.py: E203, E231, E402, E501, E701
74-
mpl_toolkits/mplot3d/axis3d.py: E231, E302
75-
mpl_toolkits/mplot3d/proj3d.py: E231, E302, E303
73+
mpl_toolkits/mplot3d/axis3d.py: E231
74+
mpl_toolkits/mplot3d/proj3d.py: E231
7675
mpl_toolkits/tests/test_axes_grid1.py: E201, E202
77-
mpl_toolkits/tests/test_mplot3d.py: E231, E302
76+
mpl_toolkits/tests/test_mplot3d.py: E231
7877

7978
doc/conf.py: E402, E501
8079
doc/sphinxext/github.py: E302, E501
@@ -188,11 +187,11 @@ per-file-ignores =
188187
examples/pyplots/annotate_transform.py: E228, E251, E402, E501
189188
examples/pyplots/annotation_basic.py: E402
190189
examples/pyplots/annotation_polar.py: E231, E402
191-
examples/pyplots/auto_subplots_adjust.py: E231, E261, E302, E402
190+
examples/pyplots/auto_subplots_adjust.py: E231, E302, E402
192191
examples/pyplots/boxplot_demo_pyplot.py: E231, E402
193192
examples/pyplots/compound_path_demo.py: E231
194193
examples/pyplots/dollar_ticks.py: E402
195-
examples/pyplots/fig_axes_customize_simple.py: E261, E402
194+
examples/pyplots/fig_axes_customize_simple.py: E402
196195
examples/pyplots/fig_axes_labels_simple.py: E402
197196
examples/pyplots/fig_x.py: E402
198197
examples/pyplots/pyplot_formatstr.py: E231, E402
@@ -206,12 +205,12 @@ per-file-ignores =
206205
examples/pyplots/text_commands.py: E231, E402
207206
examples/pyplots/text_layout.py: E231, E402
208207
examples/pyplots/whats_new_1_subplot3d.py: E402
209-
examples/pyplots/whats_new_98_4_fancy.py: E225, E261, E302, E402
208+
examples/pyplots/whats_new_98_4_fancy.py: E302, E402
210209
examples/pyplots/whats_new_98_4_fill_between.py: E225, E402
211210
examples/pyplots/whats_new_98_4_legend.py: E228, E402
212211
examples/pyplots/whats_new_99_axes_grid.py: E402
213212
examples/pyplots/whats_new_99_mplot3d.py: E402
214-
examples/pyplots/whats_new_99_spines.py: E231, E261, E402
213+
examples/pyplots/whats_new_99_spines.py: E231, E402
215214
examples/recipes/placing_text_boxes.py: E501
216215
examples/scales/power_norm.py: E402
217216
examples/shapes_and_collections/artist_reference.py: E402

examples/pyplots/auto_subplots_adjust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def on_draw(event):
3232
bbox = mtransforms.Bbox.union(bboxes)
3333
if fig.subplotpars.left < bbox.width:
3434
# we need to move it over
35-
fig.subplots_adjust(left=1.1*bbox.width) # pad a little
35+
fig.subplots_adjust(left=1.1*bbox.width) # pad a little
3636
fig.canvas.draw()
3737
return False
3838

examples/pyplots/fig_axes_customize_simple.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# ``plt.figure`` creates a ```matplotlib.figure.Figure`` instance
1313

1414
fig = plt.figure()
15-
rect = fig.patch # a rectangle instance
15+
rect = fig.patch # a rectangle instance
1616
rect.set_facecolor('lightgoldenrodyellow')
1717

1818
ax1 = fig.add_axes([0.1, 0.3, 0.4, 0.4])

examples/pyplots/whats_new_98_4_fancy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ def make_arrowstyles(ax):
2929
ax.set_ylim(0, figheight)
3030

3131
for i, (stylename, styleclass) in enumerate(sorted(styles.items())):
32-
y = (float(len(styles)) -0.25 - i) # /figheight
32+
y = (float(len(styles)) - 0.25 - i) # /figheight
3333
p = mpatch.Circle((3.2, y), 0.2, fc="w")
3434
ax.add_patch(p)
3535

3636
ax.annotate(stylename, (3.2, y),
3737
(2., y),
38-
#xycoords="figure fraction", textcoords="figure fraction",
38+
# xycoords="figure fraction", textcoords="figure fraction",
3939
ha="right", va="center",
4040
size=fontsize,
4141
arrowprops=dict(arrowstyle=stylename,

examples/pyplots/whats_new_99_spines.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
def adjust_spines(ax,spines):
1212
for loc, spine in ax.spines.items():
1313
if loc in spines:
14-
spine.set_position(('outward',10)) # outward by 10 points
14+
spine.set_position(('outward', 10)) # outward by 10 points
1515
else:
16-
spine.set_color('none') # don't draw spine
16+
spine.set_color('none') # don't draw spine
1717

1818
# turn off ticks where there is no spine
1919
if 'left' in spines:

lib/matplotlib/backends/_backend_tk.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def resize(self, event):
258258
hinch = height/dpival
259259
self.figure.set_size_inches(winch, hinch, forward=False)
260260

261-
262261
self._tkcanvas.delete(self._tkphoto)
263262
self._tkphoto = Tk.PhotoImage(
264263
master=self._tkcanvas, width=int(width), height=int(height))

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ def tostring_rgba_minimized(self):
118118
return np.array(region), extents
119119

120120
def draw_path(self, gc, path, transform, rgbFace=None):
121-
"""
122-
Draw the path
123-
"""
124-
nmax = rcParams['agg.path.chunksize'] # here at least for testing
121+
nmax = rcParams['agg.path.chunksize'] # here at least for testing
125122
npts = path.vertices.shape[0]
126123

127124
if (nmax > 100 and npts > nmax and path.should_simplify and

lib/matplotlib/backends/backend_cairo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class RendererCairo(RendererBase):
189189
'oblique' : cairo.FONT_SLANT_OBLIQUE,
190190
}
191191

192-
193192
def __init__(self, dpi):
194193
self.dpi = dpi
195194
self.gc = GraphicsContextCairo(renderer=self)
@@ -436,7 +435,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
436435
def new_gc(self):
437436
self.gc.ctx.save()
438437
self.gc._alpha = 1
439-
self.gc._forced_alpha = False # if True, _alpha overrides A from RGBA
438+
self.gc._forced_alpha = False # if True, _alpha overrides A from RGBA
440439
return self.gc
441440

442441
def points_to_pixels(self, points):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def configure_event(self, widget, event):
267267
return
268268
w, h = event.width, event.height
269269
if w < 3 or h < 3:
270-
return # empty fig
270+
return # empty fig
271271
# resize the figure (in inches)
272272
dpi = self.figure.dpi
273273
self.figure.set_size_inches(w / dpi, h / dpi, forward=False)
@@ -947,7 +947,7 @@ def trigger(self, *args, **kwargs):
947947

948948

949949
def error_msg_gtk(msg, parent=None):
950-
if parent is not None: # find the toplevel Gtk.Window
950+
if parent is not None: # find the toplevel Gtk.Window
951951
parent = parent.get_toplevel()
952952
if not parent.is_toplevel():
953953
parent = None

lib/matplotlib/backends/tkagg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def blit(photoimage, aggimage, bbox=None, colormode=1):
3535
tk.call("PyAggImagePhoto", photoimage,
3636
dataptr, colormode, bboxptr)
3737

38+
3839
def test(aggimage):
3940
r = Tk.Tk()
4041
c = Tk.Canvas(r, width=aggimage.width, height=aggimage.height)

lib/matplotlib/font_manager.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,8 @@ def __init__(self,
576576
weight = None,
577577
stretch= None,
578578
size = None,
579-
fname = None, # if set, it's a hardcoded filename to use
580-
_init = None # used only by copy()
579+
fname = None, # if set, it's a hardcoded filename to use
580+
_init = None, # used only by copy()
581581
):
582582
self._family = _normalize_font_family(rcParams['font.family'])
583583
self._slant = rcParams['font.style']
@@ -961,9 +961,9 @@ def __init__(self, size=None, weight='normal'):
961961
for pathname in ['TTFPATH', 'AFMPATH']:
962962
if pathname in os.environ:
963963
ttfpath = os.environ[pathname]
964-
if ttfpath.find(';') >= 0: #win32 style
964+
if ttfpath.find(';') >= 0: # win32 style
965965
paths.extend(ttfpath.split(';'))
966-
elif ttfpath.find(':') >= 0: # unix style
966+
elif ttfpath.find(':') >= 0: # unix style
967967
paths.extend(ttfpath.split(':'))
968968
else:
969969
paths.append(ttfpath)
@@ -1263,6 +1263,7 @@ def _findfont_cached(self, prop, fontext, directory, fallback_to_default,
12631263

12641264
return result
12651265

1266+
12661267
@lru_cache()
12671268
def is_opentype_cff_font(filename):
12681269
"""
@@ -1276,12 +1277,14 @@ def is_opentype_cff_font(filename):
12761277
else:
12771278
return False
12781279

1280+
12791281
fontManager = None
12801282
_fmcache = None
12811283

12821284

12831285
_get_font = lru_cache(64)(ft2font.FT2Font)
12841286

1287+
12851288
def get_font(filename, hinting_factor=None):
12861289
if hinting_factor is None:
12871290
hinting_factor = rcParams['text.hinting_factor']

lib/matplotlib/fontconfig_pattern.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
value_unescape = re.compile(r'\\([%s])' % value_punc).sub
2828
value_escape = re.compile(r'([%s])' % value_punc).sub
2929

30+
3031
class FontconfigPatternParser(object):
3132
"""A simple pyparsing-based parser for fontconfig-style patterns.
3233

lib/matplotlib/projections/geo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ def d(theta):
381381
latitude = ll[:, 1]
382382

383383
clat = np.pi/2 - np.abs(latitude)
384-
ihigh = clat < 0.087 # within 5 degrees of the poles
384+
ihigh = clat < 0.087 # within 5 degrees of the poles
385385
ilow = ~ihigh
386386
aux = np.empty(latitude.shape, dtype=float)
387387

@@ -394,7 +394,7 @@ def d(theta):
394394
delta, large_delta = d(theta)
395395
aux[ilow] = theta / 2
396396

397-
if ihigh.any(): # Taylor series-based approx. solution
397+
if ihigh.any(): # Taylor series-based approx. solution
398398
e = clat[ihigh]
399399
d = 0.5 * (3 * np.pi * e**2) ** (1.0/3)
400400
aux[ihigh] = (np.pi/2 - d) * np.sign(latitude[ihigh])

lib/matplotlib/pyplot.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -832,10 +832,10 @@ def axes(arg=None, **kwargs):
832832
--------
833833
::
834834
835-
#Creating a new full window axes
835+
# Creating a new full window axes
836836
plt.axes()
837837
838-
#Creating a new axes with specified dimensions and some kwargs
838+
# Creating a new axes with specified dimensions and some kwargs
839839
plt.axes((left, bottom, width, height), facecolor='w')
840840
"""
841841

@@ -1026,10 +1026,10 @@ def subplot(*args, **kwargs):
10261026
# add a red subplot that shares the x-axis with ax1
10271027
plt.subplot(224, sharex=ax1, facecolor='red')
10281028
1029-
#delete ax2 from the figure
1029+
# delete ax2 from the figure
10301030
plt.delaxes(ax2)
10311031
1032-
#add ax2 to the figure again
1032+
# add ax2 to the figure again
10331033
plt.subplot(ax2)
10341034
"""
10351035

@@ -1136,40 +1136,40 @@ def subplots(nrows=1, ncols=1, sharex=False, sharey=False, squeeze=True,
11361136
--------
11371137
::
11381138
1139-
#First create some toy data:
1139+
# First create some toy data:
11401140
x = np.linspace(0, 2*np.pi, 400)
11411141
y = np.sin(x**2)
11421142
1143-
#Creates just a figure and only one subplot
1143+
# Creates just a figure and only one subplot
11441144
fig, ax = plt.subplots()
11451145
ax.plot(x, y)
11461146
ax.set_title('Simple plot')
11471147
1148-
#Creates two subplots and unpacks the output array immediately
1148+
# Creates two subplots and unpacks the output array immediately
11491149
f, (ax1, ax2) = plt.subplots(1, 2, sharey=True)
11501150
ax1.plot(x, y)
11511151
ax1.set_title('Sharing Y axis')
11521152
ax2.scatter(x, y)
11531153
1154-
#Creates four polar axes, and accesses them through the returned array
1154+
# Creates four polar axes, and accesses them through the returned array
11551155
fig, axes = plt.subplots(2, 2, subplot_kw=dict(polar=True))
11561156
axes[0, 0].plot(x, y)
11571157
axes[1, 1].scatter(x, y)
11581158
1159-
#Share a X axis with each column of subplots
1159+
# Share a X axis with each column of subplots
11601160
plt.subplots(2, 2, sharex='col')
11611161
1162-
#Share a Y axis with each row of subplots
1162+
# Share a Y axis with each row of subplots
11631163
plt.subplots(2, 2, sharey='row')
11641164
1165-
#Share both X and Y axes with all subplots
1165+
# Share both X and Y axes with all subplots
11661166
plt.subplots(2, 2, sharex='all', sharey='all')
11671167
1168-
#Note that this is the same as
1168+
# Note that this is the same as
11691169
plt.subplots(2, 2, sharex=True, sharey=True)
11701170
1171-
#Creates figure number 10 with a single subplot
1172-
#and clears it if it already exists.
1171+
# Creates figure number 10 with a single subplot
1172+
# and clears it if it already exists.
11731173
fig, ax=plt.subplots(num=10, clear=True)
11741174
11751175
See Also

0 commit comments

Comments
 (0)