Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r67539:6965cd292e2b
Date: 2013-10-23 13:14 -0700
http://bitbucket.org/pypy/pypy/changeset/6965cd292e2b/

Log:    2to3

diff --git a/lib_pypy/numpypy/__init__.py b/lib_pypy/numpypy/__init__.py
--- a/lib_pypy/numpypy/__init__.py
+++ b/lib_pypy/numpypy/__init__.py
@@ -3,7 +3,7 @@
 from . import lib
 from .lib import *
 
-from __builtin__ import bool, int, long, float, complex, object, unicode, str
+from builtins import bool, int, int, float, complex, object, str, str
 
 from .core import round, abs, max, min
 
diff --git a/lib_pypy/numpypy/core/__init__.py 
b/lib_pypy/numpypy/core/__init__.py
--- a/lib_pypy/numpypy/core/__init__.py
+++ b/lib_pypy/numpypy/core/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import, print_function
+
 
 from . import multiarray
 from . import umath
diff --git a/lib_pypy/numpypy/core/_methods.py 
b/lib_pypy/numpypy/core/_methods.py
--- a/lib_pypy/numpypy/core/_methods.py
+++ b/lib_pypy/numpypy/core/_methods.py
@@ -1,9 +1,9 @@
 # Array methods which are called by the both the C-code for the method
 # and the Python code for the NumPy-namespace function
 
