Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[examples] pep8 fix E26* #3668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 22, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[examples] switch to print function everywhere + fix E211
Signed-off-by: Thomas Hisch <t.hisch@gmail.com>
  • Loading branch information
twmr committed Oct 18, 2014
commit 7b35fa0edffcd29e5b1cada884a97766c7522098
2 changes: 1 addition & 1 deletion 2 examples/api/date_index_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import matplotlib.ticker as ticker

datafile = cbook.get_sample_data('aapl.csv', asfileobj=False)
print ('loading %s' % datafile)
print('loading %s' % datafile)
r = mlab.csv2rec(datafile)

r.sort()
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/api/watermark_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import matplotlib.pyplot as plt

datafile = cbook.get_sample_data('logo2.png', asfileobj=False)
print ('loading %s' % datafile)
print('loading %s' % datafile)
im = image.imread(datafile)
im[:, :, -1] = 0.5 # set the alpha channel

Expand Down
4 changes: 2 additions & 2 deletions 4 examples/event_handling/pipong.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ def update(self,pads):
fudge = .001
# probably cleaner with something like...if not self.field.contains(self.x, self.y):
if self.x < 0+fudge:
#print "player A loses"
#print("player A loses")
pads[1].score += 1;
self._reset(pads[0])
return True
if self.x > 7-fudge:
#print "player B loses"
#print("player B loses")
pads[0].score += 1;
self._reset(pads[1])
return True
Expand Down
4 changes: 2 additions & 2 deletions 4 examples/misc/font_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#for ccode, glyphind in dsu:
# try: name = font.get_glyph_name(glyphind)
# except RuntimeError: pass
# else: print '% 4d % 4d %s %s'%(glyphind, ccode, hex(int(ccode)), name)
# else: print('% 4d % 4d %s %s' % (glyphind, ccode, hex(int(ccode)), name))


# make a charname to charcode and glyphind dictionary
Expand All @@ -32,7 +32,7 @@

code = coded['A']
glyph = font.load_char(code)
#print glyph.bbox
#print(glyph.bbox)
print(glyphd['A'], glyphd['V'], coded['A'], coded['V'])
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_DEFAULT))
print('AV', font.get_kerning(glyphd['A'], glyphd['V'], KERNING_UNFITTED))
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/misc/svg_filter_pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@
shadow.set("filter",'url(#dropshadow)')

fn = "svg_filter_pie.svg"
print "Saving '%s'" % fn
print("Saving '%s'" % fn)
ET.ElementTree(tree).write(fn)
2 changes: 1 addition & 1 deletion 2 examples/mplot3d/wire3d_animation_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def generate(X, Y, phi):

plt.pause(.001)

print ('FPS: %f' % (100 / (time.time() - tstart)))
print('FPS: %f' % (100 / (time.time() - tstart)))
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/anscombe.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ def fit(x):
# verify the stats
pairs = (x,y1), (x,y2), (x,y3), (x4,y4)
for x,y in pairs:
print ('mean=%1.2f, std=%1.2f, r=%1.2f'%(mean(y), std(y), corrcoef(x,y)[0][1]))
print('mean=%1.2f, std=%1.2f, r=%1.2f'%(mean(y), std(y), corrcoef(x,y)[0][1]))

show()
6 changes: 3 additions & 3 deletions 6 examples/pylab_examples/coords_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ def on_move(event):

if event.inaxes:
ax = event.inaxes # the axes instance
print ('data coords %f %f' % (event.xdata, event.ydata))
print('data coords %f %f' % (event.xdata, event.ydata))


def on_click(event):
# get the x and y coords, flip y from top to bottom
x, y = event.x, event.y
if event.button==1:
if event.inaxes is not None:
print ('data coords %f %f' % (event.xdata, event.ydata))
print('data coords %f %f' % (event.xdata, event.ydata))

binding_id = connect('motion_notify_event', on_move)
connect('button_press_event', on_click)

if "test_disconnect" in sys.argv:
print ("disconnecting console coordinate printout...")
print("disconnecting console coordinate printout...")
disconnect(binding_id)

show()
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/cursor_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def mouse_move(self, event):
self.ly.set_xdata(x)

self.txt.set_text('x=%1.2f, y=%1.2f'%(x,y))
print ('x=%1.2f, y=%1.2f'%(x,y))
print('x=%1.2f, y=%1.2f'%(x,y))
draw()

t = arange(0.0, 1.0, 0.01)
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/dashpointlabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
for i in range(len(DATA)):
(x,y) = DATA[i]
(dd, dl, r, dr, dp) = dash_style[i]
#print 'dashlen call', dl
#print('dashlen call %d' % dl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay for fixing syntax in comments!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such stuff still has to be done manually :/

