From dec4f4b76ae9b2b953bcc093275aa59f93adf6fd Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Fri, 26 Apr 2013 21:31:12 -0600 Subject: 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. --- numpy/lib/index_tricks.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'numpy/lib/index_tricks.py') diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 314cba120..b3c9b72bc 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -244,7 +244,7 @@ class AxisConcatenator(object): frame = sys._getframe().f_back mymat = matrix.bmat(key,frame.f_globals,frame.f_locals) return mymat - if type(key) is not tuple: + if not isinstance(key, tuple): key = (key,) objs = [] scalars = [] @@ -252,7 +252,7 @@ class AxisConcatenator(object): scalartypes = [] 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 @@ -627,7 +627,7 @@ class IndexExpression(object): self.maketuple = maketuple def __getitem__(self, item): - if self.maketuple and type(item) != tuple: + if self.maketuple and not isinstance(item, tuple): return (item,) else: return item -- cgit v1.2.1