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

Skip to content

Commit 2ae9668

Browse files
authored
Merge pull request #12054 from anntzer/e231-e701
More style fixes.
2 parents 1393d3b + 122b256 commit 2ae9668

24 files changed

+170
-179
lines changed

.flake8

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,25 @@ per-file-ignores =
2626
setupext.py: E302, E501
2727

2828
tools/compare_backend_driver_results.py: E501
29-
tools/subset.py: E221, E231, E251, E261, E302, E501, E701
29+
tools/subset.py: E221, E251, E261, E302, E501
3030

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, E401, E501, E701
35-
matplotlib/backends/backend_agg.py: E302, E701
34+
matplotlib/backends/_backend_tk.py: E203, E222, E225, E301, E401, E501
35+
matplotlib/backends/backend_agg.py: E302
3636
matplotlib/backends/backend_cairo.py: E203, E221, E402
3737
matplotlib/backends/backend_gtk3.py: E203, E221, E222, E225, E251, E501
38-
matplotlib/backends/backend_pgf.py: E303, E731
38+
matplotlib/backends/backend_pgf.py: E731
3939
matplotlib/backends/qt_editor/formlayout.py: E301, E501
40-
matplotlib/backends/tkagg.py: E231, E701
4140
matplotlib/font_manager.py: E203, E221, E251, E501
4241
matplotlib/fontconfig_pattern.py: E201, E203, E221, E222, E225
4342
matplotlib/mathtext.py: E201, E202, E203, E211, E221, E222, E225, E251, E301, E402
44-
matplotlib/projections/geo.py: E203, E221, E231, E502
43+
matplotlib/projections/geo.py: E203, E221, E502
4544
matplotlib/pylab.py: E501
4645
matplotlib/pyplot.py: E302, E701
4746
matplotlib/rcsetup.py: E203, E225, E501
4847
matplotlib/sphinxext/plot_directive.py: E402
49-
matplotlib/tests/test_image.py: E231
5048
matplotlib/tests/test_mathtext.py: E501
5149
matplotlib/transforms.py: E201, E202, E203, E501
5250
matplotlib/tri/triinterpolate.py: E201, E221
@@ -55,25 +53,19 @@ per-file-ignores =
5553
mpl_toolkits/axes_grid/axes_rgb.py: E501
5654
mpl_toolkits/axes_grid1/axes_divider.py: E402, E501
5755
mpl_toolkits/axes_grid1/axes_grid.py: E225
58-
mpl_toolkits/axes_grid1/axes_rgb.py: E231
5956
mpl_toolkits/axes_grid1/axes_size.py: E272, E501
60-
mpl_toolkits/axes_grid1/colorbar.py: E225, E231, E501
57+
mpl_toolkits/axes_grid1/colorbar.py: E225, E501
6158
mpl_toolkits/axes_grid1/inset_locator.py: E501
6259
mpl_toolkits/axes_grid1/mpl_axes.py: 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
60+
mpl_toolkits/axisartist/angle_helper.py: E201, E203, E221, E222, E225, E251, E501
61+
mpl_toolkits/axisartist/axis_artist.py: E221, E225, E228, E251, E501
62+
mpl_toolkits/axisartist/axislines.py: E225, E501
6763
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
71-
mpl_toolkits/mplot3d/art3d.py: E203, E222, E225, E231
72-
mpl_toolkits/mplot3d/axes3d.py: E203, E231, E402, E501, E701
73-
mpl_toolkits/mplot3d/axis3d.py: E231
74-
mpl_toolkits/mplot3d/proj3d.py: E231
64+
mpl_toolkits/axisartist/floating_axes.py: E225, E402, E501
65+
mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501
66+
mpl_toolkits/mplot3d/art3d.py: E203, E222, E225
67+
mpl_toolkits/mplot3d/axes3d.py: E203, E402, E501
7568
mpl_toolkits/tests/test_axes_grid1.py: E201, E202
76-
mpl_toolkits/tests/test_mplot3d.py: E231
7769

7870
doc/conf.py: E402, E501
7971
doc/sphinxext/github.py: E302, E501

lib/matplotlib/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,9 +1727,9 @@ def loglog(self, *args, **kwargs):
17271727
All parameters supported by `.plot`.
17281728
"""
17291729
dx = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1730-
if k in kwargs}
1730+
if k in kwargs}
17311731
dy = {k: kwargs.pop(k) for k in ['basey', 'subsy', 'nonposy']
1732-
if k in kwargs}
1732+
if k in kwargs}
17331733

17341734
self.set_xscale('log', **dx)
17351735
self.set_yscale('log', **dy)
@@ -1780,7 +1780,7 @@ def semilogx(self, *args, **kwargs):
17801780
All parameters supported by `.plot`.
17811781
"""
17821782
d = {k: kwargs.pop(k) for k in ['basex', 'subsx', 'nonposx']
1783-
if k in kwargs}
1783+
if k in kwargs}
17841784

