diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-13 09:36:36 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-13 10:16:40 -0600 |
commit | ffdad17d0db1d55d39911d637c650ea0acada78b (patch) | |
tree | 1bae8a9e699c698f723bbd8d8e989361000f2a13 /numpy/oldnumeric/ma.py | |
parent | 688bc60658b391524c6b641e0a5e5ecd73322d02 (diff) | |
download | numpy-ffdad17d0db1d55d39911d637c650ea0acada78b.tar.gz |
2to3: Apply renames fixer.
Rename sys.maxint to sys.maxsize when the Python version is >= 3. This
change was made in Python 3 because all integers are 'long' integers and
their maximum value bears no relationship to the C type that int used to
represent. The new sys.maxsize value is the maximum value of Py_ssize_t.
This change has not led to any reported problems since the numpy 1.5
release.
Closes #3082
Diffstat (limited to 'numpy/oldnumeric/ma.py')
-rw-r--r-- | numpy/oldnumeric/ma.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/numpy/oldnumeric/ma.py b/numpy/oldnumeric/ma.py index cdec74cab..05a4480af 100644 --- a/numpy/oldnumeric/ma.py +++ b/numpy/oldnumeric/ma.py @@ -11,7 +11,10 @@ Adapted for numpy_core 2005 by Travis Oliphant and """ from __future__ import division, absolute_import, print_function -import types, sys +import sys +import types +import warnings +from functools import reduce import numpy.core.umath as umath import numpy.core.fromnumeric as fromnumeric @@ -19,8 +22,13 @@ from numpy.core.numeric import newaxis, ndarray, inf from numpy.core.fromnumeric import amax, amin from numpy.core.numerictypes import bool_, typecodes import numpy.core.numeric as numeric -import warnings -from functools import reduce + +if sys.version_info[0] >= 3: + _MAXINT = sys.maxsize + _MININT = -sys.maxsize - 1 +else: + _MAXINT = sys.maxint + _MININT = -sys.maxint - 1 # Ufunc domain lookup for __array_wrap__ @@ -114,15 +122,15 @@ def minimum_fill_value (obj): if isinstance(obj, types.FloatType): return numeric.inf elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType): - return sys.maxint + return _MAXINT elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray): x = obj.dtype.char if x in typecodes['Float']: return numeric.inf if x in typecodes['Integer']: - return sys.maxint + return _MAXINT if x in typecodes['UnsignedInteger']: - return sys.maxint + return _MAXINT else: raise TypeError('Unsuitable type for calculating minimum.') @@ -131,13 +139,13 @@ def maximum_fill_value (obj): if isinstance(obj, types.FloatType): return -inf elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType): - return -sys.maxint + return -_MAXINT elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray): x = obj.dtype.char if x in typecodes['Float']: return -inf if x in typecodes['Integer']: - return -sys.maxint + return -_MAXINT if x in typecodes['UnsignedInteger']: return 0 else: |