summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-04-26 21:31:12 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-05-02 21:13:17 -0600
commitdec4f4b76ae9b2b953bcc093275aa59f93adf6fd (patch)
tree13a9a50d087f6c55a6afb942437afc99110cd6f5 /numpy/core/fromnumeric.py
parent63a9f197d040b5479b772fd3925274fc984ffd24 (diff)
downloadnumpy-dec4f4b76ae9b2b953bcc093275aa59f93adf6fd.tar.gz
MAINT: Apply 2to3 idioms fixer.
The idioms fixer makes the following replacements. 1) int <- bool 2) comparison or identity of types <- isinstance 3) a.sort() <- sorted(a) There were two problems that needed to be dealt with after the application of the fixer. First, the replacement of comparison or identity of types by isinstance was not always correct. The isinstance function returns true for subtypes whereas many of the places where the fixer made a substitution needed to check for exact type equality. Second, the sorted function was applied to arrays, but because it treats them as iterators and constructs a sorted list from the result, that is the wrong thing to do. Closes #3062.
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py
index ba89637eb..c34348e22 100644
--- a/numpy/core/fromnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -1552,7 +1552,7 @@ def sum(a, axis=None, dtype=None, out=None, keepdims=False):
out[...] = res
return out
return res
- elif not (type(a) is mu.ndarray):
+ elif type(a) is not mu.ndarray:
try:
sum = a.sum
except AttributeError:
@@ -1953,7 +1953,7 @@ def amax(a, axis=None, out=None, keepdims=False):
4.0
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
amax = a.max
except AttributeError:
@@ -2024,7 +2024,7 @@ def amin(a, axis=None, out=None, keepdims=False):
0.0
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
amin = a.min
except AttributeError:
@@ -2154,7 +2154,7 @@ def prod(a, axis=None, dtype=None, out=None, keepdims=False):
True
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
prod = a.prod
except AttributeError:
@@ -2527,7 +2527,7 @@ def mean(a, axis=None, dtype=None, out=None, keepdims=False):
0.55000000074505806
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
mean = a.mean
return mean(axis=axis, dtype=dtype, out=out)
@@ -2629,7 +2629,7 @@ def std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
0.44999999925552653
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
std = a.std
return std(axis=axis, dtype=dtype, out=out, ddof=ddof)
@@ -2732,7 +2732,7 @@ def var(a, axis=None, dtype=None, out=None, ddof=0,
0.20250000000000001
"""
- if not (type(a) is mu.ndarray):
+ if type(a) is not mu.ndarray:
try:
var = a.var
return var(axis=axis, dtype=dtype, out=out, ddof=ddof)