17851785
self.set_xscale('log', **d)
17861786
l = self.plot(*args, **kwargs)

lib/matplotlib/backends/_backend_tk.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def __init__(self, figure, master=None, resize_callback=None):
204204
super(FigureCanvasTk, self).__init__(figure)
205205
self._idle = True
206206
self._idle_callback = None
207-
t1,t2,w,h = self.figure.bbox.bounds
207+
t1, t2, w, h = self.figure.bbox.bounds
208208
w, h = int(w), int(h)
209209
self._tkcanvas = Tk.Canvas(
210210
master=master, background="white",
@@ -254,14 +254,15 @@ def resize(self, event):
254254

255255
# compute desired figure size in inches
256256
dpival = self.figure.dpi
257-
winch = width/dpival
258-
hinch = height/dpival
257+
winch = width / dpival
258+
hinch = height / dpival
259259
self.figure.set_size_inches(winch, hinch, forward=False)
260260

261261
self._tkcanvas.delete(self._tkphoto)
262262
self._tkphoto = Tk.PhotoImage(
263263
master=self._tkcanvas, width=int(width), height=int(height))
264-
self._tkcanvas.create_image(int(width/2),int(height/2),image=self._tkphoto)
264+
self._tkcanvas.create_image(
265+
int(width / 2), int(height / 2), image=self._tkphoto)
265266
self.resize_event()
266267
self.draw()
267268

@@ -329,7 +330,7 @@ def _update_pointer_position(self, guiEvent=None):
329330
# alternate implementation -- process enter/leave events
330331
# instead of motion/notify
331332
if self.figure.bbox.contains(xc, yc):
332-
self.enter_notify_event(guiEvent, xy=(xc,yc))
333+
self.enter_notify_event(guiEvent, xy=(xc, yc))
333334
else:
334335
self.leave_notify_event(guiEvent)
335336

@@ -375,13 +376,16 @@ def button_press_event(self, event, dblclick=False):
375376

376377
if sys.platform == 'darwin':
377378
# 2 and 3 were reversed on the OSX platform I tested under tkagg.
378-
if num == 2: num = 3
379-
elif num == 3: num = 2
379+
if num == 2:
380+
num = 3
381+
elif num == 3:
382+
num = 2
380383

381-
FigureCanvasBase.button_press_event(self, x, y, num, dblclick=dblclick, guiEvent=event)
384+
FigureCanvasBase.button_press_event(
385+
self, x, y, num, dblclick=dblclick, guiEvent=event)
382386

383-
def button_dblclick_event(self,event):
384-
self.button_press_event(event,dblclick=True)
387+
def button_dblclick_event(self, event):
388+
self.button_press_event(event, dblclick=True)
385389

386390
def button_release_event(self, event):
387391
x = event.x
@@ -392,19 +396,23 @@ def button_release_event(self, event):
392396

393397
if sys.platform == 'darwin':
394398
# 2 and 3 were reversed on the OSX platform I tested under tkagg.
395-
if num == 2: num = 3
396-
elif num == 3: num = 2
399+
if num == 2:
400+
num = 3
401+
elif num == 3:
402+
num = 2
397403

398404
FigureCanvasBase.button_release_event(self, x, y, num, guiEvent=event)
399405

400406
def scroll_event(self, event):
401407
x = event.x
402408
y = self.figure.bbox.height - event.y
403409
num = getattr(event, 'num', None)
404-
if num==4: step = +1
405-
elif num==5: step = -1
406-
else: step = 0
407-
410+
if num == 4:
411+
step = +1
412+
elif num == 5:
413+
step = -1
414+
else:
415+
step = 0
408416
FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=event)
409417

410418
def scroll_event_windows(self, event):
@@ -623,9 +631,7 @@ def draw_rubberband(self, event, x0, y0, x1, y1):
623631
#self.canvas.draw()
624632

625633
def release(self, event):
626-
try: self.lastrect
627-
except AttributeError: pass
628-
else:
634+
if hasattr(self, "lastrect"):
629635
self.canvas._tkcanvas.delete(self.lastrect)
630636
del self.lastrect
631637

@@ -675,7 +681,7 @@ def _init_toolbar(self):
675681
self.pack(side=Tk.BOTTOM, fill=Tk.X)
676682

677683
def configure_subplots(self):
678-
toolfig = Figure(figsize=(6,3))
684+
toolfig = Figure(figsize=(6, 3))
679685
window = Tk.Toplevel()
680686
canvas = type(self.canvas)(toolfig, master=window)
681687
toolfig.subplots_adjust(top=0.9)

