diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-04-12 20:10:58 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-04-12 21:22:36 -0600 |
commit | 5de56efaad908f2b731a7eda2b9ca2a9196f820a (patch) | |
tree | 4e889cf226ba5b1ff3c708bfcd349352bfe76b96 /numpy/lib/recfunctions.py | |
parent | 06066cb01962819c9590d87ea57c77db2a306266 (diff) | |
download | numpy-5de56efaad908f2b731a7eda2b9ca2a9196f820a.tar.gz |
2to3: Apply itertools fixer.
In Python 3 zip, map, and filter are all iterators, consequently the
itertools variants izip, imap, and ifilter have been removed and the
itertools fixer replaces them with the unprefixed names.
Because the places where the iterator variants are used in current look
like places where the iterator version might be useful, the approach
taken here is to define the prefixed versions to the unprefixed versions
for Python 3, but otherwise import them from itertools.
Closes #3233.
Diffstat (limited to 'numpy/lib/recfunctions.py')
-rw-r--r-- | numpy/lib/recfunctions.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index f909a4838..349d1996e 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -16,6 +16,11 @@ from numpy.ma import MaskedArray from numpy.ma.mrecords import MaskedRecords from numpy.lib._iotools import _is_string_like +if sys.version_info[0] >= 3: + izip = zip +else: + izip = itertools.izip + _check_fill_value = np.ma.core._check_fill_value __all__ = ['append_fields', @@ -287,7 +292,7 @@ def izip_records(seqarrays, fill_value=None, flatten=True): zipfunc = _izip_fields # try: - for tup in itertools.izip(*iters): + for tup in izip(*iters): yield tuple(zipfunc(tup)) except IndexError: pass @@ -412,7 +417,7 @@ def merge_arrays(seqarrays, seqmask = [] # If we expect some kind of MaskedArray, make a special loop. if usemask: - for (a, n) in itertools.izip(seqarrays, sizes): + for (a, n) in izip(seqarrays, sizes): nbmissing = (maxlength - n) # Get the data and mask data = a.ravel().__array__() @@ -441,7 +446,7 @@ def merge_arrays(seqarrays, output = output.view(MaskedRecords) else: # Same as before, without the mask we don't need... - for (a, n) in itertools.izip(seqarrays, sizes): + for (a, n) in izip(seqarrays, sizes): nbmissing = (maxlength - n) data = a.ravel().__array__() if nbmissing: |