Skip to content

Commit a32eb4e

Browse files
committed
More miscellaneous print_function updates.
1 parent 97d7daf commit a32eb4e

33 files changed

+116
-74
lines changed

release/win32/data/setupwin.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from distutils import cygwinccompiler
23

34
try:

release/win32/data/setupwinegg.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from distutils import cygwinccompiler
23

34
try:

test/_buildbot_install.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""This script will install matplotlib to a virtual environment to
22
faciltate testing."""
3+
from __future__ import print_function
34
import shutil, os, sys
45
from subprocess import Popen, PIPE, STDOUT
56
from optparse import OptionParser

test/_buildbot_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This script will test matplotlib in a virtual environment"""
2+
from __future__ import print_function
23
import os, glob
34

45
from _buildbot_util import check_call

test/_buildbot_test_postmortem.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
This is meant to be run from the mplroot directory."""
66

7+
from __future__ import print_function
78
import os, shutil
89

910
roots = ['test_matplotlib','test_plots']
@@ -91,8 +92,8 @@ def path_split_all(fname):
9192
continue
9293
if not os.path.exists(expected_fname):
9394
continue
94-
print fname
95-
print absdiff_fname
95+
print(fname)
96+
print(absdiff_fname)
9697

9798
teststr = os.path.splitext(fname)[0]
9899
this_targetdir = os.path.join(target_dir,teststr)

test/_buildbot_util.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Module to help _buildbot_*.py scripts."""
22

3+
from __future__ import print_function
34
import shutil, os, sys
45
from subprocess import Popen, PIPE, STDOUT
56

unit/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from __future__ import print_function

unit/agg_memleak.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
And another broken test...
33
"""
44

5+
from __future__ import print_function
56
import sys, time, os
67
from matplotlib.ft2font import FT2Font
78
from numpy.random import rand
@@ -11,7 +12,7 @@
1112
def report_memory(i):
1213
pid = os.getpid()
1314
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
14-
print i, ' ', a2[1],
15+
print(i, ' ', a2[1], end='')
1516
return int(a2[1].split()[0])
1617

1718
fname = '/usr/local/share/matplotlib/Vera.ttf'
@@ -52,7 +53,7 @@ def report_memory(i):
5253
if i==1: start = val
5354

5455
end = val
55-
print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N))
56+
print('Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N)))
5657

5758
# w/o text and w/o write_png: Average memory consumed per loop: 0.02
5859
# w/o text and w/ write_png : Average memory consumed per loop: 0.3400

unit/auto_legend.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from pylab import *
23
import sys
34

unit/cbook_unit.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import unittest
23
from datetime import datetime
34

unit/compare_backend_driver_results.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import sys
23

34
def parse_results(filename):
@@ -33,9 +34,9 @@ def compare_results(results_a, results_b):
3334
sections = results_a.keys()
3435
sections.sort()
3536
for section in results_a.keys():
36-
print "backend %s" % section
37-
print " %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff")
38-
print " " + '-' * 69
37+
print("backend %s" % section)
38+
print(" %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff"))
39+
print(" " + '-' * 69)
3940
deltas = []
4041
section_a = results_a[section]
4142
section_b = results_b[section]
@@ -54,13 +55,13 @@ def compare_results(results_a, results_b):
5455
for diff, delta, time_a, time_b, test in deltas:
5556
if diff is None:
5657
if time_a is None:
57-
print " %-40s ??? % 6.3f ??? ???" % (test, time_b)
58+
print(" %-40s ??? % 6.3f ??? ???" % (test, time_b))
5859
else:
59-
print " %-40s % 6.3f ??? ??? ???" % (test, time_a)
60+
print(" %-40s % 6.3f ??? ??? ???" % (test, time_a))
6061
else:
61-
print " %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100)
62+
print(" %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100))
63+
6264

63-
6465
if __name__ == '__main__':
6566
results_a_filename = sys.argv[-2]
6667
results_b_filename = sys.argv[-1]

unit/dates_unit.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Check to and form the epoch conversions for the various datetime
33
converters
44
"""
5+
from __future__ import print_function
56
from matplotlib.dates import MxDatetimeConverter, PyDatetimeConverter,\
67
EpochConverter
78
import mx.DateTime
@@ -13,7 +14,7 @@
1314

