8000 pep8 fix e2* in examples dir part 1/2 · matplotlib/matplotlib@cc7fc7f · GitHub
[go: up one dir, main page]

Skip to content

Commit cc7fc7f

Browse files
committed
pep8 fix e2* in examples dir part 1/2
1 parent 2f5b1e1 commit cc7fc7f

Some content is hidden

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

69 files changed

+184
-183
lines changed

examples/animation/double_pendulum_animated.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ def derivs(state, t):
1919
dydx = np.zeros_like(state)
2020
dydx[0] = state[1]
2121

22-
del_ = state[2]-state[0]
23-
den1 = (M1+M2)*L1 - M2*L1*cos(del_)*cos(del_)
22+
del_ = state[2] - state[0]
23+
den1 = (M1 + M2)*L1 - M2*L1*cos(del_)*cos(del_)
2424
dydx[1] = (M2*L1*state[1]*state[1]*sin(del_)*cos(del_)
2525
+ M2*G*sin(state[2])*cos(del_)
2626
+ M2*L2*state[3]*state[3]*sin(del_)
27-
- (M1+M2)*G*sin(state[0]))/den1
27+
- (M1 + M2)*G*sin(state[0]))/den1
2828

2929
dydx[2] = state[3]
3030

3131
den2 = (L2/L1)*den1
3232
dydx[3] = (-M2*L2*state[3]*state[3]*sin(del_)*cos(del_)
33-
+ (M1+M2)*G*sin(state[0])*cos(del_)
34-
- (M1+M2)*L1*state[1]*state[1]*sin(del_)
35-
- (M1+M2)*G*sin(state[2]))/den2
33+
+ (M1 + M2)*G*sin(state[0])*cos(del_)
34+
- (M1 + M2)*L1*state[1]*state[1]*sin(del_)
35+
- (M1 + M2)*G*sin(state[2]))/den2
3636

3737
return dydx
3838

examples/animation/simple_3danim.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def Gen_RandLine(length, dims=2):
2222
# subtraction by 0.5 is to change the range to [-0.5, 0.5]
2323
# to allow a line to move backwards.
2424
step = ((np.random.rand(dims) - 0.5) * 0.1)
25-
lineData[:, index] = lineData[:, index-1] + step
25+
lineData[:, index] = lineData[:, index - 1] + step
2626

2727
return lineData
2828

examples/axes_grid/demo_floating_axes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ def setup_axes3(fig, rect):
130130

131131
ax2, aux_ax2 = setup_axes2(fig, 132)
132132
theta = np.random.rand(10)*.5*np.pi
133-
radius = np.random.rand(10)+1.
133+
radius = np.random.rand(10) + 1.
134134
aux_ax2.scatter(theta, radius)
135135

136136
ax3, aux_ax3 = setup_axes3(fig, 133)
137137

138-
theta = (8 + np.random.rand(10)*(14-8))*15. # in degrees
138+
theta = (8 + np.random.rand(10)*(14 - 8))*15. # in degrees
139139
radius = np.random.rand(10)*14000.
140140
aux_ax3.scatter(theta, radius)
141141

examples/event_handling/data_browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def onpress(self, event):
2323
else: inc = -1
2424

2525
self.lastind += inc
26-
self.lastind = np.clip(self.lastind, 0, len(xs)-1)
26+
self.lastind = np.clip(self.lastind, 0, len(xs) - 1)
2727
self.update()
2828

2929
def onpick(self, event):
@@ -37,7 +37,7 @@ def onpick(self, event):
3737
x = event.mouseevent.xdata
3838
y = event.mouseevent.ydata
3939

40-
distances = np.hypot(x-xs[event.ind], y-ys[event.ind])
40+
distances = np.hypot(x - xs[event.ind], y - ys[event.ind])
4141
indmin = distances.argmin()
4242
dataind = event.ind[indmin]
4343

examples/event_handling/idle_and_timeout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
def on_idle(event):
2222
on_idle.count += 1
2323
print('idle', on_idle.count)
24-
line1.set_ydata(np.sin(2*np.pi*t*(N-on_idle.count)/float(N)))
24+
line1.set_ydata(np.sin(2*np.pi*t*(N - on_idle.count)/float(N)))
2525
event.canvas.draw()
2626
# test boolean return removal
2727
if on_idle.count == N:

examples/event_handling/path_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def get_ind_under_point(self, event):
8080
xy = np.asarray(self.pathpatch.get_path().vertices)
8181
xyt = self.pathpatch.get_transform().transform(xy)
8282
xt, yt = xyt[:, 0], xyt[:, 1]
83-
d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2)
83+
d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2)
8484
ind = d.argmin()
8585

8686
if d[ind] >= self.epsilon:

