diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-11 14:31:52 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-13 07:43:56 -0600 |
commit | 7f5af37e26ba2e99ad3ee6928b78437f601e96e0 (patch) | |
tree | 1b210bb7361ce691e781884bf06f89c7ebd13360 /numpy/lib | |
parent | 74b08b3f0284d9d2dd55a15dd98a3846913b1b51 (diff) | |
download | numpy-7f5af37e26ba2e99ad3ee6928b78437f601e96e0.tar.gz |
2to3: Apply the `numliterals` fixer and skip the `long` fixer.
The numliterals fixer replaces the old style octal number like '01' by
'0o1' removes the 'L' suffix.
Octal values were previously mistakenly specified in some dates, those
uses have been corrected by removing the leading zeros.
Simply Removing the 'L' suffix should not be a problem, but in some
testing code it looks neccesary, so in those places the Python long
constructor is used instead.
The 'long' type is no longer defined in Python 3. Because we need to
have it defined for Python 2 it is added to numpy/compat/np3k.py where
it is defined as 'int' for Python 3 and 'long' for Python 2. The `long`
fixer then needs to be skipped so that it doesn't undo the good work.
Closes #3074, #3067.
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/_iotools.py | 6 | ||||
-rw-r--r-- | numpy/lib/arraypad.py | 1 | ||||
-rw-r--r-- | numpy/lib/arrayterator.py | 6 | ||||
-rw-r--r-- | numpy/lib/format.py | 2 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 1 | ||||
-rw-r--r-- | numpy/lib/tests/test__datasource.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test__iotools.py | 6 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 1 | ||||
-rw-r--r-- | numpy/lib/tests/test_type_check.py | 4 | ||||
-rw-r--r-- | numpy/lib/user_array.py | 11 |
10 files changed, 24 insertions, 16 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index 9eaf4d78f..dc143415e 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -10,11 +10,11 @@ import numpy as np import numpy.core.numeric as nx if sys.version_info[0] >= 3: - from builtins import bool, int, long, float, complex, object, unicode, str + from builtins import bool, int, float, complex, object, unicode, str else: - from __builtin__ import bool, int, long, float, complex, object, unicode, str + from __builtin__ import bool, int, float, complex, object, unicode, str -from numpy.compat import asbytes, bytes, asbytes_nested +from numpy.compat import asbytes, bytes, asbytes_nested, long if sys.version_info[0] >= 3: def _bytes_to_complex(s): diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index 8a7c3a067..112a8dae9 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -6,6 +6,7 @@ of an n-dimensional array. from __future__ import division, absolute_import, print_function import numpy as np +from numpy.compat import long __all__ = ['pad'] diff --git a/numpy/lib/arrayterator.py b/numpy/lib/arrayterator.py index 761d63749..094d41c11 100644 --- a/numpy/lib/arrayterator.py +++ b/numpy/lib/arrayterator.py @@ -9,12 +9,14 @@ a user-specified number of elements. """ from __future__ import division, absolute_import, print_function +import sys from operator import mul +from functools import reduce + +from numpy.compat import long __all__ = ['Arrayterator'] -import sys -from functools import reduce class Arrayterator(object): """ diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 886ba45b3..17f3463ad 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -139,7 +139,7 @@ from __future__ import division, absolute_import, print_function import numpy import sys from numpy.lib.utils import safe_eval -from numpy.compat import asbytes, isfileobj +from numpy.compat import asbytes, isfileobj, long if sys.version_info[0] >= 3: import pickle diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 43bd3af8b..399f761ba 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -32,6 +32,7 @@ from .utils import deprecate from ._compiled_base import add_newdoc_ufunc import numpy as np import collections +from numpy.compat import long # Force range to be a generator, for np.delete's usage. if sys.version_info[0] < 3: diff --git a/numpy/lib/tests/test__datasource.py b/numpy/lib/tests/test__datasource.py index beb252186..3933fdcde 100644 --- a/numpy/lib/tests/test__datasource.py +++ b/numpy/lib/tests/test__datasource.py @@ -305,7 +305,7 @@ class TestRepositoryExists(TestCase): # would do. scheme, netloc, upath, pms, qry, frg = urlparse(localfile) local_path = os.path.join(self.repos._destpath, netloc) - os.mkdir(local_path, 0700) + os.mkdir(local_path, 0o0700) tmpfile = valid_textfile(local_path) assert_(self.repos.exists(tmpfile)) diff --git a/numpy/lib/tests/test__iotools.py b/numpy/lib/tests/test__iotools.py index 63d0ac2ef..421616ccd 100644 --- a/numpy/lib/tests/test__iotools.py +++ b/numpy/lib/tests/test__iotools.py @@ -175,11 +175,11 @@ class TestStringConverter(TestCase): StringConverter.upgrade_mapper(dateparser, date(2000, 1, 1)) convert = StringConverter(dateparser, date(2000, 1, 1)) test = convert(asbytes('2001-01-01')) - assert_equal(test, date(2001, 01, 01)) + assert_equal(test, date(2001, 1, 1)) test = convert(asbytes('2009-01-01')) - assert_equal(test, date(2009, 01, 01)) + assert_equal(test, date(2009, 1, 1)) test = convert(asbytes('')) - assert_equal(test, date(2000, 01, 01)) + assert_equal(test, date(2000, 1, 1)) # def test_string_to_object(self): "Make sure that string-to-object functions are properly recognized" diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index ae68be41f..ca329aae6 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -9,6 +9,7 @@ from numpy.testing import ( ) from numpy.random import rand from numpy.lib import * +from numpy.compat import long class TestAny(TestCase): diff --git a/numpy/lib/tests/test_type_check.py b/numpy/lib/tests/test_type_check.py index 280d0b174..25e697924 100644 --- a/numpy/lib/tests/test_type_check.py +++ b/numpy/lib/tests/test_type_check.py @@ -3,7 +3,7 @@ from __future__ import division, absolute_import, print_function from numpy.testing import * from numpy.lib import * from numpy.core import * -from numpy.compat import asbytes +from numpy.compat import asbytes, long try: import ctypes @@ -87,7 +87,7 @@ class TestIsscalar(TestCase): assert_(not isscalar([3])) assert_(not isscalar((3,))) assert_(isscalar(3j)) - assert_(isscalar(10L)) + assert_(isscalar(long(10))) assert_(isscalar(4.0)) diff --git a/numpy/lib/user_array.py b/numpy/lib/user_array.py index 1cc1345aa..d675d3702 100644 --- a/numpy/lib/user_array.py +++ b/numpy/lib/user_array.py @@ -6,10 +6,13 @@ complete. """ from __future__ import division, absolute_import, print_function -from numpy.core import array, asarray, absolute, add, subtract, multiply, \ - divide, remainder, power, left_shift, right_shift, bitwise_and, \ - bitwise_or, bitwise_xor, invert, less, less_equal, not_equal, equal, \ - greater, greater_equal, shape, reshape, arange, sin, sqrt, transpose +from numpy.core import ( + array, asarray, absolute, add, subtract, multiply, divide, + remainder, power, left_shift, right_shift, bitwise_and, bitwise_or, + bitwise_xor, invert, less, less_equal, not_equal, equal, greater, + greater_equal, shape, reshape, arange, sin, sqrt, transpose + ) +from numpy.compat import long class container(object): def __init__(self, data, dtype=None, copy=True): |