Permalink
Browse files

2to3: Apply `print` fixer.

Add `print_function` to all `from __future__ import ...` statements
and use the python3 print function syntax everywhere.

Closes #3078.
  • Loading branch information...
1 parent 7441fa5 commit bb726ca19f434f5055c0efceefe48d89469fcbbe @charris committed Apr 6, 2013
Showing 422 changed files with 888 additions and 894 deletions.
View
@@ -6,7 +6,7 @@
Also, add Doxygen /** and /**< syntax automatically where appropriate.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys
import re
View
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
from numpyx import test
test()
View
@@ -5,7 +5,7 @@
http://cython.org.
"""
-from __future__ import division
+from __future__ import division, print_function
from distutils.core import setup
from distutils.extension import Extension
View
@@ -8,7 +8,7 @@
a line by itself, preferably preceeded by a blank line.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import os # standard library imports first
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import floatint.floatint as ff
import numpy as np
@@ -12,7 +12,7 @@
# Now, the elements will be the scalar type associated
# with the ndarray.
-print g[0]
-print type(g[1])
+print(g[0])
+print(type(g[1]))
# Now, you need to register ufuncs and more arrfuncs to do useful things...
@@ -1,3 +1,3 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
@@ -1,4 +1,4 @@
-from __future__ import division
+from __future__ import division, print_function
from numpy.distutils.core import setup
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
__all__ = ['filter2d']
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
__all__ = ['add', 'filter2d']
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from __future__ import division
+from __future__ import division, print_function
from distutils.core import setup
from distutils.extension import Extension
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import timeit
@@ -54,9 +54,9 @@
for kind in ['f2py']:#['ctypes', 'pyrex', 'weave', 'f2py']:
res[kind] = []
sys.path = ['/Users/oliphant/numpybook/%s' % (kind,)] + path
- print sys.path
+ print(sys.path)
for n in N:
- print "%s - %d" % (kind, n)
+ print("%s - %d" % (kind, n))
t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n)))
mytime = min(t.repeat(3,100))
res[kind].append(mytime)
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
from scipy import weave, zeros_like
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
from scipy import weave
from numpy import rand, zeros_like
@@ -40,8 +40,8 @@ def arr(a):
return b
a = [None]*10
-print example1(a)
-print a
+print(example1(a))
+print(a)
a = rand(512,512)
b = arr(a)
View
@@ -14,7 +14,7 @@
-n name of code section (default MyCode)
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys
import optparse
@@ -25,8 +25,8 @@
newre = re.compile(r"\\begin_inset Note.*PYNEW\s+\\end_inset", re.DOTALL)
def getoutput(tstr, dic):
- print "\n\nRunning..."
- print tstr,
+ print("\n\nRunning...")
+ print(tstr, end=' ')
tempstr = io.StringIO()
sys.stdout = tempstr
code = compile(tstr, '<input>', 'exec')
@@ -44,8 +44,8 @@ def getoutput(tstr, dic):
else:
res = tempstr.getvalue() + '\n' + repr(res)
if res != '':
- print "\nOutput is"
- print res,
+ print("\nOutput is")
+ print(res, end=' ')
return res
# now find the code in the code segment
@@ -90,7 +90,7 @@ def runpycode(lyxstr, name='MyCode'):
num += 1
if num == 0:
- print "Nothing found for %s" % name
+ print("Nothing found for %s" % name)
return lyxstr
start = 0
@@ -141,7 +141,7 @@ def main(args):
fid = file(args[0])
str = fid.read()
fid.close()
- print "Processing %s" % options.name
+ print("Processing %s" % options.name)
newstr = runpycode(str, options.name)
fid = file(args[0],'w')
fid.write(newstr)
View
@@ -6,7 +6,7 @@
MODE is either 'html' or 'tex'.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import re, optparse
View
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
from numpyx import test
test()
View
@@ -12,7 +12,7 @@
http://www.scipy.org/Cookbook/ArrayStruct_and_Pyrex
"""
-from __future__ import division
+from __future__ import division, print_function
from distutils.core import setup
from distutils.extension import Extension
View
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys, os, re
@@ -1,3 +1,3 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
from .numpydoc import setup
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys
if sys.version_info[0] >= 3:
@@ -10,7 +10,7 @@
fixme: We may want to move to using _ast trees because the compiler for
them is about 6 times faster than compiler.compile.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add
@@ -1,20 +1,15 @@
"""Extract reference documentation from the NumPy source tree.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
-import sys
import inspect
import textwrap
import re
import pydoc
from warnings import warn
import collections
-if sys.version_info[0] >= 3:
- from io import StringIO
-else:
- from io import StringIO
class Reader(object):
"""A line-based string reader.
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import re, inspect, textwrap, pydoc
import sphinx
@@ -9,7 +9,7 @@
:license: BSD, see LICENSE for details.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import warnings
import collections
@@ -15,7 +15,7 @@
.. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sphinx
import collections
@@ -14,7 +14,7 @@
.. [1] http://code.google.com/p/pydocweb
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import imp, sys, compiler, types, os, inspect, re
@@ -74,7 +74,7 @@
to make them appear side-by-side, or in floats.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback
import sphinx
@@ -1,5 +1,5 @@
# -*- encoding:utf-8 -*-
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import sys, textwrap
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import numpydoc.linkcode
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import numpydoc.phantom_import
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import numpydoc.plot_directive
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import numpydoc.traitsdoc
@@ -13,7 +13,7 @@
.. [2] http://code.enthought.com/projects/traits/
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import inspect
import os
View
@@ -1,4 +1,4 @@
-from __future__ import division
+from __future__ import division, print_function
import setuptools
from distutils.core import setup
View
@@ -5,7 +5,7 @@
Show a summary about which Numpy functions are documented and which are not.
"""
-from __future__ import division, absolute_import
+from __future__ import division, absolute_import, print_function
import os, glob, re, sys, inspect, optparse
import collections
@@ -78,22 +78,22 @@ def main():
for (filename, section, keyword, toctree) in locations:
in_sections.setdefault((filename, section, keyword), []).append(name)
- print "Documented"
- print "==========\n"
+ print("Documented")
+ print("==========\n")
last_filename = None
for (filename, section, keyword), names in sorted(in_sections.items()):
if filename != last_filename:
- print "--- %s\n" % filename
+ print("--- %s\n" % filename)
last_filename = filename
- print " ** ", section
- print format_in_columns(sorted(names), options.cols)
- print "\n"
-
- print ""
- print "Undocumented"
- print "============\n"
- print format_in_columns(sorted(undocumented.keys()), options.cols)
+ print(" ** ", section)
+ print(format_in_columns(sorted(names), options.cols))
+ print("\n")
+
+ print("")
+ print("Undocumented")
+ print("============\n")
+ print(format_in_columns(sorted(undocumented.keys()), options.cols))
def check_numpy():
documented = get_documented(glob.glob(SOURCE_DIR + '/*.rst'))
View
@@ -1,5 +1,5 @@
#! /usr/bin/env python
-from __future__ import division
+from __future__ import division, print_function
# System imports
from distutils.core import *
Oops, something went wrong.

0 comments on commit bb726ca

Please sign in to comment.