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

Skip to content

Commit 118c852

Browse files
authored
Merge pull request #11674 from anntzer/style
Boring style fixes.
2 parents edd053d + baef067 commit 118c852

File tree

4 files changed

+43
-41
lines changed

4 files changed

+43
-41
lines changed

.flake8

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ per-file-ignores =
5454
matplotlib/sphinxext/mathmpl.py: E302
5555
matplotlib/sphinxext/only_directives.py: E302
5656
matplotlib/sphinxext/plot_directive.py: E261, E302, E402
57-
matplotlib/tests/test_image.py: E225, E231, E251, E302, E501
58-
matplotlib/tests/test_lines.py: E231, E261
59-
matplotlib/tests/test_mathtext.py: E261, E501
57+
matplotlib/tests/test_image.py: E231
58+
matplotlib/tests/test_mathtext.py: E501
6059
matplotlib/transforms.py: E201, E202, E203, E501
6160
matplotlib/tri/triinterpolate.py: E201, E221
6261
matplotlib/type1font.py: E731

lib/matplotlib/tests/test_image.py

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ def test_image_alpha():
205205
plt.subplot(133)
206206
plt.imshow(Z, alpha=0.5, interpolation='nearest')
207207

208+
208209
def test_cursor_data():
209210
from matplotlib.backend_bases import MouseEvent
210211

@@ -286,7 +287,8 @@ def test_image_cliprect():
286287

287288
im = ax.imshow(d, extent=(0,5,0,5))
288289

289-
rect = patches.Rectangle(xy=(1,1), width=2, height=2, transform=im.axes.transData)
290+
rect = patches.Rectangle(
291+
xy=(1,1), width=2, height=2, transform=im.axes.transData)
290292
im.set_clip_path(rect)
291293

292294

@@ -302,23 +304,20 @@ def test_imshow():
302304
@image_comparison(baseline_images=['no_interpolation_origin'],
303305
remove_text=True)
304306
def test_no_interpolation_origin():
305-
fig = plt.figure()
306-
ax = fig.add_subplot(211)
307-
ax.imshow(np.arange(100).reshape((2, 50)), origin="lower",
308-
interpolation='none')
309-
310-
ax = fig.add_subplot(212)
311-
ax.imshow(np.arange(100).reshape((2, 50)), interpolation='none')
307+
fig, axs = plt.subplots(2)
308+
axs[0].imshow(np.arange(100).reshape((2, 50)), origin="lower",
309+
interpolation='none')
310+
axs[1].imshow(np.arange(100).reshape((2, 50)), interpolation='none')
312311

313312

314313
@image_comparison(baseline_images=['image_shift'], remove_text=True,
315314
extensions=['pdf', 'svg'])
316315
def test_image_shift():
317316
from matplotlib.colors import LogNorm
318317

319-
imgData = [[1.0/(x) + 1.0/(y) for x in range(1,100)] for y in range(1,100)]
320-
tMin=734717.945208
321-
tMax=734717.946366
318+
imgData = [[1 / x + 1 / y for x in range(1, 100)] for y in range(1, 100)]
319+
tMin = 734717.945208
320+
tMax = 734717.946366
322321

323322
fig, ax = plt.subplots()
324323
ax.imshow(imgData, norm=LogNorm(), interpolation='none',
@@ -376,11 +375,13 @@ def test_image_composite_alpha():
376375
fig, ax = plt.subplots()
377376
arr = np.zeros((11, 21, 4))
378377
arr[:, :, 0] = 1
379-
arr[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))
378+
arr[:, :, 3] = np.concatenate(
379+
(np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))
380380
arr2 = np.zeros((21, 11, 4))
381381
arr2[:, :, 0] = 1
382382
arr2[:, :, 1] = 1
383-
arr2[:, :, 3] = np.concatenate((np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))[:, np.newaxis]
383+
arr2[:, :, 3] = np.concatenate(
384+
(np.arange(0, 1.1, 0.1), np.arange(0, 1, 0.1)[::-1]))[:, np.newaxis]
384385
ax.imshow(arr, extent=[1, 2, 5, 0], alpha=0.3)
385386
ax.imshow(arr, extent=[2, 3, 5, 0], alpha=0.6)
386387
ax.imshow(arr, extent=[3, 4, 5, 0])
@@ -397,21 +398,22 @@ def test_image_composite_alpha():
397398
remove_text=True, style='mpl20')
398399
def test_rasterize_dpi():
399400
# This test should check rasterized rendering with high output resolution.
400-
# It plots a rasterized line and a normal image with implot. So it will catch
401-
# when images end up in the wrong place in case of non-standard dpi setting.
402-
# Instead of high-res rasterization i use low-res. Therefore the fact that the
403-
# resolution is non-standard is easily checked by image_comparison.
401+
# It plots a rasterized line and a normal image with implot. So it will
402+
# catch when images end up in the wrong place in case of non-standard dpi
403+
# setting. Instead of high-res rasterization I use low-res. Therefore
404+
# the fact that the resolution is non-standard is easily checked by
405+
# image_comparison.
404406
img = np.asarray([[1, 2], [3, 4]])
405407