t = ax.text(x, y, str((x,y)), withdash=True,
dashdirection=dd,
dashlength=dl,
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/date_demo2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

quotes = quotes_historical_yahoo_ochl('INTC', date1, date2)
if len(quotes) == 0:
print ('Found no quotes')
print('Found no quotes')
raise SystemExit

dates = [q[0] for q in quotes]
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/date_index_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from matplotlib.ticker import Formatter

datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print ('loading %s' % datafile)
print('loading %s' % datafile)
r = csv2rec(datafile)[-40:]


Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/image_nonuniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
x = np.linspace(-4, 4, 9)
x2 = x**3
y = np.linspace(-4, 4, 9)
#print 'Size %d points' % (len(x) * len(y))
#print('Size %d points' % (len(x) * len(y)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of these that are missing the space after the '#'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done on purpose. The guideline that we follow is: put a space between # and normal text but remove a space between # and code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, are the checkers clever enough to tell?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autopep8 tries to detect if the comment contains code by checking if a call to compile(code, '<string>', 'exec') succeeds (see https://github.com/hhatto/autopep8/blob/master/autopep8.py#L2642). As this check is line based this does not work for comments like # for x in a:. If it detects comments with code it does not add a space between # and the first non-whitespace char.

pep8 does not distinguish between comments with code and without.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WeatherGod's comment here #3425 (comment) is the reason why I remove spaces between # and code, even if this does not conform to pep8

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.

z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2)

fig = figure()
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/image_slices_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, ax, X):
self.update()

def onscroll(self, event):
print ("%s %s" % (event.button, event.step))
print("%s %s" % (event.button, event.step))
if event.button=='up':
self.ind = numpy.clip(self.ind+1, 0, self.slices-1)
else:
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/mri_with_eeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

numSamples, numRows = 800,4
eegfile = cbook.get_sample_data('eeg.dat', asfileobj=False)
print ('loading eeg %s' % eegfile)
print('loading eeg %s' % eegfile)
data = np.fromstring(open(eegfile, 'rb').read(), float)
data.shape = numSamples, numRows
t = 10.0 * np.arange(numSamples, dtype=float)/numSamples
Expand Down
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/scatter_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
y = 0.9*pylab.rand(N)
s = 20*pylab.rand(N)
pylab.scatter(x,y,s)
print ('%d symbols in %1.2f s' % (N, time.time()-tstart))
print('%d symbols in %1.2f s' % (N, time.time()-tstart))
12 changes: 6 additions & 6 deletions 12 examples/pylab_examples/set_and_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,20 @@
setp(l2, linewidth=1, color='g') # line2 is thicker and green


print ('Line setters')
print('Line setters')
setp(l1)
print ('Line getters')
print('Line getters')
getp(l1)

print ('Rectangle setters')
print('Rectangle setters')
setp(gca().patch)
print ('Rectangle getters')
print('Rectangle getters')
getp(gca().patch)

t = title('Hi mom')
print ('Text setters')
print('Text setters')
setp(t)
print ('Text getters')
print('Text getters')
getp(t)

show()
6 changes: 3 additions & 3 deletions 6 examples/pylab_examples/simple_plot_fps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
axis([0.0, 1.0 - part, -1.0 + part, 1.0 - part])
wallclock = time.time() - t
user = time.clock() - c
print ("wallclock:", wallclock)
print ("user:", user)
print ("fps:", frames / wallclock)
print("wallclock:", wallclock)
print("user:", user)
print("fps:", frames / wallclock)
2 changes: 1 addition & 1 deletion 2 examples/pylab_examples/stix_fonts_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def doall():
axis([0, 3, -len(tests), 0])
yticks(arange(len(tests)) * -1)
for i, s in enumerate(tests):
#print (i, s.encode("ascii", "backslashreplace"))
#print(i, s.encode("ascii", "backslashreplace"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace on #

text(0.1, -i, s, fontsize=32)

savefig('stix_fonts_example')
Expand Down
4 changes: 2 additions & 2 deletions 4 examples/pylab_examples/tricontour_vs_griddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
plt.ylim(-2, 2)
plt.title('griddata and contour (%d points, %d grid points)' %
(npts, ngridx*ngridy))
print ('griddata and contour seconds: %f' % (time.clock() - start))
print('griddata and contour seconds: %f' % (time.clock() - start))

# tricontour.
start = time.clock()
Expand All @@ -46,6 +46,6 @@
plt.xlim(-2, 2)
plt.ylim(-2, 2)
plt.title('tricontour (%d points)' % npts)
print ('tricontour seconds: %f' % (time.clock() - start))
print('tricontour seconds: %f' % (time.clock() - start))

plt.show()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.