Skip to content

Commit bb726ca

Browse files
committed
2to3: Apply print fixer.
Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes numpy#3078.
1 parent 7441fa5 commit bb726ca

File tree

422 files changed

+888
-894
lines changed

Some content is hidden

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

422 files changed

+888
-894
lines changed

doc/cdoc/numpyfilter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Also, add Doxygen /** and /**< syntax automatically where appropriate.
77
88
"""
9-
from __future__ import division, absolute_import
9+
from __future__ import division, absolute_import, print_function
1010

1111
import sys
1212
import re

doc/cython/run_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
from __future__ import division, absolute_import
2+
from __future__ import division, absolute_import, print_function
33

44
from numpyx import test
55
test()

doc/cython/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
http://cython.org.
66
77
"""
8-
from __future__ import division
8+
from __future__ import division, print_function
99

1010
from distutils.core import setup
1111
from distutils.extension import Extension

doc/example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
a line by itself, preferably preceeded by a blank line.
99
1010
"""
11-
from __future__ import division, absolute_import
11+
from __future__ import division, absolute_import, print_function
1212

1313
import os # standard library imports first
1414

doc/newdtype_example/example.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import floatint.floatint as ff
44
import numpy as np
@@ -12,7 +12,7 @@
1212

1313
# Now, the elements will be the scalar type associated
1414
# with the ndarray.
15-
print g[0]
16-
print type(g[1])
15+
print(g[0])
16+
print(type(g[1]))
1717

1818
# Now, you need to register ufuncs and more arrfuncs to do useful things...
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33

doc/newdtype_example/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, print_function
22

33
from numpy.distutils.core import setup
44

doc/numpybook/comparison/ctypes/filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
__all__ = ['filter2d']
44

doc/numpybook/comparison/ctypes/interface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
__all__ = ['add', 'filter2d']
44

doc/numpybook/comparison/pyrex/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
from __future__ import division
2+
from __future__ import division, print_function
33

44
from distutils.core import setup
55
from distutils.extension import Extension

doc/numpybook/comparison/timing.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import timeit
44

@@ -54,9 +54,9 @@
5454
for kind in ['f2py']:#['ctypes', 'pyrex', 'weave', 'f2py']:
5555
res[kind] = []
5656
sys.path = ['/Users/oliphant/numpybook/%s' % (kind,)] + path
57-
print sys.path
57+
print(sys.path)
5858
for n in N:
59-
print "%s - %d" % (kind, n)
59+
print("%s - %d" % (kind, n))
6060
t = timeit.Timer(eval('%s_run'%kind), eval('%s_pre %% (%d,%d)'%(kind,n,n)))
6161
mytime = min(t.repeat(3,100))
6262
res[kind].append(mytime)

doc/numpybook/comparison/weave/filter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
from scipy import weave, zeros_like
44

doc/numpybook/comparison/weave/inline.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
from scipy import weave
44
from numpy import rand, zeros_like
@@ -40,8 +40,8 @@ def arr(a):
4040
return b
4141

4242
a = [None]*10
43-
print example1(a)
44-
print a
43+
print(example1(a))
44+
print(a)
4545

4646
a = rand(512,512)
4747
b = arr(a)

doc/numpybook/runcode.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
-n name of code section (default MyCode)
1515
1616
"""
17-
from __future__ import division, absolute_import
17+
from __future__ import division, absolute_import, print_function
1818

1919
import sys
2020
import optparse
@@ -25,8 +25,8 @@
2525
newre = re.compile(r"\\begin_inset Note.*PYNEW\s+\\end_inset", re.DOTALL)
2626

2727
def getoutput(tstr, dic):
28-
print "\n\nRunning..."
29-
print tstr,
28+
print("\n\nRunning...")
29+
print(tstr, end=' ')
3030
tempstr = io.StringIO()
3131
sys.stdout = tempstr
3232
code = compile(tstr, '<input>', 'exec')
@@ -44,8 +44,8 @@ def getoutput(tstr, dic):
4444
else:
4545
res = tempstr.getvalue() + '\n' + repr(res)
4646
if res != '':
47-
print "\nOutput is"
48-
print res,
47+
print("\nOutput is")
48+
print(res, end=' ')
4949
return res
5050

5151
# now find the code in the code segment
@@ -90,7 +90,7 @@ def runpycode(lyxstr, name='MyCode'):
9090
num += 1
9191

9292
if num == 0:
93-
print "Nothing found for %s" % name
93+
print("Nothing found for %s" % name)
9494
return lyxstr
9595

9696
start = 0
@@ -141,7 +141,7 @@ def main(args):
141141
fid = file(args[0])
142142
str = fid.read()
143143
fid.close()
144-
print "Processing %s" % options.name
144+
print("Processing %s" % options.name)
145145
newstr = runpycode(str, options.name)
146146
fid = file(args[0],'w')
147147
fid.write(newstr)

doc/postprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
MODE is either 'html' or 'tex'.
77
88
"""
9-
from __future__ import division, absolute_import
9+
from __future__ import division, absolute_import, print_function
1010

1111
import re, optparse
1212

doc/pyrex/run_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
from __future__ import division, absolute_import
2+
from __future__ import division, absolute_import, print_function
33

44
from numpyx import test
55
test()

doc/pyrex/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
http://www.scipy.org/Cookbook/ArrayStruct_and_Pyrex
1313
1414
"""
15-
from __future__ import division
15+
from __future__ import division, print_function
1616

1717
from distutils.core import setup
1818
from distutils.extension import Extension

doc/source/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
from __future__ import division, absolute_import
2+
from __future__ import division, absolute_import, print_function
33

44
import sys, os, re
55

doc/sphinxext/numpydoc/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
from .numpydoc import setup

doc/sphinxext/numpydoc/comment_eater.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import sys
44
if sys.version_info[0] >= 3:

doc/sphinxext/numpydoc/compiler_unparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
fixme: We may want to move to using _ast trees because the compiler for
1111
them is about 6 times faster than compiler.compile.
1212
"""
13-
from __future__ import division, absolute_import
13+
from __future__ import division, absolute_import, print_function
1414

1515
import sys
1616
from compiler.ast import Const, Name, Tuple, Div, Mul, Sub, Add

doc/sphinxext/numpydoc/docscrape.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
"""Extract reference documentation from the NumPy source tree.
22
33
"""
4-
from __future__ import division, absolute_import
4+
from __future__ import division, absolute_import, print_function
55

6-
import sys
76
import inspect
87
import textwrap
98
import re
109
import pydoc
1110
from warnings import warn
1211
import collections
1312

14-
if sys.version_info[0] >= 3:
15-
from io import StringIO
16-
else:
17-
from io import StringIO
1813

1914
class Reader(object):
2015
"""A line-based string reader.

doc/sphinxext/numpydoc/docscrape_sphinx.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import re, inspect, textwrap, pydoc
44
import sphinx

doc/sphinxext/numpydoc/linkcode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
:license: BSD, see LICENSE for details.
1010
1111
"""
12-
from __future__ import division, absolute_import
12+
from __future__ import division, absolute_import, print_function
1313

1414
import warnings
1515
import collections

doc/sphinxext/numpydoc/numpydoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
.. [1] https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt
1616
1717
"""
18-
from __future__ import division, absolute_import
18+
from __future__ import division, absolute_import, print_function
1919

2020
import sphinx
2121
import collections

doc/sphinxext/numpydoc/phantom_import.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
.. [1] http://code.google.com/p/pydocweb
1515
1616
"""
17-
from __future__ import division, absolute_import
17+
from __future__ import division, absolute_import, print_function
1818

1919
import imp, sys, compiler, types, os, inspect, re
2020

doc/sphinxext/numpydoc/plot_directive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
to make them appear side-by-side, or in floats.
7575
7676
"""
77-
from __future__ import division, absolute_import
77+
from __future__ import division, absolute_import, print_function
7878

7979
import sys, os, glob, shutil, imp, warnings, re, textwrap, traceback
8080
import sphinx

doc/sphinxext/numpydoc/tests/test_docscrape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- encoding:utf-8 -*-
2-
from __future__ import division, absolute_import
2+
from __future__ import division, absolute_import, print_function
33

44
import sys, textwrap
55

doc/sphinxext/numpydoc/tests/test_linkcode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import numpydoc.linkcode
44

doc/sphinxext/numpydoc/tests/test_phantom_import.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import numpydoc.phantom_import
44

doc/sphinxext/numpydoc/tests/test_plot_directive.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import numpydoc.plot_directive
44

doc/sphinxext/numpydoc/tests/test_traitsdoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division, absolute_import
1+
from __future__ import division, absolute_import, print_function
22

33
import numpydoc.traitsdoc
44

doc/sphinxext/numpydoc/traitsdoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
.. [2] http://code.enthought.com/projects/traits/
1414
1515
"""
16-
from __future__ import division, absolute_import
16+
from __future__ import division, absolute_import, print_function
1717

1818
import inspect
1919
import os

doc/sphinxext/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
from __future__ import division, print_function
22

33
import setuptools
44
from distutils.core import setup

doc/summarize.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Show a summary about which Numpy functions are documented and which are not.
66
77
"""
8-
from __future__ import division, absolute_import
8+
from __future__ import division, absolute_import, print_function
99

1010
import os, glob, re, sys, inspect, optparse
1111
import collections
@@ -78,22 +78,22 @@ def main():
7878
for (filename, section, keyword, toctree) in locations:
7979
in_sections.setdefault((filename, section, keyword), []).append(name)
8080

81-
print "Documented"
82-
print "==========\n"
81+
print("Documented")
82+
print("==========\n")
8383

8484
last_filename = None
8585
for (filename, section, keyword), names in sorted(in_sections.items()):
8686
if filename != last_filename:
87-
print "--- %s\n" % filename
87+
print("--- %s\n" % filename)
8888
last_filename = filename
89-
print " ** ", section
90-
print format_in_columns(sorted(names), options.cols)
91-
print "\n"
92-
93-
print ""
94-
print "Undocumented"
95-
print "============\n"
96-
print format_in_columns(sorted(undocumented.keys()), options.cols)
89+
print(" ** ", section)
90+
print(format_in_columns(sorted(names), options.cols))
91+
print("\n")
92+
93+
print("")
94+
print("Undocumented")
95+
print("============\n")
96+
print(format_in_columns(sorted(undocumented.keys()), options.cols))
9797

9898
def check_numpy():
9999
documented = get_documented(glob.glob(SOURCE_DIR + '/*.rst'))

doc/swig/test/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /usr/bin/env python
2-
from __future__ import division
2+
from __future__ import division, print_function
33

44
# System imports
55
from distutils.core import *

0 commit comments

Comments
 (0)