406-
fig, axes = plt.subplots(1, 3, figsize = (3, 1))
408+
fig, axes = plt.subplots(1, 3, figsize=(3, 1))
407409

408410
axes[0].imshow(img)
409411

410-
axes[1].plot([0,1],[0,1], linewidth=20., rasterized=True)
411-
axes[1].set(xlim = (0,1), ylim = (-1, 2))
412+
axes[1].plot([0,1], [0,1], linewidth=20., rasterized=True)
413+
axes[1].set(xlim=(0, 1), ylim=(-1, 2))
412414

413-
axes[2].plot([0,1],[0,1], linewidth=20.)
414-
axes[2].set(xlim = (0,1), ylim = (-1, 2))
415+
axes[2].plot([0,1], [0,1], linewidth=20.)
416+
axes[2].set(xlim=(0, 1), ylim=(-1, 2))
415417

416418
# Low-dpi PDF rasterization errors prevent proper image comparison tests.
417419
# Hide detailed structures like the axes spines.
@@ -441,8 +443,8 @@ def test_bbox_image_inverted():
441443

442444
image = np.identity(10)
443445

444-
bbox_im = BboxImage(
445-
TransformedBbox(Bbox([[0.1, 0.2], [0.3, 0.25]]), ax.figure.transFigure))
446+
bbox_im = BboxImage(TransformedBbox(Bbox([[0.1, 0.2], [0.3, 0.25]]),
447+
ax.figure.transFigure))
446448
bbox_im.set_data(image)
447449
bbox_im.set_clip_on(False)
448450
ax.add_artist(bbox_im)
@@ -459,7 +461,8 @@ def test_get_window_extent_for_AxisImage():
459461
ax.set_position([0, 0, 1, 1])
460462
ax.set_xlim(0, 1)
461463
ax.set_ylim(0, 1)
462-
im_obj = ax.imshow(im, extent=[0.4, 0.7, 0.2, 0.9], interpolation='nearest')
464+
im_obj = ax.imshow(
465+
im, extent=[0.4, 0.7, 0.2, 0.9], interpolation='nearest')
463466

464467
fig.canvas.draw()
465468
renderer = fig.canvas.renderer

