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/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'numpy/lib/utils.py') diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 2519cd4d4..f94abeeab 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -435,7 +435,7 @@ def _makenamedict(module='numpy'): thedict = {module.__name__:module.__dict__} dictlist = [module.__name__] totraverse = [module.__dict__] - while 1: + while True: if len(totraverse) == 0: break thisdict = totraverse.pop(0) @@ -584,7 +584,7 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'): methstr, other = pydoc.splitdoc(inspect.getdoc(thisobj) or "None") print(" %s -- %s" % (meth, methstr), file=output) - elif type(object) is types.InstanceType: ## check for __call__ method + elif isinstance(object, types.InstanceType): ## check for __call__ method print("Instance of class: ", object.__class__.__name__, file=output) print(file=output) if hasattr(object, '__call__'): -- cgit v1.2.1