lib/matplotlib/backends/backend_agg.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,9 @@ def draw(self):
406406
def get_renderer(self, cleared=False):
407407
l, b, w, h = self.figure.bbox.bounds
408408
key = w, h, self.figure.dpi
409-
try: self._lastKey, self.renderer
410-
except AttributeError: need_new_renderer = True
411-
else: need_new_renderer = (self._lastKey != key)
412-
413-
if need_new_renderer:
409+
reuse_renderer = (hasattr(self, "renderer")
410+
and getattr(self, "_lastKey", None) == key)
411+
if not reuse_renderer:
414412
self.renderer = RendererAgg(w, h, self.figure.dpi)
415413
self._lastKey = key
416414
elif cleared:

lib/matplotlib/backends/backend_pgf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
665665
prop_cmds = _font_properties_str(prop)
666666
s = r"%s %s" % (prop_cmds, s)
667667

668-
669668
writeln(self.fh, r"\begin{pgfscope}")
670669

671670
alpha = gc.get_alpha()

lib/matplotlib/backends/tkagg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def test(aggimage):
4242
c.pack()
4343
p = Tk.PhotoImage(width=aggimage.width, height=aggimage.height)
4444
blit(p, aggimage)
45-
c.create_image(aggimage.width,aggimage.height,image=p)
45+
c.create_image(aggimage.width, aggimage.height, image=p)
4646
blit(p, aggimage)
47-
while True: r.update_idletasks()
47+
while True:
48+
r.update_idletasks()

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,8 +1487,6 @@ def _add_solids(self, X, Y, C):
14871487
Draw the colors using :class:`~matplotlib.patches.Patch`;
14881488
optionally add separators.
14891489
"""
1490-
kw = {'alpha': self.alpha, }
1491-
14921490
n_segments = len(C)
14931491

14941492
# ensure there are sufficient hatches
@@ -1511,7 +1509,7 @@ def _add_solids(self, X, Y, C):
15111509
patch = mpatches.PathPatch(mpath.Path(xy),
15121510
facecolor=self.cmap(self.norm(val)),
15131511
hatch=hatch, linewidth=0,
1514-
antialiased=False, **kw)
1512+
antialiased=False, alpha=self.alpha)
15151513
self.ax.add_patch(patch)
15161514
patches.append(patch)
15171515

lib/matplotlib/projections/geo.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def _get_affine_transform(self):
118118
.scale(0.5 / xscale, 0.5 / yscale) \
119119
.translate(0.5, 0.5)
120120

121-
def get_xaxis_transform(self,which='grid'):
121+
def get_xaxis_transform(self, which='grid'):
122122
if which not in ['tick1', 'tick2', 'grid']:
123123
raise ValueError(
124124
"'which' must be one of 'tick1', 'tick2', or 'grid'")
@@ -130,7 +130,7 @@ def get_xaxis_text1_transform(self, pad):
130130
def get_xaxis_text2_transform(self, pad):
131131
return self._xaxis_text2_transform, 'top', 'center'
132132

133-
def get_yaxis_transform(self,which='grid'):
133+
def get_yaxis_transform(self, which='grid'):
134134
if which not in ['tick1', 'tick2', 'grid']:
135135
raise ValueError(
136136
"'which' must be one of 'tick1', 'tick2', or 'grid'")
@@ -146,8 +146,7 @@ def _gen_axes_patch(self):
146146
return Circle((0.5, 0.5), 0.5)
147147

148148
def _gen_axes_spines(self):
149-
return {'geo':mspines.Spine.circular_spine(self,
150-
(0.5, 0.5), 0.5)}
149+
return {'geo': mspines.Spine.circular_spine(self, (0.5, 0.5), 0.5)}
151150

152151
def set_yscale(self, *args, **kwargs):
153152
if args[0] != 'linear':
@@ -400,8 +399,8 @@ def d(theta):
400399
aux[ihigh] = (np.pi/2 - d) * np.sign(latitude[ihigh])
401400

402401
xy = np.empty(ll.shape, dtype=float)
403-
xy[:,0] = (2.0 * np.sqrt(2.0) / np.pi) * longitude * np.cos(aux)
404-
xy[:,1] = np.sqrt(2.0) * np.sin(aux)
402+
xy[:, 0] = (2.0 * np.sqrt(2.0) / np.pi) * longitude * np.cos(aux)
403+
xy[:, 1] = np.sqrt(2.0) * np.sin(aux)
405404

406405
return xy
407406
transform_non_affine.__doc__ = Transform.transform_non_affine.__doc__

0 commit comments

Comments
 (0)