1415
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
1516
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
16-
print 'passed mx tests'
17+
print('passed mx tests')
1718

1819
import datetime
1920
dt1 = datetime.datetime(2004, 03, 01) # before dst
@@ -22,7 +23,7 @@
2223
dtc = PyDatetimeConverter()
2324
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
2425
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
25-
print 'passed datetime tests'
26+
print('passed datetime tests')
2627

2728
# epoch
2829
dt1 = 12345334
@@ -31,4 +32,4 @@
3132
dtc = EpochConverter()
3233
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
3334
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
34-
print 'passed epoch tests'
35+
print('passed epoch tests')

unit/ellipse_compare.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Compare the ellipse generated with arcs versus a polygonal approximation
33
"""
4+
from __future__ import print_function
45
import numpy as npy
56
from matplotlib import patches
67
from pylab import figure, show

unit/ellipse_large.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# bound ellipses, it demonstrates how significant this error
55
# is to our plots.
66

7+
from __future__ import print_function
78
import math
89
from pylab import *
910
from matplotlib.patches import Ellipse, Arc

unit/ft2font_memleak.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
This appears to be obsolete as of 2009/02/24; a key import fails.
33
"""
4+
from __future__ import print_function
45
import sys, time, os
56
from numpy.random import rand
67
from matplotlib.ft2font import FT2Font
@@ -11,7 +12,7 @@
1112
def report_memory(i):
1213
pid = os.getpid()
1314
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
14-
print i, ' ', a2[1],
15+
print(i, ' ', a2[1], end='')
1516
return int(a2[1].split()[0])
1617

1718
fname = '/usr/local/share/matplotlib/Vera.ttf'
@@ -32,6 +33,6 @@ def report_memory(i):
3233
if i==1: start = val
3334

