Skip to content

Commit

Permalink
Merge pull request #3236 from charris/2to3-apply-itertools
Browse files Browse the repository at this point in the history
2to3: Apply itertools fixer.
  • Loading branch information
njsmith committed Apr 13, 2013
2 parents 06066cb + 5de56ef commit 74b08b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion numpy/lib/npyio.py
Expand Up @@ -24,8 +24,10 @@

if sys.version_info[0] >= 3:
import pickle
imap = map
else:
import cPickle as pickle
imap = itertools.imap

loads = pickle.loads

Expand Down Expand Up @@ -1607,7 +1609,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
converter.iterupgrade(current_column)
except ConverterLockError:
errmsg = "Converter #%i is locked and cannot be upgraded: " % i
current_column = itertools.imap(itemgetter(i), rows)
current_column = imap(itemgetter(i), rows)
for (j, value) in enumerate(current_column):
try:
converter.upgrade(value)
Expand Down
11 changes: 8 additions & 3 deletions numpy/lib/recfunctions.py
Expand Up @@ -16,6 +16,11 @@
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',
Expand Down Expand Up @@ -287,7 +292,7 @@ def sentinel(counter=([fill_value] * (len(seqarrays) - 1)).pop):
zipfunc = _izip_fields
#
try:
for tup in itertools.izip(*iters):
for tup in izip(*iters):
yield tuple(zipfunc(tup))
except IndexError:
pass
Expand Down Expand Up @@ -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__()
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tools/py3tool.py
Expand Up @@ -65,8 +65,8 @@
'input',
'intern',
# 'isinstance',
# 'itertools',
'itertools_imports',
'itertools',
# 'long',
'map',
'metaclass',
Expand Down

0 comments on commit 74b08b3

Please sign in to comment.