summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.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/ma/extras.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/ma/extras.py')
-rw-r--r--numpy/ma/extras.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index 861fefad0..2f3159c49 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -1435,14 +1435,14 @@ class MAxisConcatenator(AxisConcatenator):
def __getitem__(self, key):
if isinstance(key, str):
raise MAError("Unavailable for masked array.")
- if type(key) is not tuple:
+ if not isinstance(key, tuple):
key = (key,)
objs = []
scalars = []
final_dtypedescr = None
for k in range(len(key)):
scalar = False
- if type(key[k]) is slice:
+ if isinstance(key[k], slice):
step = key[k].step
start = key[k].start
stop = key[k].stop
@@ -1450,12 +1450,12 @@ class MAxisConcatenator(AxisConcatenator):
start = 0
if step is None:
step = 1
- if type(step) is type(1j):
+ if isinstance(step, complex):
size = int(abs(step))
newobj = np.linspace(start, stop, num=size)
else:
newobj = np.arange(start, stop, step)
- elif type(key[k]) is str:
+ elif isinstance(key[k], str):
if (key[k] in 'rc'):
self.matrix = True
self.col = (key[k] == 'c')