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

Skip to content

Commit 38ee431

Browse files
committed
More style fixes.
1 parent b91b740 commit 38ee431

22 files changed

+165
-171
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/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/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__

lib/matplotlib/tests/test_image.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,21 @@ def test_interp_nearest_vs_none():
6565

6666
def do_figimage(suppressComposite):
6767
""" Helper for the next two tests """
68-
fig = plt.figure(figsize=(2,2), dpi=100)
68+
fig = plt.figure(figsize=(2, 2), dpi=100)
6969
fig.suppressComposite = suppressComposite
70-
x,y = np.ix_(np.arange(100.0)/100.0, np.arange(100.0)/100.0)
70+
x, y = np.ix_(np.arange(100) / 100.0, np.arange(100) / 100)
7171
z = np.sin(x**2 + y**2 - x*y)
7272
c = np.sin(20*x**2 + 50*y**2)
7373
img = z + c/5
7474

7575
fig.figimage(img, xo=0, yo=0, origin='lower')
76-
fig.figimage(img[::-1,:], xo=0, yo=100, origin='lower')
77-
fig.figimage(img[:,::-1], xo=100, yo=0, origin='lower')
78-
fig.figimage(img[::-1,::-1], xo=100, yo=100, origin='lower')
76+
fig.figimage(img[::-1, :], xo=0, yo=100, origin='lower')
77+
fig.figimage(img[:, ::-1], xo=100, yo=0, origin='lower')
78+
fig.figimage(img[::-1, ::-1], xo=100, yo=100, origin='lower')
7979

8080

8181
@image_comparison(baseline_images=['figimage-0'],
82-
extensions=['png','pdf'])
82+
extensions=['png', 'pdf'])
8383
def test_figimage0():
8484
'test the figimage method'
8585

@@ -88,7 +88,7 @@ def test_figimage0():
8888

8989

9090
@image_comparison(baseline_images=['figimage-1'],
91-
extensions=['png','pdf'])
91+
extensions=['png', 'pdf'])
9292
def test_figimage1():
9393
'test the figimage method'
9494
suppressComposite = True
@@ -97,7 +97,7 @@ def test_figimage1():
9797

9898
def test_image_python_io():
9999
fig, ax = plt.subplots()
100-
ax.plot([1,2,3])
100+
ax.plot([1, 2, 3])
101101
buffer = io.BytesIO()
102102
fig.savefig(buffer)
103103
buffer.seek(0)
@@ -277,22 +277,22 @@ def test_image_cliprect():
277277
import matplotlib.patches as patches
278278

279279
fig, ax = plt.subplots()
280-
d = [[1,2],[3,4]]
280+
d = [[1, 2], [3, 4]]
281281

282-
im = ax.imshow(d, extent=(0,5,0,5))
282+
im = ax.imshow(d, extent=(0, 5, 0, 5))
283283

284284
rect = patches.Rectangle(
285-
xy=(1,1), width=2, height=2, transform=im.axes.transData)
285+
xy=(1, 1), width=2, height=2, transform=im.axes.transData)
286286
im.set_clip_path(rect)
287287

288288

289289
@image_comparison(baseline_images=['imshow'], remove_text=True, style='mpl20')
290290
def test_imshow():
291291
fig, ax = plt.subplots()
292292
arr = np.arange(100).reshape((10, 10))
293-
ax.imshow(arr, interpolation="bilinear", extent=(1,2,1,2))
294-
ax.set_xlim(0,3)
295-
ax.set_ylim(0,3)
293+
ax.imshow(arr, interpolation="bilinear", extent=(1, 2, 1, 2))
294+
ax.set_xlim(0, 3)
295+
ax.set_ylim(0, 3)
296296

297297

298298
@image_comparison(baseline_images=['no_interpolation_origin'],
@@ -403,10 +403,10 @@ def test_rasterize_dpi():
403403

404404
axes[0].imshow(img)
405405

406-
axes[1].plot([0,1], [0,1], linewidth=20., rasterized=True)
406+
axes[1].plot([0, 1], [0, 1], linewidth=20., rasterized=True)
407407
axes[1].set(xlim=(0, 1), ylim=(-1, 2))
408408

409-
axes[2].plot([0,1], [0,1], linewidth=20.)
409+
axes[2].plot([0, 1], [0, 1], linewidth=20.)
410410
axes[2].set(xlim=(0, 1), ylim=(-1, 2))
411411

412412
# Low-dpi PDF rasterization errors prevent proper image comparison tests.
@@ -673,7 +673,7 @@ def test_image_preserve_size2():
673673
ax = plt.Axes(fig, [0.0, 0.0, 1.0, 1.0])
674674
ax.set_axis_off()
675675
fig.add_axes(ax)
676-
ax.imshow(data, interpolation='nearest', origin='lower',aspect='auto')
676+
ax.imshow(data, interpolation='nearest', origin='lower', aspect='auto')
677677
buff = io.BytesIO()
678678
fig.savefig(buff, dpi=1)
679679

@@ -837,7 +837,7 @@ def test_imshow_bignumbers():
837837
# putting a big number in an array of integers shouldn't
838838
# ruin the dynamic range of the resolved bits.
839839
fig, ax = plt.subplots()
840-
img = np.array([[1, 2, 1e12],[3, 1, 4]], dtype=np.uint64)
840+
img = np.array([[1, 2, 1e12], [3, 1, 4]], dtype=np.uint64)
841841
pc = ax.imshow(img)
842842
pc.set_clim(0, 5)
843843

@@ -849,7 +849,7 @@ def test_imshow_bignumbers_real():
849849
# putting a big number in an array of integers shouldn't
850850
# ruin the dynamic range of the resolved bits.
851851
fig, ax = plt.subplots()
852-
img = np.array([[2., 1., 1.e22],[4., 1., 3.]])
852+
img = np.array([[2., 1., 1.e22], [4., 1., 3.]])
853853
pc = ax.imshow(img)
854854
pc.set_clim(0, 5)
855855

lib/mpl_toolkits/axes_grid1/axes_rgb.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def make_rgb_axes(ax, pad=0.01, axes_class=None, add_all=True):
5555
def imshow_rgb(ax, r, g, b, **kwargs):
5656
ny, nx = r.shape
5757
R = np.zeros([ny, nx, 3], dtype="d")
58-
R[:,:,0] = r
58+
R[:, :, 0] = r
5959
G = np.zeros_like(R)
60-
G[:,:,1] = g
60+
G[:, :, 1] = g
6161
B = np.zeros_like(R)
62-
B[:,:,2] = b
62+
B[:, :, 2] = b
6363

6464
RGB = R + G + B
6565

@@ -202,11 +202,11 @@ def imshow_rgb(self, r, g, b, **kwargs):
202202
.format(r.shape, g.shape, b.shape))
203203
RGB = np.dstack([r, g, b])
204204
R = np.zeros_like(RGB)
205-
R[:,:,0] = r
205+
R[:, :, 0] = r
206206
G = np.zeros_like(RGB)
207-
G[:,:,1] = g
207+
G[:, :, 1] = g
208208
B = np.zeros_like(RGB)
209-
B[:,:,2] = b
209+
B[:, :, 2] = b
210210

211211
im_rgb = self.RGB.imshow(RGB, **kwargs)
212212
im_r = self.R.imshow(R, **kwargs)

0 commit comments

Comments
 (0)