diff options
author | Jaime <jaime.frio@gmail.com> | 2015-12-20 07:35:41 +0100 |
---|---|---|
committer | Jaime <jaime.frio@gmail.com> | 2015-12-20 07:35:41 +0100 |
commit | 144c34b8ecd051e05a93c6268290eadb1827afb0 (patch) | |
tree | c8a1a549e5a093a9433fe9a50a6e0e8bb5358ab1 | |
parent | e2bdaccba1a8691f9223b059b981b2890bb13b09 (diff) | |
parent | 8bc592fabf4a2b0bc76db996b1523330ba095be3 (diff) | |
download | numpy-144c34b8ecd051e05a93c6268290eadb1827afb0.tar.gz |
Merge pull request #6867 from gfyoung/print_fixes
DOC: No Print Statements When Using print_function from __future__
32 files changed, 136 insertions, 136 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 01ef24a5b..7eef07c4a 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -49,7 +49,7 @@ add_newdoc('numpy.core', 'flatiter', >>> type(fl) <type 'numpy.flatiter'> >>> for item in fl: - ... print item + ... print(item) ... 0 1 @@ -1548,7 +1548,7 @@ add_newdoc('numpy.core.multiarray', 'lexsort', >>> a = [1,5,1,4,3,4,4] # First column >>> b = [9,4,0,4,0,2,1] # Second column >>> ind = np.lexsort((b,a)) # Sort by a, then by b - >>> print ind + >>> print(ind) [2 0 4 6 5 3 1] >>> [(a[i],b[i]) for i in ind] @@ -4773,7 +4773,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view', >>> y = x.view(dtype=np.int16, type=np.matrix) >>> y matrix([[513]], dtype=int16) - >>> print type(y) + >>> print(type(y)) <class 'numpy.matrixlib.defmatrix.matrix'> Creating a view on a structured array so it can be used in calculations @@ -4789,7 +4789,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view', Making changes to the view changes the underlying array >>> xv[0,1] = 20 - >>> print x + >>> print(x) [(1, 20) (3, 4)] Using a view to convert an array to a recarray: @@ -4915,7 +4915,7 @@ add_newdoc('numpy.core.umath', 'geterrobj', [10000, 0, None] >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) ... >>> old_bufsize = np.setbufsize(20000) >>> old_err = np.seterr(divide='raise') @@ -4979,7 +4979,7 @@ add_newdoc('numpy.core.umath', 'seterrobj', [10000, 0, None] >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) ... >>> new_errobj = [20000, 12, err_handler] >>> np.seterrobj(new_errobj) @@ -5064,7 +5064,7 @@ add_newdoc('numpy.core.multiarray', 'digitize', >>> inds array([1, 4, 3, 2]) >>> for n in range(x.size): - ... print bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]] + ... print(bins[inds[n]-1], "<=", x[n], "<", bins[inds[n]]) ... 0.0 <= 0.2 < 1.0 4.0 <= 6.4 < 10.0 @@ -5473,7 +5473,7 @@ add_newdoc('numpy.core', 'ufunc', ('identity', 1 >>> np.power.identity 1 - >>> print np.exp.identity + >>> print(np.exp.identity) None """)) @@ -6181,7 +6181,7 @@ add_newdoc('numpy.core.multiarray', 'dtype', ('fields', Examples -------- >>> dt = np.dtype([('name', np.str_, 16), ('grades', np.float64, (2,))]) - >>> print dt.fields + >>> print(dt.fields) {'grades': (dtype(('float64',(2,))), 16), 'name': (dtype('|S16'), 0)} """)) diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index a28b5a89e..fefcb6493 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -114,13 +114,13 @@ def set_printoptions(precision=None, threshold=None, edgeitems=None, Floating point precision can be set: >>> np.set_printoptions(precision=4) - >>> print np.array([1.123456789]) + >>> print(np.array([1.123456789])) [ 1.1235] Long arrays can be summarised: >>> np.set_printoptions(threshold=5) - >>> print np.arange(10) + >>> print(np.arange(10)) [0 1 2 ..., 7 8 9] Small results can be suppressed: @@ -420,8 +420,8 @@ def array2string(a, max_line_width=None, precision=None, Examples -------- >>> x = np.array([1e-16,1,2,3]) - >>> print np.array2string(x, precision=2, separator=',', - ... suppress_small=True) + >>> print(np.array2string(x, precision=2, separator=',', + ... suppress_small=True)) [ 0., 1., 2., 3.] >>> x = np.arange(3.) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 197513294..7d2078adf 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1434,20 +1434,20 @@ def ravel(a, order='C'): It is equivalent to ``reshape(-1, order=order)``. >>> x = np.array([[1, 2, 3], [4, 5, 6]]) - >>> print np.ravel(x) + >>> print(np.ravel(x)) [1 2 3 4 5 6] - >>> print x.reshape(-1) + >>> print(x.reshape(-1)) [1 2 3 4 5 6] - >>> print np.ravel(x, order='F') + >>> print(np.ravel(x, order='F')) [1 4 2 5 3 6] When ``order`` is 'A', it will preserve the array's 'C' or 'F' ordering: - >>> print np.ravel(x.T) + >>> print(np.ravel(x.T)) [1 4 2 5 3 6] - >>> print np.ravel(x.T, order='A') + >>> print(np.ravel(x.T, order='A')) [1 2 3 4 5 6] When ``order`` is 'K', it will preserve orderings that are neither 'C' diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 3b442ea78..4f3d418e6 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1808,7 +1808,7 @@ def set_string_function(f, repr=True): >>> a = np.arange(10) >>> a HA! - What are you going to do now? - >>> print a + >>> print(a) [0 1 2 3 4 5 6 7 8 9] We can reset the function to the default: @@ -2710,7 +2710,7 @@ def seterrcall(func): Callback upon error: >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) ... >>> saved_handler = np.seterrcall(err_handler) @@ -2729,7 +2729,7 @@ def seterrcall(func): >>> class Log(object): ... def write(self, msg): - ... print "LOG: %s" % msg + ... print("LOG: %s" % msg) ... >>> log = Log() @@ -2787,7 +2787,7 @@ def geterrcall(): >>> oldsettings = np.seterr(all='call') >>> def err_handler(type, flag): - ... print "Floating point error (%s), with flag %s" % (type, flag) + ... print("Floating point error (%s), with flag %s" % (type, flag)) >>> oldhandler = np.seterrcall(err_handler) >>> np.array([1, 2, 3]) / 0.0 Floating point error (divide by zero), with flag 1 diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index 7dc6e0bd8..1b6551e6c 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -822,7 +822,7 @@ def sctype2char(sctype): Examples -------- >>> for sctype in [np.int32, np.float, np.complex, np.string_, np.ndarray]: - ... print np.sctype2char(sctype) + ... print(np.sctype2char(sctype)) l d D diff --git a/numpy/core/records.py b/numpy/core/records.py index b07755384..ca6070cf7 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -567,7 +567,7 @@ def fromarrays(arrayList, dtype=None, shape=None, formats=None, >>> x2=np.array(['a','dd','xyz','12']) >>> x3=np.array([1.1,2,3,4]) >>> r = np.core.records.fromarrays([x1,x2,x3],names='a,b,c') - >>> print r[1] + >>> print(r[1]) (2, 'dd', 2.0) >>> x1[1]=34 >>> r.a @@ -643,7 +643,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, >>> r=np.core.records.fromrecords([(456,'dbe',1.2),(2,'de',1.3)], ... names='col1,col2,col3') - >>> print r[0] + >>> print(r[0]) (456, 'dbe', 1.2) >>> r.col1 array([456, 2]) @@ -651,7 +651,7 @@ def fromrecords(recList, dtype=None, shape=None, formats=None, names=None, array(['dbe', 'de'], dtype='|S3') >>> import pickle - >>> print pickle.loads(pickle.dumps(r)) + >>> print(pickle.loads(pickle.dumps(r))) [(456, 'dbe', 1.2) (2, 'de', 1.3)] """ @@ -736,7 +736,7 @@ def fromfile(fd, dtype=None, shape=None, offset=0, formats=None, >>> fd.seek(0) >>> r=np.core.records.fromfile(fd, formats='f8,i4,a5', shape=10, ... byteorder='<') - >>> print r[5] + >>> print(r[5]) (0.5, 10, 'abcde') >>> r.shape (10,) diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index 0dd2e164a..599b48d82 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -150,7 +150,7 @@ def atleast_3d(*arys): True >>> for arr in np.atleast_3d([1, 2], [[1, 2]], [[[1, 2]]]): - ... print arr, arr.shape + ... print(arr, arr.shape) ... [[[1] [2]]] (1, 2, 1) diff --git a/numpy/distutils/npy_pkg_config.py b/numpy/distutils/npy_pkg_config.py index 1c801fd9c..fe64709ca 100644 --- a/numpy/distutils/npy_pkg_config.py +++ b/numpy/distutils/npy_pkg_config.py @@ -366,7 +366,7 @@ def read_config(pkgname, dirs=None): >>> npymath_info = np.distutils.npy_pkg_config.read_config('npymath') >>> type(npymath_info) <class 'numpy.distutils.npy_pkg_config.LibraryInfo'> - >>> print npymath_info + >>> print(npymath_info) Name: npymath Description: Portable, core math library implementing C99 standard Requires: diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index 94436243e..bf2762523 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -1947,7 +1947,7 @@ class _numpy_info(system_info): ## hex(vstr2hex(module.__version__))), ## ) ## except Exception as msg: -## print msg +## print(msg) dict_append(info, define_macros=macros) include_dirs = self.get_include_dirs() inc_dir = None diff --git a/numpy/doc/glossary.py b/numpy/doc/glossary.py index 9dacd1cb5..4a3238491 100644 --- a/numpy/doc/glossary.py +++ b/numpy/doc/glossary.py @@ -109,7 +109,7 @@ Glossary >>> def log(f): ... def new_logging_func(*args, **kwargs): - ... print "Logging call with parameters:", args, kwargs + ... print("Logging call with parameters:", args, kwargs) ... return f(*args, **kwargs) ... ... return new_logging_func @@ -185,7 +185,7 @@ Glossary It is often used in combintion with ``enumerate``:: >>> keys = ['a','b','c'] >>> for n, k in enumerate(keys): - ... print "Key %d: %s" % (n, k) + ... print("Key %d: %s" % (n, k)) ... Key 0: a Key 1: b @@ -315,7 +315,7 @@ Glossary ... color = 'blue' ... ... def paint(self): - ... print "Painting the city %s!" % self.color + ... print("Painting the city %s!" % self.color) ... >>> p = Paintbrush() >>> p.color = 'red' diff --git a/numpy/doc/misc.py b/numpy/doc/misc.py index 1709ad66d..e30caf0cb 100644 --- a/numpy/doc/misc.py +++ b/numpy/doc/misc.py @@ -86,7 +86,7 @@ Examples >>> np.sqrt(np.array([-1.])) FloatingPointError: invalid value encountered in sqrt >>> def errorhandler(errstr, errflag): - ... print "saw stupid error!" + ... print("saw stupid error!") >>> np.seterrcall(errorhandler) <function err_handler at 0x...> >>> j = np.seterr(all='call') diff --git a/numpy/doc/subclassing.py b/numpy/doc/subclassing.py index a62fc2d6d..85327feab 100644 --- a/numpy/doc/subclassing.py +++ b/numpy/doc/subclassing.py @@ -123,13 +123,13 @@ For example, consider the following Python code: class C(object): def __new__(cls, *args): - print 'Cls in __new__:', cls - print 'Args in __new__:', args + print('Cls in __new__:', cls) + print('Args in __new__:', args) return object.__new__(cls, *args) def __init__(self, *args): - print 'type(self) in __init__:', type(self) - print 'Args in __init__:', args + print('type(self) in __init__:', type(self)) + print('Args in __init__:', args) meaning that we get: @@ -159,13 +159,13 @@ of some other class. Consider the following: class D(C): def __new__(cls, *args): - print 'D cls is:', cls - print 'D args in __new__:', args + print('D cls is:', cls) + print('D args in __new__:', args) return C.__new__(C, *args) def __init__(self, *args): # we never get here - print 'In D __init__' + print('In D __init__') meaning that: @@ -242,18 +242,18 @@ The following code allows us to look at the call sequences and arguments: class C(np.ndarray): def __new__(cls, *args, **kwargs): - print 'In __new__ with class %s' % cls + print('In __new__ with class %s' % cls) return np.ndarray.__new__(cls, *args, **kwargs) def __init__(self, *args, **kwargs): # in practice you probably will not need or want an __init__ # method for your subclass - print 'In __init__ with class %s' % self.__class__ + print('In __init__ with class %s' % self.__class__) def __array_finalize__(self, obj): - print 'In array_finalize:' - print ' self type is %s' % type(self) - print ' obj type is %s' % type(obj) + print('In array_finalize:') + print(' self type is %s' % type(self)) + print(' obj type is %s' % type(obj)) Now: @@ -441,16 +441,16 @@ some print statements: return obj def __array_finalize__(self, obj): - print 'In __array_finalize__:' - print ' self is %s' % repr(self) - print ' obj is %s' % repr(obj) + print('In __array_finalize__:') + print(' self is %s' % repr(self)) + print(' obj is %s' % repr(obj)) if obj is None: return self.info = getattr(obj, 'info', None) def __array_wrap__(self, out_arr, context=None): - print 'In __array_wrap__:' - print ' self is %s' % repr(self) - print ' arr is %s' % repr(out_arr) + print('In __array_wrap__:') + print(' self is %s' % repr(self)) + print(' arr is %s' % repr(out_arr)) # then just call the parent return np.ndarray.__array_wrap__(self, out_arr, context) diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index b64aaa50d..289102e5a 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -673,7 +673,7 @@ def getcallprotoargument(rout, cb_map={}): proto_args = ','.join(arg_types + arg_types2) if not proto_args: proto_args = 'void' - # print proto_args + # print(proto_args) return proto_args diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py index 80b369bd5..fb52ada86 100644 --- a/numpy/lib/arrayterator.py +++ b/numpy/lib/arrayterator.py @@ -80,7 +80,7 @@ class Arrayterator(object): >>> for subarr in a_itor: ... if not subarr.all(): - ... print subarr, subarr.shape + ... print(subarr, subarr.shape) ... [[[[0 1]]]] (1, 1, 1, 2) @@ -158,7 +158,7 @@ class Arrayterator(object): >>> for subarr in a_itor.flat: ... if not subarr: - ... print subarr, type(subarr) + ... print(subarr, type(subarr)) ... 0 <type 'numpy.int32'> diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py index a7e4e60b6..c42424da1 100644 --- a/numpy/lib/financial.py +++ b/numpy/lib/financial.py @@ -247,7 +247,7 @@ def nper(rate, pmt, pv, fv=0, when='end'): If you only had $150/month to pay towards the loan, how long would it take to pay-off a loan of $8,000 at 7% annual interest? - >>> print round(np.nper(0.07/12, -150, 8000), 5) + >>> print(round(np.nper(0.07/12, -150, 8000), 5)) 64.07335 So, over 64 months would be required to pay off the loan. @@ -347,7 +347,7 @@ def ipmt(rate, per, nper, pv, fv=0.0, when='end'): >>> for payment in per: ... index = payment - 1 ... principal = principal + ppmt[index] - ... print fmt.format(payment, ppmt[index], ipmt[index], principal) + ... print(fmt.format(payment, ppmt[index], ipmt[index], principal)) 1 -200.58 -17.17 2299.42 2 -201.96 -15.79 2097.46 3 -203.35 -14.40 1894.11 diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 8335b4fdb..c69185c1c 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -833,7 +833,7 @@ def asarray_chkfinite(a, dtype=None, order=None): >>> try: ... np.asarray_chkfinite(a) ... except ValueError: - ... print 'ValueError' + ... print('ValueError') ... ValueError @@ -2200,13 +2200,13 @@ def cov(m, y=None, rowvar=True, bias=False, ddof=None, fweights=None, >>> x = [-2.1, -1, 4.3] >>> y = [3, 1.1, 0.12] >>> X = np.vstack((x,y)) - >>> print np.cov(X) + >>> print(np.cov(X)) [[ 11.71 -4.286 ] [ -4.286 2.14413333]] - >>> print np.cov(x, y) + >>> print(np.cov(x, y)) [[ 11.71 -4.286 ] [ -4.286 2.14413333]] - >>> print np.cov(x) + >>> print(np.cov(x)) 11.71 """ diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 8bcc3fb53..a0875a25f 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -491,7 +491,7 @@ class ndenumerate(object): -------- >>> a = np.array([[1, 2], [3, 4]]) >>> for index, x in np.ndenumerate(a): - ... print index, x + ... print(index, x) (0, 0) 1 (0, 1) 2 (1, 0) 3 @@ -542,7 +542,7 @@ class ndindex(object): Examples -------- >>> for index in np.ndindex(3, 2, 1): - ... print index + ... print(index) (0, 0, 0) (0, 1, 0) (1, 0, 0) diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py index 2f677438b..a5d3f5f5f 100644 --- a/numpy/lib/polynomial.py +++ b/numpy/lib/polynomial.py @@ -715,12 +715,12 @@ def polyadd(a1, a2): >>> p1 = np.poly1d([1, 2]) >>> p2 = np.poly1d([9, 5, 4]) - >>> print p1 + >>> print(p1) 1 x + 2 - >>> print p2 + >>> print(p2) 2 9 x + 5 x + 4 - >>> print np.polyadd(p1, p2) + >>> print(np.polyadd(p1, p2)) 2 9 x + 6 x + 6 @@ -826,13 +826,13 @@ def polymul(a1, a2): >>> p1 = np.poly1d([1, 2, 3]) >>> p2 = np.poly1d([9, 5, 1]) - >>> print p1 + >>> print(p1) 2 1 x + 2 x + 3 - >>> print p2 + >>> print(p2) 2 9 x + 5 x + 1 - >>> print np.polymul(p1, p2) + >>> print(np.polymul(p1, p2)) 4 3 2 9 x + 23 x + 38 x + 17 x + 3 @@ -966,7 +966,7 @@ class poly1d(object): Construct the polynomial :math:`x^2 + 2x + 3`: >>> p = np.poly1d([1, 2, 3]) - >>> print np.poly1d(p) + >>> print(np.poly1d(p)) 2 1 x + 2 x + 3 @@ -1022,7 +1022,7 @@ class poly1d(object): using the `variable` parameter: >>> p = np.poly1d([1,2,3], variable='z') - >>> print p + >>> print(p) 2 1 z + 2 z + 3 diff --git a/numpy/lib/tests/test_format.py b/numpy/lib/tests/test_format.py index 1bf65fa61..a091ef5b3 100644 --- a/numpy/lib/tests/test_format.py +++ b/numpy/lib/tests/test_format.py @@ -112,7 +112,7 @@ Test the header writing. >>> for arr in basic_arrays + record_arrays: ... f = BytesIO() ... format.write_array_header_1_0(f, arr) # XXX: arr is not a dict, items gets called on it - ... print repr(f.getvalue()) + ... print(repr(f.getvalue())) ... "F\x00{'descr': '|u1', 'fortran_order': False, 'shape': (0,)} \n" "F\x00{'descr': '|u1', 'fortran_order': False, 'shape': ()} \n" diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 464ffd914..b2f350bb7 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -664,7 +664,7 @@ def histogram2d(x, y, bins=10, range=None, normed=False, weights=None): Or we fill the histogram H with a determined bin content: >>> H = np.ones((4, 4)).cumsum().reshape(4, 4) - >>> print H[::-1] # This shows the bin content in the order as plotted + >>> print(H[::-1]) # This shows the bin content in the order as plotted [[ 13. 14. 15. 16.] [ 9. 10. 11. 12.] [ 5. 6. 7. 8.] diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py index 2fe4e7d23..1313adff7 100644 --- a/numpy/lib/type_check.py +++ b/numpy/lib/type_check.py @@ -501,7 +501,7 @@ def typename(char): >>> typechars = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', ... 'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q'] >>> for typechar in typechars: - ... print typechar, ' : ', np.typename(typechar) + ... print(typechar, ' : ', np.typename(typechar)) ... S1 : character ? : bool diff --git a/numpy/linalg/lapack_lite/clapack_scrub.py b/numpy/linalg/lapack_lite/clapack_scrub.py index 4a517d531..9dfee0a84 100644 --- a/numpy/linalg/lapack_lite/clapack_scrub.py +++ b/numpy/linalg/lapack_lite/clapack_scrub.py @@ -14,9 +14,9 @@ class MyScanner(Scanner): def begin(self, state_name): # if self.state_name == '': -# print '<default>' +# print('<default>') # else: -# print self.state_name +# print(self.state_name) Scanner.begin(self, state_name) def sep_seq(sequence, sep): diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 2e969727b..9dc879d31 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -1853,7 +1853,7 @@ def lstsq(a, b, rcond=-1): [ 3., 1.]]) >>> m, c = np.linalg.lstsq(A, y)[0] - >>> print m, c + >>> print(m, c) 1.0 -0.95 Plot the data along with the fitted line: diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 25e542cd6..de716a669 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2147,12 +2147,12 @@ def masked_object(x, value, copy=True, shrink=True): >>> food = np.array(['green_eggs', 'ham'], dtype=object) >>> # don't eat spoiled food >>> eat = ma.masked_object(food, 'green_eggs') - >>> print eat + >>> print(eat) [-- ham] >>> # plain ol` ham is boring >>> fresh_food = np.array(['cheese', 'ham', 'pineapple'], dtype=object) >>> eat = ma.masked_object(fresh_food, 'green_eggs') - >>> print eat + >>> print(eat) [cheese ham pineapple] Note that `mask` is set to ``nomask`` if possible. @@ -2548,7 +2548,7 @@ class MaskedIterator(object): >>> type(fl) <class 'numpy.ma.core.MaskedIterator'> >>> for item in fl: - ... print item + ... print(item) ... 0 1 @@ -3064,11 +3064,11 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3.1],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1.0 -- 3.1] [-- 5.0 --] [7.0 -- 9.0]] - >>> print x.astype(int32) + >>> print(x.astype(int32)) [[1 -- 3] [-- 5 --] [7 -- 9]] @@ -3656,7 +3656,7 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1 -- 3] [-- 5 --] [7 -- 9]] @@ -4261,11 +4261,11 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1 -- 3] [-- 5 --] [7 -- 9]] - >>> print x.ravel() + >>> print(x.ravel()) [1 -- 3 -- 5 -- 7 -- 9] """ @@ -4317,11 +4317,11 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2],[3,4]], mask=[1,0,0,1]) - >>> print x + >>> print(x) [[-- 2] [3 --]] >>> x = x.reshape((4,1)) - >>> print x + >>> print(x) [[--] [2] [3] @@ -4382,18 +4382,18 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1 -- 3] [-- 5 --] [7 -- 9]] >>> x.put([0,4,8],[10,20,30]) - >>> print x + >>> print(x) [[10 -- 3] [-- 20 --] [7 -- 30]] >>> x.put(4,999) - >>> print x + >>> print(x) [[10 -- 3] [-- 999 --] [7 -- 30]] @@ -4745,17 +4745,17 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1 -- 3] [-- 5 --] [7 -- 9]] - >>> print x.sum() + >>> print(x.sum()) 25 - >>> print x.sum(axis=1) + >>> print(x.sum(axis=1)) [4 5 16] - >>> print x.sum(axis=0) + >>> print(x.sum(axis=0)) [8 5 12] - >>> print type(x.sum(axis=0, dtype=np.int64)[0]) + >>> print(type(x.sum(axis=0, dtype=np.int64)[0])) <type 'numpy.int64'> """ @@ -4823,7 +4823,7 @@ class MaskedArray(ndarray): Examples -------- >>> marr = np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0]) - >>> print marr.cumsum() + >>> print(marr.cumsum()) [0 1 3 -- -- -- 9 16 24 33] """ @@ -5223,12 +5223,12 @@ class MaskedArray(ndarray): -------- >>> x = np.ma.array(arange(4), mask=[1,1,0,0]) >>> x.shape = (2,2) - >>> print x + >>> print(x) [[-- --] [2 3]] - >>> print x.argmin(axis=0, fill_value=-1) + >>> print(x.argmin(axis=0, fill_value=-1)) [0 0] - >>> print x.argmin(axis=0, fill_value=9) + >>> print(x.argmin(axis=0, fill_value=9)) [1 1] """ @@ -5324,19 +5324,19 @@ class MaskedArray(ndarray): >>> a = ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) >>> # Default >>> a.sort() - >>> print a + >>> print(a) [1 3 5 -- --] >>> a = ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) >>> # Put missing values in the front >>> a.sort(endwith=False) - >>> print a + >>> print(a) [-- -- 1 3 5] >>> a = ma.array([1, 2, 5, 4, 3],mask=[0, 1, 0, 1, 0]) >>> # fill_value takes over endwith >>> a.sort(endwith=False, fill_value=3) - >>> print a + >>> print(a) [1 -- -- 3 5] """ @@ -5452,7 +5452,7 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array(np.arange(6), mask=[0 ,1, 0, 0, 0 ,1]).reshape(3, 2) - >>> print x + >>> print(x) [[0 --] [2 3] [4 --]] @@ -5462,7 +5462,7 @@ class MaskedArray(ndarray): masked_array(data = [0 3], mask = [False False], fill_value = 999999) - >>> print x.mini(axis=1) + >>> print(x.mini(axis=1)) [0 2 4] """ @@ -5741,11 +5741,11 @@ class MaskedArray(ndarray): Examples -------- >>> x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4) - >>> print x + >>> print(x) [[1 -- 3] [-- 5 --] [7 -- 9]] - >>> print x.toflex() + >>> print(x.toflex()) [[(1, False) (2, True) (3, False)] [(4, True) (5, False) (6, True)] [(7, False) (8, True) (9, False)]] @@ -6914,14 +6914,14 @@ def where(condition, x=_NoValue, y=_NoValue): >>> x = np.ma.array(np.arange(9.).reshape(3, 3), mask=[[0, 1, 0], ... [1, 0, 1], ... [0, 1, 0]]) - >>> print x + >>> print(x) [[0.0 -- 2.0] [-- 4.0 --] [6.0 -- 8.0]] >>> np.ma.where(x > 5) # return the indices where x > 5 (array([2, 2]), array([0, 2])) - >>> print np.ma.where(x > 5, x, -3.1416) + >>> print(np.ma.where(x > 5, x, -3.1416)) [[-3.1416 -- -3.1416] [-- -3.1416 --] [6.0 -- 8.0]] diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index e1d228e73..9855b4e76 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -439,7 +439,7 @@ if apply_over_axes.__doc__ is not None: >>> a = ma.arange(24).reshape(2,3,4) >>> a[:,0,1] = ma.masked >>> a[:,1,:] = ma.masked - >>> print a + >>> print(a) [[[0 -- 2 3] [-- -- -- --] [8 9 10 11]] @@ -447,14 +447,14 @@ if apply_over_axes.__doc__ is not None: [[12 -- 14 15] [-- -- -- --] [20 21 22 23]]] - >>> print ma.apply_over_axes(ma.sum, a, [0,2]) + >>> print(ma.apply_over_axes(ma.sum, a, [0,2])) [[[46] [--] [124]]] Tuple axis arguments to ufuncs are equivalent: - >>> print ma.sum(a, axis=(0,2)).reshape((1,-1,1)) + >>> print(ma.sum(a, axis=(0,2)).reshape((1,-1,1))) [[[46] [--] [124]]] @@ -502,13 +502,13 @@ def average(a, axis=None, weights=None, returned=False): 1.25 >>> x = np.ma.arange(6.).reshape(3, 2) - >>> print x + >>> print(x) [[ 0. 1.] [ 2. 3.] [ 4. 5.]] >>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3], ... returned=True) - >>> print avg + >>> print(avg) [2.66666666667 3.66666666667] """ @@ -1476,7 +1476,7 @@ def flatnotmasked_edges(a): array([3, 8]) >>> a[:] = np.ma.masked - >>> print flatnotmasked_edges(ma) + >>> print(flatnotmasked_edges(ma)) None """ @@ -1578,7 +1578,7 @@ def flatnotmasked_contiguous(a): >>> np.ma.flatnotmasked_contiguous(a) [slice(3, 5, None), slice(6, 9, None)] >>> a[:] = np.ma.masked - >>> print np.ma.flatnotmasked_edges(a) + >>> print(np.ma.flatnotmasked_edges(a)) None """ diff --git a/numpy/ma/tests/test_old_ma.py b/numpy/ma/tests/test_old_ma.py index a32f358c0..d9a93efd4 100644 --- a/numpy/ma/tests/test_old_ma.py +++ b/numpy/ma/tests/test_old_ma.py @@ -831,13 +831,13 @@ def eqmask(m1, m2): # t = testta(n, f) # t1 = testtb(n, f) # t2 = testtc(n, f) -# print f.test_name -# print """\ +# print(f.test_name) +# print("""\ #n = %7d #numpy time (ms) %6.1f #MA maskless ratio %6.1f #MA masked ratio %6.1f -#""" % (n, t*1000.0, t1/t, t2/t) +#""" % (n, t*1000.0, t1/t, t2/t)) #def testta(n, f): # x=np.arange(n) + 1.0 diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index 170db87c8..134f4d203 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -233,7 +233,7 @@ class matrix(N.ndarray): Examples -------- >>> a = np.matrix('1 2; 3 4') - >>> print a + >>> print(a) [[1 2] [3 4]] diff --git a/numpy/testing/decorators.py b/numpy/testing/decorators.py index df3d297ff..6cde298e1 100644 --- a/numpy/testing/decorators.py +++ b/numpy/testing/decorators.py @@ -48,7 +48,7 @@ def slow(t): @dec.slow def test_big(self): - print 'Big, slow test' + print('Big, slow test') """ diff --git a/numpy/testing/noseclasses.py b/numpy/testing/noseclasses.py index 197e20bac..4a8e9b0d6 100644 --- a/numpy/testing/noseclasses.py +++ b/numpy/testing/noseclasses.py @@ -34,33 +34,33 @@ class NumpyDocTestFinder(doctest.DocTestFinder): module. """ if module is None: - #print '_fm C1' # dbg + #print('_fm C1') # dbg return True elif inspect.isfunction(object): - #print '_fm C2' # dbg + #print('_fm C2') # dbg return module.__dict__ is object.__globals__ elif inspect.isbuiltin(object): - #print '_fm C2-1' # dbg + #print('_fm C2-1') # dbg return module.__name__ == object.__module__ elif inspect.isclass(object): - #print '_fm C3' # dbg + #print('_fm C3') # dbg return module.__name__ == object.__module__ elif inspect.ismethod(object): # This one may be a bug in cython that fails to correctly set the # __module__ attribute of methods, but since the same error is easy # to make by extension code writers, having this safety in place # isn't such a bad idea - #print '_fm C3-1' # dbg + #print('_fm C3-1') # dbg return module.__name__ == object.__self__.__class__.__module__ elif inspect.getmodule(object) is not None: - #print '_fm C4' # dbg - #print 'C4 mod',module,'obj',object # dbg + #print('_fm C4') # dbg + #print('C4 mod',module,'obj',object) # dbg return module is inspect.getmodule(object) elif hasattr(object, '__module__'): - #print '_fm C5' # dbg + #print('_fm C5') # dbg return module.__name__ == object.__module__ elif isinstance(object, property): - #print '_fm C6' # dbg + #print('_fm C6') # dbg return True # [XX] no way not be sure. else: raise ValueError("object must be a class or function") @@ -95,10 +95,10 @@ class NumpyDocTestFinder(doctest.DocTestFinder): # Look for tests in a class's contained objects. if isclass(obj) and self._recurse: - #print 'RECURSE into class:',obj # dbg + #print('RECURSE into class:',obj) # dbg for valname, val in obj.__dict__.items(): #valname1 = '%s.%s' % (name, valname) # dbg - #print 'N',name,'VN:',valname,'val:',str(val)[:77] # dbg + #print('N',name,'VN:',valname,'val:',str(val)[:77]) # dbg # Special handling for staticmethod/classmethod. if isinstance(val, staticmethod): val = getattr(obj, valname) diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 00f7ce4d1..49d249339 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -1293,7 +1293,7 @@ def measure(code_str,times=1,label=None): -------- >>> etime = np.testing.measure('for i in range(1000): np.sqrt(i**2)', ... times=times) - >>> print "Time for a single execution : ", etime / times, "s" + >>> print("Time for a single execution : ", etime / times, "s") Time for a single execution : 0.005 s """ diff --git a/tools/swig/test/testFortran.py b/tools/swig/test/testFortran.py index be4134d4e..c77d728e9 100644 --- a/tools/swig/test/testFortran.py +++ b/tools/swig/test/testFortran.py @@ -29,7 +29,7 @@ class FortranTestCase(unittest.TestCase): # commenting it out. --WFS # def testSecondElementContiguous(self): # "Test Fortran matrix initialized from reshaped default array" - # print >>sys.stderr, self.typeStr, "... ", + # print(self.typeStr, "... ", end="", file=sys.stderr) # second = Fortran.__dict__[self.typeStr + "SecondElement"] # matrix = np.arange(9).reshape(3, 3).astype(self.typeCode) # self.assertEquals(second(matrix), 3) diff --git a/tools/win32build/misc/x86analysis.py b/tools/win32build/misc/x86analysis.py index 39b7cca79..0b5586406 100644 --- a/tools/win32build/misc/x86analysis.py +++ b/tools/win32build/misc/x86analysis.py @@ -148,9 +148,9 @@ def analyse(filename): sse3 = has_sse3(inst) #mmx = has_mmx(inst) #ppro = has_ppro(inst) - #print sse - #print sse2 - #print sse3 + #print(sse) + #print(sse2) + #print(sse3) print("SSE3 inst %d" % cntset(sse3)) print("SSE2 inst %d" % cntset(sse2)) print("SSE inst %d" % cntset(sse)) |