-import multiarray as mu
-import umath as um
-from numeric import asanyarray
+from . import multiarray as mu
+from . import umath as um
+from .numeric import asanyarray
 
 def _amax(a, axis=None, out=None, keepdims=False):
     return um.maximum.reduce(a, axis=axis,
@@ -31,7 +31,7 @@
 
 def _count_reduce_items(arr, axis):
     if axis is None:
-        axis = tuple(xrange(arr.ndim))
+        axis = tuple(range(arr.ndim))
     if not isinstance(axis, tuple):
         axis = (axis,)
     items = 1
diff --git a/lib_pypy/numpypy/core/arrayprint.py 
b/lib_pypy/numpypy/core/arrayprint.py
--- a/lib_pypy/numpypy/core/arrayprint.py
+++ b/lib_pypy/numpypy/core/arrayprint.py
@@ -13,10 +13,10 @@
 # and by Travis Oliphant  2005-8-22 for numpy
 
 import sys
-import numerictypes as _nt
-from umath import maximum, minimum, absolute, not_equal, isnan, isinf
+from . import numerictypes as _nt
+from .umath import maximum, minimum, absolute, not_equal, isnan, isinf
 #from multiarray import format_longfloat, datetime_as_string, datetime_data
-from fromnumeric import ravel
+from .fromnumeric import ravel
 
 
 def product(x, y): return x*y
@@ -194,7 +194,7 @@
     return d
 
 def _leading_trailing(a):
-    import numeric as _nc
+    from . import numeric as _nc
     if a.ndim == 1:
         if len(a) > 2*_summaryEdgeItems:
             b = _nc.concatenate((a[:_summaryEdgeItems],
@@ -258,9 +258,9 @@
                   'str' : str}
 
     if formatter is not None:
-        fkeys = [k for k in formatter.keys() if formatter[k] is not None]
+        fkeys = [k for k in list(formatter.keys()) if formatter[k] is not None]
         if 'all' in fkeys:
-            for key in formatdict.keys():
+            for key in list(formatdict.keys()):
                 formatdict[key] = formatter['all']
         if 'int_kind' in fkeys:
             for key in ['int']:
@@ -274,7 +274,7 @@
         if 'str_kind' in fkeys:
             for key in ['numpystr', 'str']:
                 formatdict[key] = formatter['str_kind']
-        for key in formatdict.keys():
+        for key in list(formatdict.keys()):
             if key in fkeys:
                 formatdict[key] = formatter[key]
 
@@ -322,7 +322,7 @@
     return lst
 
 def _convert_arrays(obj):
-    import numeric as _nc
+    from . import numeric as _nc
     newtup = []
     for k in obj:
         if isinstance(k, _nc.ndarray):
@@ -478,14 +478,14 @@
     if rank == 1:
         s = ""
         line = next_line_prefix
-        for i in xrange(leading_items):
+        for i in range(leading_items):
             word = format_function(a[i]) + separator
             s, line = _extendLine(s, line, word, max_line_len, 
next_line_prefix)
 
         if summary_insert1:
             s, line = _extendLine(s, line, summary_insert1, max_line_len, 
next_line_prefix)
 
-        for i in xrange(trailing_items, 1, -1):
+        for i in range(trailing_items, 1, -1):
             word = format_function(a[-i]) + separator
             s, line = _extendLine(s, line, word, max_line_len, 
next_line_prefix)
 
@@ -496,7 +496,7 @@
     else:
         s = '['
         sep = separator.rstrip()
-        for i in xrange(leading_items):
+        for i in range(leading_items):
             if i > 0:
                 s += next_line_prefix
             s += _formatArray(a[i], format_function, rank-1, max_line_len,
@@ -507,7 +507,7 @@
         if summary_insert1:
             s += next_line_prefix + summary_insert1 + "\n"
 
-        for i in xrange(trailing_items, 1, -1):
+        for i in range(trailing_items, 1, -1):
             if leading_items or i != trailing_items:
                 s += next_line_prefix
             s += _formatArray(a[-i], format_function, rank-1, max_line_len,
@@ -537,7 +537,7 @@
             pass
 
     def fillFormat(self, data):
-        import numeric as _nc
+        from . import numeric as _nc
         errstate = _nc.seterr(all='ignore')
         try:
             special = isnan(data) | isinf(data)
@@ -590,7 +590,7 @@
         self.format = format
 
     def __call__(self, x, strip_zeros=True):
-        import numeric as _nc
+        from . import numeric as _nc
         err = _nc.seterr(invalid='ignore')
         try:
             if isnan(x):
diff --git a/lib_pypy/numpypy/core/fromnumeric.py 
b/lib_pypy/numpypy/core/fromnumeric.py
--- a/lib_pypy/numpypy/core/fromnumeric.py
+++ b/lib_pypy/numpypy/core/fromnumeric.py
@@ -4,7 +4,7 @@
 """Module containing non-deprecated functions borrowed from Numeric.
 
 """
-from __future__ import division, absolute_import, print_function
+
 
 import types
 
diff --git a/lib_pypy/numpypy/core/numeric.py b/lib_pypy/numpypy/core/numeric.py
--- a/lib_pypy/numpypy/core/numeric.py
+++ b/lib_pypy/numpypy/core/numeric.py
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import, print_function
+
 
 __all__ = [
            'newaxis', 'ufunc', 'argwhere',
@@ -27,7 +27,7 @@
     try:
         mall = getattr(module, '__all__')
     except AttributeError:
-        mall = [k for k in module.__dict__.keys() if not k.startswith('_')]
+        mall = [k for k in list(module.__dict__.keys()) if not 
k.startswith('_')]
     for a in mall:
         if a not in adict:
             __all__.append(a)
diff --git a/lib_pypy/numpypy/core/numerictypes.py 
b/lib_pypy/numpypy/core/numerictypes.py
--- a/lib_pypy/numpypy/core/numerictypes.py
+++ b/lib_pypy/numpypy/core/numerictypes.py
@@ -83,7 +83,7 @@
      \\-> object_ (not used much)                (kind=O)
 
 """
-from __future__ import division, absolute_import, print_function
+
 
 # we add more at the bottom
 __all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes',
@@ -102,9 +102,9 @@
 # as numerictypes.bool, etc.
 if sys.version_info[0] >= 3:
     from builtins import bool, int, float, complex, object, str
-    unicode = str
+    str = str
 else:
-    from __builtin__ import bool, int, float, complex, object, unicode, str
+    from builtins import bool, int, float, complex, object, str, str
 
 
 # String-handling utilities to avoid locale-dependence.
@@ -285,7 +285,7 @@
 
 
 def _add_types():
-    for a in typeinfo.keys():
+    for a in list(typeinfo.keys()):
         name = english_lower(a)
         if isinstance(typeinfo[a], tuple):
             typeobj = typeinfo[a][-1]
@@ -301,7 +301,7 @@
 _add_types()
 
 def _add_aliases():
-    for a in typeinfo.keys():
+    for a in list(typeinfo.keys()):
         name = english_lower(a)
         if not isinstance(typeinfo[a], tuple):
             continue
@@ -312,7 +312,7 @@
         if base != '':
             myname = "%s%d" % (base, bit)
             if (name != 'longdouble' and name != 'clongdouble') or \
-                   myname not in allTypes.keys():
+                   myname not in list(allTypes.keys()):
                 allTypes[myname] = typeobj
                 sctypeDict[myname] = typeobj
                 if base == 'complex':
@@ -354,7 +354,7 @@
         uval = typeinfo['U'+ctype]
         typeobj = val[-1]
         utypeobj = uval[-1]
-        if intname not in allTypes.keys():
+        if intname not in list(allTypes.keys()):
             uintname = 'uint%d' % bits
             allTypes[intname] = typeobj
             allTypes[uintname] = utypeobj
@@ -432,7 +432,7 @@
 # Now, construct dictionary to lookup character codes from types
 _sctype2char_dict = {}
 def _construct_char_code_lookup():
-    for name in typeinfo.keys():
+    for name in list(typeinfo.keys()):
         tup = typeinfo[name]
         if isinstance(tup, tuple):
             if tup[0] not in ['p', 'P']:
@@ -444,7 +444,7 @@
            'uint':[],
            'float':[],
            'complex':[],
-           'others':[bool, object, str, unicode, void]}
+           'others':[bool, object, str, str, void]}
 
 def _add_array_type(typename, bits):
     try:
@@ -545,7 +545,7 @@
                  complex: 'complex_',
                  bool: 'bool_',
                  bytes: 'bytes_',
-                 unicode: 'unicode_',
+                 str: 'unicode_',
                  buffer_type: 'void',
                 }
 
@@ -784,7 +784,7 @@
 _maxvals = _typedict()
 _minvals = _typedict()
 def _construct_lookups():
-    for name, val in typeinfo.items():
+    for name, val in list(typeinfo.items()):
         if not isinstance(val, tuple):
             continue
         obj = val[-1]
@@ -859,21 +859,21 @@
     # Py3K
     ScalarType = [int, float, complex, int, bool, bytes, str, memoryview]
 
-ScalarType.extend(_sctype2char_dict.keys())
+ScalarType.extend(list(_sctype2char_dict.keys()))
 ScalarType = tuple(ScalarType)
-for key in _sctype2char_dict.keys():
+for key in list(_sctype2char_dict.keys()):
     cast[key] = lambda x, k=key : array(x, copy=False).astype(k)
 
 # Create the typestring lookup dictionary
 _typestr = _typedict()
-for key in _sctype2char_dict.keys():
+for key in list(_sctype2char_dict.keys()):
     if issubclass(key, allTypes['flexible']):
         _typestr[key] = _sctype2char_dict[key]
     else:
         _typestr[key] = empty((1,), key).dtype.str[1:]
 
 # Make sure all typestrings are in sctypeDict
-for key, val in _typestr.items():
+for key, val in list(_typestr.items()):
     if val not in sctypeDict:
         sctypeDict[val] = key
 
diff --git a/lib_pypy/numpypy/core/shape_base.py 
b/lib_pypy/numpypy/core/shape_base.py
--- a/lib_pypy/numpypy/core/shape_base.py
+++ b/lib_pypy/numpypy/core/shape_base.py
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import, print_function
+
 
 __all__ = ['atleast_1d', 'atleast_2d', 'atleast_3d', 'vstack', 'hstack']
 
diff --git a/lib_pypy/numpypy/lib/__init__.py b/lib_pypy/numpypy/lib/__init__.py
--- a/lib_pypy/numpypy/lib/__init__.py
+++ b/lib_pypy/numpypy/lib/__init__.py
@@ -1,4 +1,4 @@
-from __future__ import division, absolute_import, print_function
+
 
 import math
 
diff --git a/lib_pypy/numpypy/lib/shape_base.py 
b/lib_pypy/numpypy/lib/shape_base.py
--- a/lib_pypy/numpypy/lib/shape_base.py
+++ b/lib_pypy/numpypy/lib/shape_base.py
@@ -51,4 +51,4 @@
            [[3, 4]]])
 
     """
-    return _nx.concatenate(map(atleast_3d,tup),2)
+    return _nx.concatenate(list(map(atleast_3d,tup)),2)
diff --git a/lib_pypy/numpypy/lib/ufunclike.py 
b/lib_pypy/numpypy/lib/ufunclike.py
--- a/lib_pypy/numpypy/lib/ufunclike.py
+++ b/lib_pypy/numpypy/lib/ufunclike.py
@@ -3,7 +3,7 @@
 storing results in an output array.
 
 """
-from __future__ import division, absolute_import, print_function
+
 
 __all__ = ['fix', 'isneginf', 'isposinf']
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to