summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-04-10 17:06:28 -0700
committerCharles Harris <charlesr.harris@gmail.com>2013-04-10 17:06:28 -0700
commit25d55b8f0ea74f7c8a700a14ef8c256a51dd1376 (patch)
tree8d959355240553c3e7e0f331dc997622949ad38e /numpy/lib
parent230db778beaca454a95b0fb706330b6dcbd4a8f8 (diff)
parenta6164794a63215e23fa28432d9acec4727c68d02 (diff)
downloadnumpy-25d55b8f0ea74f7c8a700a14ef8c256a51dd1376.tar.gz
Merge pull request #3216 from charris/2to3-apply-map-fixer
2to3: Apply `map` fixer.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/_iotools.py3
-rw-r--r--numpy/lib/financial.py10
-rw-r--r--numpy/lib/index_tricks.py4
-rw-r--r--numpy/lib/npyio.py21
-rw-r--r--numpy/lib/recfunctions.py2
-rw-r--r--numpy/lib/shape_base.py2
-rw-r--r--numpy/lib/stride_tricks.py4
7 files changed, 24 insertions, 22 deletions
diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py
index 34c85e47e..9eaf4d78f 100644
--- a/numpy/lib/_iotools.py
+++ b/numpy/lib/_iotools.py
@@ -721,7 +721,8 @@ class StringConverter(object):
value = (value,)
_strict_call = self._strict_call
try:
- map(_strict_call, value)
+ for _m in value:
+ _strict_call(_m)
except ValueError:
# Raise an exception if we locked the converter...
if self._locked:
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py
index 28e63f52b..cd21db0f2 100644
--- a/numpy/lib/financial.py
+++ b/numpy/lib/financial.py
@@ -115,7 +115,7 @@ def fv(rate, nper, pmt, pv, when='end'):
"""
when = _convert_when(when)
- rate, nper, pmt, pv, when = map(np.asarray, [rate, nper, pmt, pv, when])
+ (rate, nper, pmt, pv, when) = map(np.asarray, [rate, nper, pmt, pv, when])
temp = (1+rate)**nper
miter = np.broadcast(rate, nper, pmt, pv, when)
zer = np.zeros(miter.shape)
@@ -206,7 +206,7 @@ def pmt(rate, nper, pv, fv=0, when='end'):
"""
when = _convert_when(when)
- rate, nper, pv, fv, when = map(np.asarray, [rate, nper, pv, fv, when])
+ (rate, nper, pv, fv, when) = map(np.asarray, [rate, nper, pv, fv, when])
temp = (1+rate)**nper
miter = np.broadcast(rate, nper, pv, fv, when)
zer = np.zeros(miter.shape)
@@ -263,7 +263,7 @@ def nper(rate, pmt, pv, fv=0, when='end'):
"""
when = _convert_when(when)
- rate, pmt, pv, fv, when = map(np.asarray, [rate, pmt, pv, fv, when])
+ (rate, pmt, pv, fv, when) = map(np.asarray, [rate, pmt, pv, fv, when])
use_zero_rate = False
old_err = np.seterr(divide="raise")
@@ -502,7 +502,7 @@ def pv(rate, nper, pmt, fv=0.0, when='end'):
"""
when = _convert_when(when)
- rate, nper, pmt, fv, when = map(np.asarray, [rate, nper, pmt, fv, when])
+ (rate, nper, pmt, fv, when) = map(np.asarray, [rate, nper, pmt, fv, when])
temp = (1+rate)**nper
miter = np.broadcast(rate, nper, pmt, fv, when)
zer = np.zeros(miter.shape)
@@ -568,7 +568,7 @@ def rate(nper, pmt, pv, fv, when='end', guess=0.10, tol=1e-6, maxiter=100):
"""
when = _convert_when(when)
- nper, pmt, pv, fv, when = map(np.asarray, [nper, pmt, pv, fv, when])
+ (nper, pmt, pv, fv, when) = map(np.asarray, [nper, pmt, pv, fv, when])
rn = guess
iter = 0
close = False
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 41a891a39..b04e348b8 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -163,8 +163,8 @@ class nd_grid(object):
isinstance(key[k].stop, float):
typ = float
if self.sparse:
- nn = map(lambda x,t: _nx.arange(x, dtype=t), size, \
- (typ,)*len(size))
+ nn = [_nx.arange(_x, dtype=_t)
+ for _x, _t in zip(size, (typ,)*len(size))]
else:
nn = _nx.indices(size, typ)
for k in range(len(size)):
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 7f66fb141..600ab4a36 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -1602,7 +1602,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
# Upgrade the converters (if needed)
if dtype is None:
for (i, converter) in enumerate(converters):
- current_column = map(itemgetter(i), rows)
+ current_column = [itemgetter(i)(_m) for _m in rows]
try:
converter.iterupgrade(current_column)
except ConverterLockError:
@@ -1653,18 +1653,19 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
# Convert each value according to the converter:
# We want to modify the list in place to avoid creating a new one...
-# if loose:
-# conversionfuncs = [conv._loose_call for conv in converters]
-# else:
-# conversionfuncs = [conv._strict_call for conv in converters]
-# for (i, vals) in enumerate(rows):
-# rows[i] = tuple([convert(val)
-# for (convert, val) in zip(conversionfuncs, vals)])
+ #
+ # if loose:
+ # conversionfuncs = [conv._loose_call for conv in converters]
+ # else:
+ # conversionfuncs = [conv._strict_call for conv in converters]
+ # for (i, vals) in enumerate(rows):
+ # rows[i] = tuple([convert(val)
+ # for (convert, val) in zip(conversionfuncs, vals)])
if loose:
- rows = zip(*[map(converter._loose_call, map(itemgetter(i), rows))
+ rows = zip(*[[converter._loose_call(_r) for _r in map(itemgetter(i), rows)]
for (i, converter) in enumerate(converters)])
else:
- rows = zip(*[map(converter._strict_call, map(itemgetter(i), rows))
+ rows = zip(*[[converter._strict_call(_r) for _r in map(itemgetter(i), rows)]
for (i, converter) in enumerate(converters)])
# Reset the dtype
data = rows
diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py
index a9f480f5d..f909a4838 100644
--- a/numpy/lib/recfunctions.py
+++ b/numpy/lib/recfunctions.py
@@ -401,7 +401,7 @@ def merge_arrays(seqarrays,
seqarrays = (seqarrays,)
else:
# Make sure we have arrays in the input sequence
- seqarrays = map(np.asanyarray, seqarrays)
+ seqarrays = [np.asanyarray(_m) for _m in seqarrays]
# Find the sizes of the inputs and their maximum
sizes = tuple(a.size for a in seqarrays)
maxlength = max(sizes)
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 631cf6820..de8606167 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -345,7 +345,7 @@ def dstack(tup):
[[3, 4]]])
"""
- return _nx.concatenate(map(atleast_3d,tup),2)
+ return _nx.concatenate([atleast_3d(_m) for _m in tup], 2)
def _replace_zero_by_x_arrays(sub_arys):
for i in range(len(sub_arys)):
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
index 5c9d222f3..1f08131ec 100644
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -60,7 +60,7 @@ def broadcast_arrays(*args):
Here is a useful idiom for getting contiguous copies instead of
non-contiguous views.
- >>> map(np.array, np.broadcast_arrays(x, y))
+ >>> [np.array(a) for a in np.broadcast_arrays(x, y)]
[array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]]), array([[1, 1, 1],
@@ -68,7 +68,7 @@ def broadcast_arrays(*args):
[3, 3, 3]])]
"""
- args = map(np.asarray, args)
+ args = [np.asarray(_m) for _m in args]
shapes = [x.shape for x in args]
if len(set(shapes)) == 1:
# Common case where nothing needs to be broadcasted.