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/numarray | |
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/numarray')
-rw-r--r-- | numpy/numarray/alter_code1.py | 2 | ||||
-rw-r--r-- | numpy/numarray/functions.py | 2 | ||||
-rw-r--r-- | numpy/numarray/session.py | 4 |
3 files changed, 4 insertions, 4 deletions
diff --git a/numpy/numarray/alter_code1.py b/numpy/numarray/alter_code1.py index 4c5b7e9fc..a80a5ae3c 100644 --- a/numpy/numarray/alter_code1.py +++ b/numpy/numarray/alter_code1.py @@ -81,7 +81,7 @@ def changeimports(fstr, name, newname): ind = 0 Nlen = len(fromstr) Nlen2 = len("from %s import " % newname) - while 1: + while True: found = fstr.find(fromstr,ind) if (found < 0): break diff --git a/numpy/numarray/functions.py b/numpy/numarray/functions.py index 3f91046d2..78d05e5f5 100644 --- a/numpy/numarray/functions.py +++ b/numpy/numarray/functions.py @@ -222,7 +222,7 @@ def fromfile(infile, type=None, shape=None, sizing=STRICT, buf = np.newbuffer(initsize) bytesread=0 - while 1: + while True: data=infile.read(blocksize) if len(data) != blocksize: ##eof break diff --git a/numpy/numarray/session.py b/numpy/numarray/session.py index f1dcbfbdc..e40cd4033 100644 --- a/numpy/numarray/session.py +++ b/numpy/numarray/session.py @@ -120,7 +120,7 @@ def _callers_modules(): g = _callers_globals() mods = [] for k,v in g.items(): - if type(v) == type(sys): + if isinstance(v, type(sys)): mods.append(getattr(v,"__name__")) return mods @@ -326,7 +326,7 @@ def load(variables=None, file=SAVEFILE, dictionary=None, verbose=False): dictionary = _callers_globals() values = [] p = pickle.Unpickler(file) - while 1: + while True: o = p.load() if isinstance(o, _SaveSession): session = dict(zip(o.keys, values)) |