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

Skip to content

Commit 46a5603

Browse files
committed
Merge pull request #3635 from thisch/examples_pep8_e201_202_e221_222
PEP8 : fix pep8 error classes e20[12] and e22[12] in examples
2 parents 0f4a68d + ea8617d commit 46a5603

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+213
-213
lines changed

examples/color/color_cycle_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
yy = np.transpose([np.sin(x + phi) for phi in offsets])
1818

1919
plt.rc('lines', linewidth=4)
20-
fig, (ax0, ax1) = plt.subplots(nrows=2)
20+
fig, (ax0, ax1) = plt.subplots(nrows=2)
2121

2222
plt.rc('axes', color_cycle=['r', 'g', 'b', 'y'])
2323
ax0.plot(yy)

examples/event_handling/looking_glass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
x, y = np.random.rand(2, 200)
55

66
fig, ax = plt.subplots()
7-
circ = patches.Circle( (0.5, 0.5), 0.25, alpha=0.8, fc='yellow')
7+
circ = patches.Circle((0.5, 0.5), 0.25, alpha=0.8, fc='yellow')
88
ax.add_patch(circ)
99

1010

examples/event_handling/pipong.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, disp, pad, field):
6262
def _reset(self,pad):
6363
self.x = pad.x + pad.xoffset
6464
if pad.y < 0:
65-
self.y = pad.y + pad.yoffset
65+
self.y = pad.y + pad.yoffset
6666
else:
6767
self.y = pad.y - pad.yoffset
6868
self.vx = pad.x - self.x
@@ -145,15 +145,15 @@ def __init__(self, ax):
145145
self.inst = True # show instructions from the beginning
146146
self.background = None
147147
self.pads = []
148-
self.pads.append( Pad(pA,0,padAy))
149-
self.pads.append( Pad(pB,padBx,padBy,'r'))
148+
self.pads.append(Pad(pA,0,padAy))
149+
self.pads.append(Pad(pB,padBx,padBy,'r'))
150150
self.pucks =[]
151151
self.i = self.ax.annotate(instructions,(.5,0.5),
152152
name='monospace',
153153
verticalalignment='center',
154154
horizontalalignment='center',
155155
multialignment='left',
156-
textcoords='axes fraction',animated=True )
156+
textcoords='axes fraction',animated=True)
157157
self.canvas.mpl_connect('key_press_event', self.key_press)
158158

159159
def draw(self, evt):

examples/misc/contour_manual.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
import matplotlib.cm as cm
77

88
# Contour lines for each level are a list/tuple of polygons.
9-
lines0 = [ [[0,0],[0,4]] ]
10-
lines1 = [ [[2,0],[1,2],[1,3]] ]
11-
lines2 = [ [[3,0],[3,2]], [[3,3],[3,4]] ] # Note two lines.
9+
lines0 = [[[0,0],[0,4]]]
10+
lines1 = [[[2,0],[1,2],[1,3]]]
11+
lines2 = [[[3,0],[3,2]], [[3,3],[3,4]]] # Note two lines.
1212

1313
# Filled contours between two levels are also a list/tuple of polygons.
1414
# Points can be ordered clockwise or anticlockwise.
15-
filled01 = [ [[0,0],[0,4],[1,3],[1,2],[2,0]] ]
16-
filled12 = [ [[2,0],[3,0],[3,2],[1,3],[1,2]], # Note two polygons.
17-
[[1,4],[3,4],[3,3]] ]
15+
filled01 = [[[0,0],[0,4],[1,3],[1,2],[2,0]]]
16+
filled12 = [[[2,0],[3,0],[3,2],[1,3],[1,2]], # Note two polygons.
17+
[[1,4],[3,4],[3,3]]]
1818

1919

2020
plt.figure()
@@ -38,8 +38,8 @@
3838
# Here a code type of 1 is a MOVETO, and 2 is a LINETO.
3939

4040
plt.figure()
41-
filled01 = [ [[0,0],[3,0],[3,3],[0,3],[1,1],[1,2],[2,2],[2,1]] ]
42-
kinds01 = [ [1,2,2,2,1,2,2,2] ]
41+
filled01 = [[[0,0],[3,0],[3,3],[0,3],[1,1],[1,2],[2,2],[2,1]]]
42+
kinds01 = [[1,2,2,2,1,2,2,2]]
4343
cs = ContourSet(plt.gca(), [0,1], [filled01], [kinds01], filled=True)
4444
cbar = plt.colorbar(cs)
4545

examples/misc/font_indexing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
coded[name] = ccode
3131
glyphd[name] = glyphind
3232