examples/event_handling/pick_event_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def line_picker(line, mouseevent):
120120
xdata = line.get_xdata()
121121
ydata = line.get_ydata()
122122
maxd = 0.05
123-
d = np.sqrt((xdata-mouseevent.xdata)**2. + (ydata-mouseevent.ydata)**2.)
123+
d = np.sqrt((xdata - mouseevent.xdata)**2. + (ydata - mouseevent.ydata)**2.)
124124

125125
ind = np.nonzero(np.less_equal(d, maxd))
126126
if len(ind):

examples/event_handling/pick_event_demo2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def onpick(event):
2525

2626
figi = plt.figure()
2727
for subplotnum, dataind in enumerate(event.ind):
28-
ax = figi.add_subplot(N, 1, subplotnum+1)
28+
ax = figi.add_subplot(N, 1, subplotnum + 1)
2929
ax.plot(X[dataind])
3030
ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]),
3131
transform=ax.transAxes, va='top')

examples/event_handling/pipong.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ def update(self, pads):
8080
self.vy *= 1.2 * pad.signy
8181
fudge = .001
8282
# probably cleaner with something like...if not self.field.contains(self.x, self.y):
83-
if self.x < 0+fudge:
83+
if self.x < 0 + fudge:
8484
#print("player A loses")
8585
pads[1].score += 1;
8686
self._reset(pads[0])
8787
return True
88-
if self.x > 7-fudge:
88+
if self.x > 7 - fudge:
8989
#print("player B loses")
9090
pads[0].score += 1;
9191
self._reset(pads[1])
9292
return True
93-
if self.y < -1+fudge or self.y > 1-fudge:
93+
if self.y < -1 + fudge or self.y > 1 - fudge:
9494
self.vy *= -1.0
9595
# add some randomness, just to make it interesting
9696
self.vy -= (randn()/300.0 + 1/300.0) * np.sign(self.vy)
@@ -166,10 +166,10 @@ def draw(self, evt):
166166

167167
# show the distractors
168168
if self.distract:
169-
self.line.set_ydata(np.sin(self.x+self.cnt/self.res))
170-
self.line2.set_ydata(np.cos(self.x-self.cnt/self.res))
171-
self.line3.set_ydata(np.tan(self.x+self.cnt/self.res))
172-
self.line4.set_ydata(np.tan(self.x-self.cnt/self.res))
169+
self.line.set_ydata(np.sin(self.x + self.cnt/self.res))
170+
self.line2.set_ydata(np.cos(self.x - self.cnt/self.res))
171+
self.line3.set_ydata(np.tan(self.x + self.cnt/self.res))
172+
self.line4.set_ydata(np.tan(self.x - self.cnt/self.res))
173173
draw_artist(self.line)
174174
draw_artist(self.line2)
175175
draw_artist(self.line3)
@@ -224,7 +224,7 @@ def key_press(self, event):
224224
if event.key == 'e':
225225
self.pads[0].y += .1
226226
if self.pads[0].y > 1 - .3:
227-
self.pads[0].y = 1-.3
227+
self.pads[0].y = 1 - .3
228228
if event.key == 'd':
229229
self.pads[0].y -= .1
230230
if self.pads[0].y < -1:
@@ -233,7 +233,7 @@ def key_press(self, event):
233233
if event.key == 'i':
234234
self.pads[1].y += .1
235235
if self.pads[1].y > 1 - .3:
236-
self.pads[1].y = 1-.3
236+
self.pads[1].y = 1 - .3
237237
if event.key == 'k':
238238
self.pads[1].y -= .1
239239
if self.pads[1].y < -1:

examples/event_handling/poly_editor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def get_ind_under_point(self, event):
7070
xy = np.asarray(self.poly.xy)
7171
xyt = self.poly.get_transform().transform(xy)
7272
xt, yt = xyt[:, 0], xyt[:, 1]
73-
d = np.sqrt((xt-event.x)**2 + (yt-event.y)**2)
73+
d = np.sqrt((xt - event.x)**2 + (yt - event.y)**2)
7474
indseq = np.nonzero(np.equal(d, np.amin(d)))[0]
7575
ind = indseq[0]
7676

@@ -107,9 +107,9 @@ def key_press_callback(self, event):
107107
elif event.key == 'i':
108108
xys = self.poly.get_transform().transform(self.poly.xy)
109109
p = event.x, event.y # display coords
110-
for i in range(len(xys)-1):
110+
for i in range(len(xys) - 1):
111111
s0 = xys[i]
112-
s1 = xys[i+1]
112+
s1 = xys[i + 1]
113113
d = dist_point_to_segment(p, s0, s1)
114114
if d <= self.epsilon:
115115
self.poly.xy = np.array(

0 commit comments

Comments
 (0)
0