Permalink
Browse files

More miscellaneous print_function updates.

  • Loading branch information...
1 parent 97d7daf commit a32eb4e6f6234f285bae18dcf34d7e55b1d2575c @mdboom mdboom committed Mar 14, 2011
@@ -1,3 +1,4 @@
+from __future__ import print_function
from distutils import cygwinccompiler
try:
@@ -1,3 +1,4 @@
+from __future__ import print_function
from distutils import cygwinccompiler
try:
@@ -1,5 +1,6 @@
"""This script will install matplotlib to a virtual environment to
faciltate testing."""
+from __future__ import print_function
import shutil, os, sys
from subprocess import Popen, PIPE, STDOUT
from optparse import OptionParser
View
@@ -1,4 +1,5 @@
"""This script will test matplotlib in a virtual environment"""
+from __future__ import print_function
import os, glob
from _buildbot_util import check_call
@@ -4,6 +4,7 @@
This is meant to be run from the mplroot directory."""
+from __future__ import print_function
import os, shutil
roots = ['test_matplotlib','test_plots']
@@ -91,8 +92,8 @@ def path_split_all(fname):
continue
if not os.path.exists(expected_fname):
continue
- print fname
- print absdiff_fname
+ print(fname)
+ print(absdiff_fname)
teststr = os.path.splitext(fname)[0]
this_targetdir = os.path.join(target_dir,teststr)
View
@@ -1,5 +1,6 @@
"""Module to help _buildbot_*.py scripts."""
+from __future__ import print_function
import shutil, os, sys
from subprocess import Popen, PIPE, STDOUT
View
@@ -0,0 +1 @@
+from __future__ import print_function
View
@@ -2,6 +2,7 @@
And another broken test...
"""
+from __future__ import print_function
import sys, time, os
from matplotlib.ft2font import FT2Font
from numpy.random import rand
@@ -11,7 +12,7 @@
def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
- print i, ' ', a2[1],
+ print(i, ' ', a2[1], end='')
return int(a2[1].split()[0])
fname = '/usr/local/share/matplotlib/Vera.ttf'
@@ -52,7 +53,7 @@ def report_memory(i):
if i==1: start = val
end = val
-print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N))
+print('Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N)))
# w/o text and w/o write_png: Average memory consumed per loop: 0.02
# w/o text and w/ write_png : Average memory consumed per loop: 0.3400
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
from pylab import *
import sys
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
import unittest
from datetime import datetime
@@ -1,3 +1,4 @@
+from __future__ import print_function
import sys
def parse_results(filename):
@@ -33,9 +34,9 @@ def compare_results(results_a, results_b):
sections = results_a.keys()
sections.sort()
for section in results_a.keys():
- print "backend %s" % section
- print " %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff")
- print " " + '-' * 69
+ print("backend %s" % section)
+ print(" %-40s %6s %6s %6s %6s" % ("test", "a", "b", "delta", "% diff"))
+ print(" " + '-' * 69)
deltas = []
section_a = results_a[section]
section_b = results_b[section]
@@ -54,13 +55,13 @@ def compare_results(results_a, results_b):
for diff, delta, time_a, time_b, test in deltas:
if diff is None:
if time_a is None:
- print " %-40s ??? % 6.3f ??? ???" % (test, time_b)
+ print(" %-40s ??? % 6.3f ??? ???" % (test, time_b))
else:
- print " %-40s % 6.3f ??? ??? ???" % (test, time_a)
+ print(" %-40s % 6.3f ??? ??? ???" % (test, time_a))
else:
- print " %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100)
+ print(" %-40s % 6.3f % 6.3f % 6.3f %6d%%" % (test, time_a, time_b, delta, diff * 100))
+
-
if __name__ == '__main__':
results_a_filename = sys.argv[-2]
results_b_filename = sys.argv[-1]
View
@@ -2,6 +2,7 @@
Check to and form the epoch conversions for the various datetime
converters
"""
+from __future__ import print_function
from matplotlib.dates import MxDatetimeConverter, PyDatetimeConverter,\
EpochConverter
import mx.DateTime
@@ -13,7 +14,7 @@
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
-print 'passed mx tests'
+print('passed mx tests')
import datetime
dt1 = datetime.datetime(2004, 03, 01) # before dst
@@ -22,7 +23,7 @@
dtc = PyDatetimeConverter()
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
-print 'passed datetime tests'
+print('passed datetime tests')
# epoch
dt1 = 12345334
@@ -31,4 +32,4 @@
dtc = EpochConverter()
assert( dtc.from_epoch( dtc.epoch(dt1) ) == dt1 )
assert( dtc.from_epoch( dtc.epoch(dt2) ) == dt2 )
-print 'passed epoch tests'
+print('passed epoch tests')
View
@@ -1,6 +1,7 @@
"""
Compare the ellipse generated with arcs versus a polygonal approximation
"""
+from __future__ import print_function
import numpy as npy
from matplotlib import patches
from pylab import figure, show
View
@@ -4,6 +4,7 @@
# bound ellipses, it demonstrates how significant this error
# is to our plots.
+from __future__ import print_function
import math
from pylab import *
from matplotlib.patches import Ellipse, Arc
View
@@ -1,6 +1,7 @@
"""
This appears to be obsolete as of 2009/02/24; a key import fails.
"""
+from __future__ import print_function
import sys, time, os
from numpy.random import rand
from matplotlib.ft2font import FT2Font
@@ -11,7 +12,7 @@
def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
- print i, ' ', a2[1],
+ print(i, ' ', a2[1], end='')
return int(a2[1].split()[0])
fname = '/usr/local/share/matplotlib/Vera.ttf'
@@ -32,6 +33,6 @@ def report_memory(i):
if i==1: start = val
end = val
-print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N))
+print('Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N)))
# Average memory consumed per loop: 0.09
View
4 unit/inside_poly_memleak.py 100644 → 100755
@@ -1,16 +1,18 @@
#!/usr/bin/env python
+
"""
Another broken test...
"""
+from __future__ import print_function
import os, sys, time
import matplotlib.nxutils as nxutils
from numpy.random import rand
def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
- print i, ' ', a2[1],
+ print(i, ' ', a2[1], end='')
return int(a2[1].split()[1])
@@ -2,6 +2,7 @@
Broken.
"""
+from __future__ import print_function
import os, sys, time
import matplotlib.nxutils as nxutils
@@ -24,7 +25,7 @@
points = rand(numpoints,2)
mask = nxutils.points_inside_poly(points, verts)
tnew = time.time() - t0
- print numverts, numpoints, told, tnew, told/tnew
+ print(numverts, numpoints, told, tnew, told/tnew)
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
from pylab import figure, show, nx
Ntests = 3
View
@@ -1,6 +1,8 @@
#!/usr/bin/env python
# try plotting very large numbers
+from __future__ import print_function
+
from pylab import *
x = arange(1000) + 2**32
View
40 unit/memleak_gui.py 100644 → 100755
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+
'''
This illustrates a leak that occurs with any interactive backend.
Run with :
@@ -13,6 +14,7 @@
You may need to edit cbook.report_memory to support your platform
'''
+from __future__ import print_function
import os, sys, time
import gc
from optparse import OptionParser
@@ -48,8 +50,8 @@
import pylab
import matplotlib.cbook as cbook
-print '# columns are: iteration, OS memory (k), number of python objects'
-print '#'
+print('# columns are: iteration, OS memory (k), number of python objects')
+print('#')
for i in range(indEnd+1):
fig = pylab.figure()
@@ -68,40 +70,40 @@
gc.collect()
end = val
-print '# columns above are: iteration, OS memory (k), number of python objects'
-print '#'
-print '# uncollectable list:', gc.garbage
-print '#'
+print('# columns above are: iteration, OS memory (k), number of python objects')
+print('#')
+print('# uncollectable list:', gc.garbage)
+print('#')
if i > indStart:
- print '# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams
+ print('# Backend %(backend)s, toolbar %(toolbar)s' % matplotlib.rcParams)
backend = options.backend.lower()
if backend.startswith("gtk"):
import gtk
import gobject
- print "# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \
- (gtk.pygtk_version, gtk.gtk_version,
- gobject.pygobject_version, gobject.glib_version)
+ print("# pygtk version: %s, gtk version: %s, pygobject version: %s, glib version: %s" % \
+ (gtk.pygtk_version, gtk.gtk_version,
+ gobject.pygobject_version, gobject.glib_version))
elif backend.startswith("qt4"):
import PyQt4.pyqtconfig
- print "# PyQt4 version: %s, Qt version %x" % \
+ print("# PyQt4 version: %s, Qt version %x" % \
(PyQt4.pyqtconfig.Configuration().pyqt_version_str,
- PyQt4.pyqtconfig.Configuration().qt_version)
+ PyQt4.pyqtconfig.Configuration().qt_version))
elif backend.startswith("qt"):
import pyqtconfig
- print "# pyqt version: %s, qt version: %x" % \
+ print("# pyqt version: %s, qt version: %x" % \
(pyqtconfig.Configuration().pyqt_version_str,
- pyqtconfig.Configuration().qt_version)
+ pyqtconfig.Configuration().qt_version))
elif backend.startswith("wx"):
import wx
- print "# wxPython version: %s" % wx.__version__
+ print("# wxPython version: %s" % wx.__version__)
elif backend.startswith("tk"):
import Tkinter
- print "# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion)
+ print("# Tkinter version: %s, Tk version: %s, Tcl version: %s" % (Tkinter.__version__, Tkinter.TkVersion, Tkinter.TclVersion))
- print '# Averaging over loops %d to %d' % (indStart, indEnd)
- print '# Memory went from %dk to %dk' % (start, end)
- print '# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
+ print('# Averaging over loops %d to %d' % (indStart, indEnd))
+ print('# Memory went from %dk to %dk' % (start, end))
+ print('# Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)))
if options.cycles:
cbook.print_cycles(gc.garbage)
View
6 unit/memleak_hawaii3.py 100644 → 100755
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import os, sys, time, gc
import matplotlib
matplotlib.use('PDF')
@@ -43,9 +45,9 @@
gc.collect()
val = report_memory(i)
- print i, val
+ print(i, val)
if i==indStart: start = val # wait a few cycles for memory usage to stabilize
end = val
-print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
+print('Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)))
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
import os,matplotlib
matplotlib.use('Agg')
from matplotlib.figure import Figure
@@ -7,7 +8,7 @@ def plot():
fig = Figure()
i = 0
while True:
- print i,report_memory(i)
+ print(i, report_memory(i))
fig.clf()
ax = fig.add_axes([0.1,0.1,0.7,0.7])
ax.plot([1,2,3])
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
import datetime, StringIO, unittest
import matplotlib.mlab as mlab
import numpy
@@ -40,19 +41,19 @@ def test_csv2rec_roundtrip(self):
mlab.rec2csv( ra, fh )
fh.seek(0)
if 0:
- print 'CSV contents:','-'*40
- print fh.read()
- print '-'*40
+ print('CSV contents:','-'*40)
+ print(fh.read())
+ print('-'*40)
fh.seek(0)
ra2 = mlab.csv2rec(fh)
fh.close()
#print 'ra', ra
#print 'ra2', ra2
for name in ra.dtype.names:
if 0:
- print name, repr(ra[name]), repr(ra2[name])
+ print(name, repr(ra[name]), repr(ra2[name]))
dt = ra.dtype[name]
- print 'repr(dt.type)',repr(dt.type)
+ print('repr(dt.type)',repr(dt.type))
self.failUnless( numpy.all(ra[name] == ra2[name]) ) # should not fail with numpy 1.0.5
def test_csv2rec_masks(self):
View
@@ -1,3 +1,4 @@
+from __future__ import print_function
import numpy as np
import nose, nose.tools as nt
Oops, something went wrong.

0 comments on commit a32eb4e

Please sign in to comment.