33-
code = coded['A']
33+
code = coded['A']
3434
glyph = font.load_char(code)
3535
#print glyph.bbox
3636
print(glyphd['A'], glyphd['V'], coded['A'], coded['V'])

examples/misc/rc_traits.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
doprint = True
1414
flexible_true_trait = traits.Trait(
1515
True,
16-
{ 'true': True, 't': True, 'yes': True, 'y': True, 'on': True, True: True,
16+
{'true': True, 't': True, 'yes': True, 'y': True, 'on': True, True: True,
1717
'false': False, 'f': False, 'no': False, 'n': False, 'off': False, False: False
18-
} )
19-
flexible_false_trait = traits.Trait( False, flexible_true_trait )
18+
})
19+
flexible_false_trait = traits.Trait(False, flexible_true_trait)
2020

2121
colors = {
2222
'c' : '#00bfbf',
@@ -83,7 +83,7 @@ def hex_to_rgba(ob, name, val):
8383

8484
def colorname_to_rgba(ob, name, val):
8585
hex = colors[val.lower()]
86-
r,g,b = hex2color(hex)
86+
r,g,b = hex2color(hex)
8787
return RGBA(r,g,b,1.0)
8888
colorname_to_rgba.info = 'a named color'
8989

@@ -102,7 +102,7 @@ def file_exists(ob, name, val):
102102
fh = file(val, 'r')
103103
return val
104104

105-
linestyles = ('-', '--', '-.', ':', 'steps', 'None')
105+
linestyles = ('-', '--', '-.', ':', 'steps', 'None')
106106
TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN = range(4)
107107
linemarkers = (None, '.', ',', 'o', '^', 'v', '<', '>', 's',
108108
'+', 'x', 'd', 'D', '|', '_', 'h', 'H',
@@ -116,23 +116,23 @@ def file_exists(ob, name, val):
116116

117117

118118
class LineRC(traits.HasTraits):
119-
linewidth = traits.Float(0.5)
120-
linestyle = traits.Trait(*linestyles)
121-
color = Color
122-
marker = traits.Trait(*linemarkers)
119+
linewidth = traits.Float(0.5)
120+
linestyle = traits.Trait(*linestyles)
121+
color = Color
122+
marker = traits.Trait(*linemarkers)
123123
markerfacecolor = Color
124124
markeredgecolor = Color
125125
markeredgewidth = traits.Float(0.5)
126-
markersize = traits.Float(6)
127-
antialiased = flexible_true_trait
128-
data_clipping = flexible_false_trait
126+
markersize = traits.Float(6)
127+
antialiased = flexible_true_trait
128+
data_clipping = flexible_false_trait
129129

130130

131131
class PatchRC(traits.HasTraits):
132-
linewidth = traits.Float(1.0)
132+
linewidth = traits.Float(1.0)
133133
facecolor = Color
134134
edgecolor = Color
135-
antialiased = flexible_true_trait
135+
antialiased = flexible_true_trait
136136

137137
timezones = 'UTC', 'US/Central', 'ES/Eastern' # fixme: and many more
138138
backends = ('GTKAgg', 'Cairo', 'GDK', 'GTK', 'Agg',
@@ -142,11 +142,11 @@ class PatchRC(traits.HasTraits):
142142

143143
class RC(traits.HasTraits):
144144
backend = traits.Trait(*backends)
145-
interactive = flexible_false_trait
146-
toolbar = traits.Trait('toolbar2', 'classic', None)
147-
timezone = traits.Trait(*timezones)
148-
lines = traits.Trait(LineRC())
149-
patch = traits.Trait(PatchRC())
145+
interactive = flexible_false_trait
146+
toolbar = traits.Trait('toolbar2', 'classic', None)
147+
timezone = traits.Trait(*timezones)
148+
lines = traits.Trait(LineRC())
149+
patch = traits.Trait(PatchRC())
150150

151151
rc = RC()
152152
rc.lines.color = 'r'

examples/pylab_examples/anchored_artists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, width, height, xdescent, ydescent,
9898

9999
# draw a horizontal bar with length of 0.1 in Data coordinate
100100
# (ax.transData) with a label underneath.
101-
asb = AnchoredSizeBar(ax.transData,
101+
asb = AnchoredSizeBar(ax.transData,
102102
0.1,
103103
r"1$^{\prime}$",
104104
loc=8,

examples/pylab_examples/anscombe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from pylab import *
1313

14-
x = array([10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5])
14+
x = array([10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5])
1515
y1 = array([8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68])
1616
y2 = array([9.14, 8.14, 8.74, 8.77, 9.26, 8.10, 6.13, 3.10, 9.13, 7.26, 4.74])
1717
y3 = array([7.46, 6.77, 12.74, 7.11, 7.81, 8.84, 6.08, 5.39, 8.15, 6.42, 5.73])
@@ -23,7 +23,7 @@ def fit(x):
2323
return 3+0.5*x
2424

2525

26-
xfit = array( [amin(x), amax(x) ] )
26+
xfit = array([amin(x), amax(x)])
2727

2828
subplot(221)
2929
plot(x,y1,'ks', xfit, fit(xfit), 'r-', lw=2)

examples/pylab_examples/axes_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
# the main axes is subplot(111) by default
1313
plot(t, s)
14-
axis([0, 1, 1.1*amin(s), 2*amax(s) ])
14+
axis([0, 1, 1.1*amin(s), 2*amax(s)])
1515
xlabel('time (s)')
1616
ylabel('current (nA)')
1717
title('Gaussian colored noise')

examples/pylab_examples/axis_equal_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
an = linspace(0,2*pi,100)
88

99
subplot(221)
10-
plot( 3*cos(an), 3*sin(an) )
10+
plot(3*cos(an), 3*sin(an))
1111
title('not equal, looks like ellipse',fontsize=10)
1212

1313
subplot(222)
14-
plot( 3*cos(an), 3*sin(an) )
14+
plot(3*cos(an), 3*sin(an))
1515
axis('equal')
1616
title('equal, looks like circle',fontsize=10)
1717

1818
subplot(223)
19-
plot( 3*cos(an), 3*sin(an) )
19+
plot(3*cos(an), 3*sin(an))
2020
axis('equal')
2121
axis([-3,3,-3,3])
2222
title('looks like circle, even after changing limits',fontsize=10)
2323

2424
subplot(224)
25-
plot( 3*cos(an), 3*sin(an) )
25+
plot(3*cos(an), 3*sin(an))
2626
axis('equal')
2727
axis([-3,3,-3,3])
2828
plot([0,4],[0,4])

examples/pylab_examples/bar_stacked.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66

77
N = 5
8-
menMeans = (20, 35, 30, 35, 27)
8+
menMeans = (20, 35, 30, 35, 27)
99
womenMeans = (25, 32, 34, 20, 25)
10-
menStd = (2, 3, 4, 1, 2)
11-
womenStd = (3, 5, 2, 3, 3)
10+
menStd = (2, 3, 4, 1, 2)
11+
womenStd = (3, 5, 2, 3, 3)
1212
ind = np.arange(N) # the x locations for the groups
1313
width = 0.35 # the width of the bars: can also be len(x) sequence
1414

@@ -18,8 +18,8 @@
1818

1919
plt.ylabel('Scores')
2020
plt.title('Scores by group and gender')
21-
plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5') )
21+
plt.xticks(ind+width/2., ('G1', 'G2', 'G3', 'G4', 'G5'))
2222
plt.yticks(np.arange(0,81,10))
23-
plt.legend( (p1[0], p2[0]), ('Men', 'Women') )
23+
plt.legend((p1[0], p2[0]), ('Men', 'Women'))
2424

2525
plt.show()

examples/pylab_examples/boxplot_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
center = ones(25) * 40
4242
flier_high = rand(10) * 100 + 100
4343
flier_low = rand(10) * -100
44-
d2 = concatenate( (spread, center, flier_high, flier_low), 0 )
44+
d2 = concatenate((spread, center, flier_high, flier_low), 0)
4545
data.shape = (-1, 1)
4646
d2.shape = (-1, 1)
4747
#data = concatenate( (data, d2), 1 )

examples/pylab_examples/boxplot_demo3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ def fakeBootStrapper(n):
4242

4343
ax.set_xlabel('treatment')
4444
ax.set_ylabel('response')
45-
plt.setp(bp['whiskers'], color='k', linestyle='-' )
45+
plt.setp(bp['whiskers'], color='k', linestyle='-')
4646
plt.setp(bp['fliers'], markersize=3.0)
4747
plt.show()

examples/pylab_examples/broken_axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
# 30 points between 0 0.2] originally made using np.random.rand(30)*.2
9-
pts = np.array([ 0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195,
9+
pts = np.array([0.015, 0.166, 0.133, 0.159, 0.041, 0.024, 0.195,
1010
0.039, 0.161, 0.018, 0.143, 0.056, 0.125, 0.096, 0.094, 0.051,
1111
0.043, 0.021, 0.138, 0.075, 0.109, 0.195, 0.05 , 0.074, 0.079,
1212
0.155, 0.02 , 0.01 , 0.061, 0.008])

examples/pylab_examples/broken_barh.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import matplotlib.pyplot as plt
55

66
fig, ax = plt.subplots()
7-
ax.broken_barh([ (110, 30), (150, 10) ] , (10, 9), facecolors='blue')
8-
ax.broken_barh([ (10, 50), (100, 20), (130, 10)] , (20, 9),
7+
ax.broken_barh([(110, 30), (150, 10)] , (10, 9), facecolors='blue')
8+
ax.broken_barh([(10, 50), (100, 20), (130, 10)] , (20, 9),
99
facecolors=('red', 'yellow', 'green'))
1010
ax.set_ylim(5,35)
1111
ax.set_xlim(0,200)

examples/pylab_examples/contour_label_demo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __repr__(self):
4848
return '%.1f' % self.__float__()
4949

5050
# Recast levels to new class
51-
CS.levels = [nf(val) for val in CS.levels ]
51+
CS.levels = [nf(val) for val in CS.levels]
5252

5353
# Label levels with specially formatted floats
5454
if plt.rcParams["text.usetex"]:
@@ -67,8 +67,8 @@ def __repr__(self):
6767
CS = plt.contour(X, Y, Z)
6868

6969
fmt = {}
70-
strs = [ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh' ]
71-
for l,s in zip( CS.levels, strs ):
70+
strs = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh']
71+
for l,s in zip(CS.levels, strs):
7272
fmt[l] = s
7373

7474
# Label every other level using strings

examples/pylab_examples/coords_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
def millions(x):
99
return '$%1.1fM' % (x*1e-6)
1010

11-
x = rand(20)
12-
y = 1e7*rand(20)
11+
x = rand(20)
12+
y = 1e7*rand(20)
1313

1414
fig, ax = subplots()
1515
ax.fmt_ydata = millions

examples/pylab_examples/cursor_demo.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ def __init__(self, ax):
2121
self.ly = ax.axvline(color='k') # the vert line
2222

2323
# text location in axes coords
24-
self.txt = ax.text( 0.7, 0.9, '', transform=ax.transAxes)
24+
self.txt = ax.text(0.7, 0.9, '', transform=ax.transAxes)
2525

2626
def mouse_move(self, event):
2727
if not event.inaxes: return
2828

2929
x, y = event.xdata, event.ydata
3030
# update the line positions
31-
self.lx.set_ydata(y )
32-
self.ly.set_xdata(x )
31+
self.lx.set_ydata(y)
32+
self.ly.set_xdata(x)
3333

34-
self.txt.set_text( 'x=%1.2f, y=%1.2f'%(x,y) )
34+
self.txt.set_text('x=%1.2f, y=%1.2f'%(x,y))
3535
draw()
3636

3737

@@ -48,7 +48,7 @@ def __init__(self, ax, x, y):
4848
self.x = x
4949
self.y = y
5050
# text location in axes coords
51-
self.txt = ax.text( 0.7, 0.9, '', transform=ax.transAxes)
51+
self.txt = ax.text(0.7, 0.9, '', transform=ax.transAxes)
5252

5353
def mouse_move(self, event):
5454

@@ -60,10 +60,10 @@ def mouse_move(self, event):
6060
x = self.x[indx]
6161
y = self.y[indx]
6262
# update the line positions
63-
self.lx.set_ydata(y )
64-
self.ly.set_xdata(x )
63+
self.lx.set_ydata(y)
64+
self.ly.set_xdata(x)
6565

66-
self.txt.set_text( 'x=%1.2f, y=%1.2f'%(x,y) )
66+
self.txt.set_text('x=%1.2f, y=%1.2f'%(x,y))
6767
print ('x=%1.2f, y=%1.2f'%(x,y))
6868
draw()
6969

examples/pylab_examples/custom_ticker1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import matplotlib.pyplot as plt
1515
import numpy as np
1616

17-
x = np.arange(4)
17+
x = np.arange(4)
1818
money = [1.5e5, 2.5e6, 5.5e6, 2.0e7]
1919

2020

@@ -27,5 +27,5 @@ def millions(x, pos):
2727
fig, ax = plt.subplots()
2828
ax.yaxis.set_major_formatter(formatter)
2929
plt.bar(x, money)
30-
plt.xticks( x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue') )
30+
plt.xticks(x + 0.5, ('Bill', 'Fred', 'Mary', 'Sue'))
3131
plt.show()

0 commit comments

Comments
 (0)