summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-04-11 14:31:52 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-04-13 07:43:56 -0600
commit7f5af37e26ba2e99ad3ee6928b78437f601e96e0 (patch)
tree1b210bb7361ce691e781884bf06f89c7ebd13360 /numpy/core
parent74b08b3f0284d9d2dd55a15dd98a3846913b1b51 (diff)
downloadnumpy-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/core')
-rw-r--r--numpy/core/defchararray.py2
-rw-r--r--numpy/core/getlimits.py6
-rw-r--r--numpy/core/memmap.py3
-rw-r--r--numpy/core/numerictypes.py22
-rw-r--r--numpy/core/records.py2
-rw-r--r--numpy/core/tests/test_regression.py2
-rw-r--r--numpy/core/tests/test_shape_base.py3
7 files changed, 19 insertions, 21 deletions
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index d5acb1e97..874a295ef 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -22,7 +22,7 @@ from .numerictypes import string_, unicode_, integer, object_, bool_, character
from .numeric import ndarray, compare_chararrays
from .numeric import array as narray
from numpy.core.multiarray import _vec_string
-from numpy.compat import asbytes
+from numpy.compat import asbytes, long
import numpy
__all__ = ['chararray',
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py
index 57ad60543..93210a23b 100644
--- a/numpy/core/getlimits.py
+++ b/numpy/core/getlimits.py
@@ -260,7 +260,7 @@ class iinfo(object):
try:
val = iinfo._min_vals[self.key]
except KeyError:
- val = int(-(1L << (self.bits-1)))
+ val = int(-(1 << (self.bits-1)))
iinfo._min_vals[self.key] = val
return val
@@ -272,9 +272,9 @@ class iinfo(object):
val = iinfo._max_vals[self.key]
except KeyError:
if self.kind == 'u':
- val = int((1L << self.bits) - 1)
+ val = int((1 << self.bits) - 1)
else:
- val = int((1L << (self.bits-1)) - 1)
+ val = int((1 << (self.bits-1)) - 1)
iinfo._max_vals[self.key] = val
return val
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index ee079157d..0ac153a74 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -3,10 +3,11 @@ from __future__ import division, absolute_import, print_function
__all__ = ['memmap']
import warnings
-from .numeric import uint8, ndarray, dtype
import sys
import numpy as np
+from .numeric import uint8, ndarray, dtype
+from numpy.compat import long
dtypedescr = dtype
valid_filemodes = ["r", "c", "r+", "w+"]
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 65f0943c8..e164427af 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -90,26 +90,22 @@ __all__ = ['sctypeDict', 'sctypeNA', 'typeDict', 'typeNA', 'sctypes',
'busday_offset', 'busday_count', 'is_busday', 'busdaycalendar',
]
-from numpy.core.multiarray import typeinfo, ndarray, array, \
- empty, dtype, datetime_data, datetime_as_string, \
- busday_offset, busday_count, is_busday, busdaycalendar
+from numpy.core.multiarray import (
+ typeinfo, ndarray, array, empty, dtype, datetime_data,
+ datetime_as_string, busday_offset, busday_count, is_busday,
+ busdaycalendar
+ )
import types as _types
import sys
+from numpy.compat import bytes, long
# we don't export these for import *, but we do want them accessible
# as numerictypes.bool, etc.
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 bytes
-
-if sys.version_info[0] >= 3:
- # Py3K
- class long(int):
- # Placeholder class -- this will not escape outside numerictypes.py
- pass
# String-handling utilities to avoid locale-dependence.
@@ -861,7 +857,7 @@ try:
_types.StringType, _types.UnicodeType, _types.BufferType]
except AttributeError:
# Py3K
- ScalarType = [int, float, complex, long, bool, bytes, str, memoryview]
+ ScalarType = [int, float, complex, int, bool, bytes, str, memoryview]
ScalarType.extend(_sctype2char_dict.keys())
ScalarType = tuple(ScalarType)
diff --git a/numpy/core/records.py b/numpy/core/records.py
index b263adb6a..4f520ae66 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -46,7 +46,7 @@ import types
import os
import sys
-from numpy.compat import isfileobj, bytes
+from numpy.compat import isfileobj, bytes, long
ndarray = sb.ndarray
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index fe2185833..d22868999 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -17,7 +17,7 @@ from numpy.testing import (
assert_raises, assert_warns, dec
)
from numpy.testing.utils import _assert_valid_refcount, WarningManager
-from numpy.compat import asbytes, asunicode, asbytes_nested
+from numpy.compat import asbytes, asunicode, asbytes_nested, long
rlevel = 1
diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py
index 1f261375f..8cbcfede3 100644
--- a/numpy/core/tests/test_shape_base.py
+++ b/numpy/core/tests/test_shape_base.py
@@ -6,6 +6,7 @@ from numpy.testing import (TestCase, assert_, assert_raises, assert_array_equal,
assert_equal, run_module_suite)
from numpy.core import (array, arange, atleast_1d, atleast_2d, atleast_3d,
vstack, hstack, newaxis, concatenate)
+from numpy.compat import long
class TestAtleast1d(TestCase):
def test_0D_array(self):
@@ -43,7 +44,7 @@ class TestAtleast1d(TestCase):
"""
assert_(atleast_1d(3).shape == (1,))
assert_(atleast_1d(3j).shape == (1,))
- assert_(atleast_1d(3L).shape == (1,))
+ assert_(atleast_1d(long(3)).shape == (1,))
assert_(atleast_1d(3.0).shape == (1,))
assert_(atleast_1d([[2,3],[4,5]]).shape == (2,2))