lib/matplotlib/tests/test_lines.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ def test_invisible_Line_rendering():
3232
"""
3333
# Creates big x and y data:
3434
N = 10**7
35-
x = np.linspace(0,1,N)
35+
x = np.linspace(0, 1, N)
3636
y = np.random.normal(size=N)
3737

3838
# Create a plot figure:
3939
fig = plt.figure()
4040
ax = plt.subplot(111)
4141

4242
# Create a "big" Line instance:
43-
l = mlines.Line2D(x,y)
43+
l = mlines.Line2D(x, y)
4444
l.set_visible(False)
4545
# but don't add it to the Axis instance `ax`
4646

@@ -58,7 +58,7 @@ def test_invisible_Line_rendering():
5858
# gives about 290 ms for N = 10**7 pts
5959

6060
slowdown_factor = (t_unvisible_line/t_no_line)
61-
slowdown_threshold = 2 # trying to avoid false positive failures
61+
slowdown_threshold = 2 # trying to avoid false positive failures
6262
assert slowdown_factor < slowdown_threshold
6363

6464

lib/matplotlib/tests/test_mathtext.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
'$\\alpha \\beta \\gamma \\delta \\epsilon \\zeta \\eta \\theta \\iota \\lambda \\mu \\nu \\xi \\pi \\kappa \\rho \\sigma \\tau \\upsilon \\phi \\chi \\psi$',
5656

5757
# The examples prefixed by 'mmltt' are from the MathML torture test here:
58-
# http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml
58+
# http://www.mozilla.org/projects/mathml/demo/texvsmml.xhtml
5959
r'${x}^{2}{y}^{2}$',
6060
r'${}_{2}F_{3}$',
6161
r'$\frac{x+{y}^{2}}{k+1}$',
@@ -87,26 +87,26 @@
8787
r'${x}_{92}^{31415}+\pi $',
8888
r'${x}_{{y}_{b}^{a}}^{{z}_{c}^{d}}$',
8989
r'${y}_{3}^{\prime \prime \prime }$',
90-
r"$\left( \xi \left( 1 - \xi \right) \right)$", # Bug 2969451
91-
r"$\left(2 \, a=b\right)$", # Sage bug #8125
92-
r"$? ! &$", # github issue #466
93-
r'$\operatorname{cos} x$', # github issue #553
90+
r"$\left( \xi \left( 1 - \xi \right) \right)$", # Bug 2969451
91+
r"$\left(2 \, a=b\right)$", # Sage bug #8125
92+
r"$? ! &$", # github issue #466
93+
r'$\operatorname{cos} x$', # github issue #553
9494
r'$\sum _{\genfrac{}{}{0}{}{0\leq i\leq m}{0<j<n}}P\left(i,j\right)$',
9595
r"$\left\Vert a \right\Vert \left\vert b \right\vert \left| a \right| \left\| b\right\| \Vert a \Vert \vert b \vert$",
9696
r'$\mathring{A} \stackrel{\circ}{A} \AA$',
9797
r'$M \, M \thinspace M \/ M \> M \: M \; M \ M \enspace M \quad M \qquad M \! M$',
9898
r'$\Cup$ $\Cap$ $\leftharpoonup$ $\barwedge$ $\rightharpoonup$',
9999
r'$\dotplus$ $\doteq$ $\doteqdot$ $\ddots$',
100-
r'$xyz^kx_kx^py^{p-2} d_i^jb_jc_kd x^j_i E^0 E^0_u$', # github issue #4873
100+
r'$xyz^kx_kx^py^{p-2} d_i^jb_jc_kd x^j_i E^0 E^0_u$', # github issue #4873
101101
r'${xyz}^k{x}_{k}{x}^{p}{y}^{p-2} {d}_{i}^{j}{b}_{j}{c}_{k}{d} {x}^{j}_{i}{E}^{0}{E}^0_u$',
102102
r'${\int}_x^x x\oint_x^x x\int_{X}^{X}x\int_x x \int^x x \int_{x} x\int^{x}{\int}_{x} x{\int}^{x}_{x}x$',
103103
r'testing$^{123}$',
104104
' '.join('$\\' + p + '$' for p in sorted(mathtext.Parser._snowflake)),
105105
r'$6-2$; $-2$; $ -2$; ${-2}$; ${ -2}$; $20^{+3}_{-2}$',
106-
r'$\overline{\omega}^x \frac{1}{2}_0^x$', # github issue #5444
107-
r'$,$ $.$ $1{,}234{, }567{ , }890$ and $1,234,567,890$', # github issue 5799
108-
r'$\left(X\right)_{a}^{b}$', # github issue 7615
109-
r'$\dfrac{\$100.00}{y}$', # github issue #1888
106+
r'$\overline{\omega}^x \frac{1}{2}_0^x$', # github issue #5444
107+
r'$,$ $.$ $1{,}234{, }567{ , }890$ and $1,234,567,890$', # github issue 5799
108+
r'$\left(X\right)_{a}^{b}$', # github issue 7615
109+
r'$\dfrac{\$100.00}{y}$', # github issue #1888
110110
]
111111

112112
digits = "0123456789"

0 commit comments

Comments
 (0)