3435
end = val
35-
print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N))
36+
print('Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N)))
3637

3738
# Average memory consumed per loop: 0.09

unit/inside_poly_memleak.py

100644100755
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/usr/bin/env python
2+
23
"""
34
Another broken test...
45
"""
56

7+
from __future__ import print_function
68
import os, sys, time
79
import matplotlib.nxutils as nxutils
810
from numpy.random import rand
911

1012
def report_memory(i):
1113
pid = os.getpid()
1214
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
13-
print i, ' ', a2[1],
15+
print(i, ' ', a2[1], end='')
1416
return int(a2[1].split()[1])
1517

1618

unit/inside_poly_profile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Broken.
33
"""
44

5+
from __future__ import print_function
56
import os, sys, time
67

78
import matplotlib.nxutils as nxutils
@@ -24,7 +25,7 @@
2425
points = rand(numpoints,2)
2526
mask = nxutils.points_inside_poly(points, verts)
2627
tnew = time.time() - t0
27-
print numverts, numpoints, told, tnew, told/tnew
28+
print(numverts, numpoints, told, tnew, told/tnew)
2829

2930

3031

unit/legend_unit.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from pylab import figure, show, nx
23

34
Ntests = 3

unit/longs_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
# try plotting very large numbers
33

4+
from __future__ import print_function
5+
46
from pylab import *
57
x = arange(1000) + 2**32
68

unit/memleak_gui.py

100644100755
+21-19
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
23
'''
34
This illustrates a leak that occurs with any interactive backend.
45
Run with :
@@ -13,6 +14,7 @@
1314
You may need to edit cbook.report_memory to support your platform
1415
1516
'''
17+
from __future__ import print_function
1618
import os, sys, time
1719
import gc
1820
from optparse import OptionParser
@@ -48,8 +50,8 @@
4850
import pylab
4951
import matplotlib.cbook as cbook
5052

51-
print '# columns are: iteration, OS memory (k), number of python objects'
52-
print '#'
53+
print('# columns are: iteration, OS memory (k), number of python objects')
54+
print('#')
5355
for i in range(indEnd+1):
5456

5557
fig = pylab.figure()
@@ -68,40 +70,40 @@
6870
gc.collect()
6971
end = val
7072

71-
print '# columns above are: iteration, OS memory (k), number of python objects'
72-
print '#'
73-
print '# uncollectable list:', gc.garbage
74-
print '#'
73+
print('# columns above are: iteration, OS memory (k), number of python objects')
74+
print('#')
75+
print('# uncollectable list:', gc.garbage)
76+
print('#')
7577

7678
if i > indStart:
77-
print '# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams
79+
print('# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams)
7880
backend = options.backend.lower()
7981
if backend.startswith("gtk"):
8082
import gtk
8183
import gobject
82-
print "# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \
83-
(gtk.pygtk_version, gtk.gtk_version,
84-
gobject.pygobject_version, gobject.glib_version)
84+
print("# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \
85+
(gtk.pygtk_version, gtk.gtk_version,
86+
gobject.pygobject_version, gobject.glib_version))
8587
elif backend.startswith("qt4"):
8688
import PyQt4.pyqtconfig
87-
print "# PyQt4 version: %s, Qt version %x" % \
89+
print("# PyQt4 version: %s, Qt version %x" % \
8890
(PyQt4.pyqtconfig.Configuration().pyqt_version_str,
89-
PyQt4.pyqtconfig.Configuration().qt_version)
91+
PyQt4.pyqtconfig.Configuration().qt_version))
9092
elif backend.startswith("qt"):
9193
import pyqtconfig
92-
print "# pyqt version: %s, qt version: %x" % \
94+
print("# pyqt version: %s, qt version: %x" % \
9395
(pyqtconfig.Configuration().pyqt_version_str,
94-
pyqtconfig.Configuration().qt_version)
96+
pyqtconfig.Configuration().qt_version))
9597
elif backend.startswith("wx"):
9698
import wx
97-
print "# wxPython version: %s" % wx.__version__
99+
print("# wxPython version: %s" % wx.__version__)
98100
elif backend.startswith("tk"):
99101
import Tkinter
100-
print "# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion)
102+
print("# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion))
101103

102-
print '# Averaging over loops %d to %d' % (indStart, indEnd)
103-
print '# Memory went from %dk to %dk' % (start, end)
104-
print '# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
104+
print('# Averaging over loops %d to %d' % (indStart, indEnd))
105+
print('# Memory went from %dk to %dk' % (start, end))
106+
print('# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)))
105107

106108
if options.cycles:
107109
cbook.print_cycles(gc.garbage)

unit/memleak_hawaii3.py

100644100755
+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
4+
35
import os, sys, time, gc
46
import matplotlib
57
matplotlib.use('PDF')
@@ -43,9 +45,9 @@
4345

4446
gc.collect()
4547
val = report_memory(i)
46-
print i, val
48+
print(i, val)
4749
if i==indStart: start = val # wait a few cycles for memory usage to stabilize
4850

4951
end = val
50-
print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
52+
print('Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)))
5153

unit/memleak_nongui.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os,matplotlib
23
matplotlib.use('Agg')
34
from matplotlib.figure import Figure
@@ -7,7 +8,7 @@ def plot():
78
fig = Figure()
89
i = 0
910
while True:
10-
print i,report_memory(i)
11+
print(i, report_memory(i))
1112
fig.clf()
1213
ax = fig.add_axes([0.1,0.1,0.7,0.7])
1314
ax.plot([1,2,3])

unit/mlab_unit.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import datetime, StringIO, unittest
23
import matplotlib.mlab as mlab
34
import numpy
@@ -40,19 +41,19 @@ def test_csv2rec_roundtrip(self):
4041
mlab.rec2csv( ra, fh )
4142
fh.seek(0)
4243
if 0:
43-
print 'CSV contents:','-'*40
44-
print fh.read()
45-
print '-'*40
44+
print('CSV contents:','-'*40)
45+
print(fh.read())
46+
print('-'*40)
4647
fh.seek(0)
4748
ra2 = mlab.csv2rec(fh)
4849
fh.close()
4950
#print 'ra', ra
5051
#print 'ra2', ra2
5152
for name in ra.dtype.names:
5253
if 0:
53-
print name, repr(ra[name]), repr(ra2[name])
54+
print(name, repr(ra[name]), repr(ra2[name]))
5455
dt = ra.dtype[name]
55-
print 'repr(dt.type)',repr(dt.type)
56+
print('repr(dt.type)',repr(dt.type))
5657
self.failUnless( numpy.all(ra[name] == ra2[name]) ) # should not fail with numpy 1.0.5
5758

5859
def test_csv2rec_masks(self):

unit/nose_tests.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import numpy as np
23

34
import nose, nose.tools as nt

0 commit comments

Comments
 (0)