diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-26 21:31:12 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-05-02 21:13:17 -0600 |
commit | dec4f4b76ae9b2b953bcc093275aa59f93adf6fd (patch) | |
tree | 13a9a50d087f6c55a6afb942437afc99110cd6f5 /numpy/f2py/rules.py | |
parent | 63a9f197d040b5479b772fd3925274fc984ffd24 (diff) | |
download | numpy-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/f2py/rules.py')
-rw-r--r-- | numpy/f2py/rules.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/f2py/rules.py b/numpy/f2py/rules.py index a76401ac9..f7f82fc99 100644 --- a/numpy/f2py/rules.py +++ b/numpy/f2py/rules.py @@ -1388,9 +1388,9 @@ def buildapi(rout): vrd['check']=c ar=applyrules(check_rules,vrd,var[a]) rd=dictappend(rd,ar) - if type(rd['cleanupfrompyobj']) is list: + if isinstance(rd['cleanupfrompyobj'], list): rd['cleanupfrompyobj'].reverse() - if type(rd['closepyobjfrom']) is list: + if isinstance(rd['closepyobjfrom'], list): rd['closepyobjfrom'].reverse() rd['docsignature']=stripcomma(replace('#docsign##docsignopt##docsignxa#', {'docsign':rd['docsign'], @@ -1415,15 +1415,15 @@ def buildapi(rout): else: rd['callcompaqfortran']=cfs rd['callfortran']=cfs - if type(rd['docreturn'])==list: + if isinstance(rd['docreturn'], list): rd['docreturn']=stripcomma(replace('#docreturn#',{'docreturn':rd['docreturn']}))+' = ' rd['docstrsigns']=[] rd['latexdocstrsigns']=[] for k in ['docstrreq','docstropt','docstrout','docstrcbs']: - if k in rd and type(rd[k])==list: + if k in rd and isinstance(rd[k], list): rd['docstrsigns']=rd['docstrsigns']+rd[k] k='latex'+k - if k in rd and type(rd[k])==list: + if k in rd and isinstance(rd[k], list): rd['latexdocstrsigns']=rd['latexdocstrsigns']+rd[k][0:1]+\ ['\\begin{description}']+rd[k][1:]+\ ['\\end{description}'] |