diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/compat/_inspect.py | 2 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 2 | ||||
-rw-r--r-- | numpy/core/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_scalarmath.py | 4 | ||||
-rw-r--r-- | numpy/core/tests/test_shape_base.py | 136 | ||||
-rw-r--r-- | numpy/f2py/auxfuncs.py | 4 | ||||
-rw-r--r-- | numpy/f2py/cfuncs.py | 2 | ||||
-rw-r--r-- | numpy/f2py/common_rules.py | 2 | ||||
-rwxr-xr-x | numpy/f2py/crackfortran.py | 9 | ||||
-rwxr-xr-x | numpy/f2py/f2py2e.py | 4 | ||||
-rw-r--r-- | numpy/f2py/f90mod_rules.py | 2 | ||||
-rw-r--r-- | numpy/f2py/tests/test_array_from_pyobj.py | 4 | ||||
-rw-r--r-- | numpy/lib/_iotools.py | 3 | ||||
-rw-r--r-- | numpy/lib/financial.py | 10 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 4 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 21 | ||||
-rw-r--r-- | numpy/lib/recfunctions.py | 2 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/stride_tricks.py | 4 | ||||
-rw-r--r-- | numpy/matrixlib/defmatrix.py | 2 | ||||
-rw-r--r-- | numpy/oldnumeric/matrix.py | 2 | ||||
-rw-r--r-- | numpy/testing/utils.py | 3 |
22 files changed, 128 insertions, 100 deletions
diff --git a/numpy/compat/_inspect.py b/numpy/compat/_inspect.py index 931364f6d..557a3da32 100644 --- a/numpy/compat/_inspect.py +++ b/numpy/compat/_inspect.py @@ -152,7 +152,7 @@ def joinseq(seq): def strseq(object, convert, join=joinseq): """Recursively walk a sequence, stringifying each element.""" if type(object) in [types.ListType, types.TupleType]: - return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object)) + return join([strseq(_o, convert, join) for _o in object]) else: return convert(object) diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index c5cdecfdc..65f0943c8 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -116,7 +116,7 @@ if sys.version_info[0] >= 3: # "import string" is costly to import! # Construct the translation tables directly # "A" = chr(65), "a" = chr(97) -_all_chars = map(chr, list(range(256))) +_all_chars = [chr(_m) for _m in range(256)] _ascii_upper = _all_chars[65:65+26] _ascii_lower = _all_chars[97:97+26] LOWER_TABLE="".join(_all_chars[:65] + _ascii_lower + _all_chars[65+26:]) diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index 9f146ad5c..ee0b1342e 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -225,7 +225,7 @@ def vstack(tup): [4]]) """ - return _nx.concatenate(map(atleast_2d,tup),0) + return _nx.concatenate([atleast_2d(_m) for _m in tup], 0) def hstack(tup): """ @@ -269,7 +269,7 @@ def hstack(tup): [3, 4]]) """ - arrs = map(atleast_1d,tup) + arrs = [atleast_1d(_m) for _m in tup] # As a special case, dimension 0 of 1-dimensional arrays is "horizontal" if arrs[0].ndim == 1: return _nx.concatenate(arrs, 0) diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py index 683aae8b2..201861279 100644 --- a/numpy/core/tests/test_scalarmath.py +++ b/numpy/core/tests/test_scalarmath.py @@ -104,10 +104,10 @@ class TestConversion(TestCase): li = [10**6, 10**12, 10**18, -10**6, -10**12, -10**18] for T in [None, np.float64, np.int64]: a = np.array(l,dtype=T) - assert_equal(map(int,a), li) + assert_equal([int(_m) for _m in a], li) a = np.array(l[:3], dtype=np.uint64) - assert_equal(map(int,a), li[:3]) + assert_equal([int(_m) for _m in a], li[:3]) #class TestRepr(TestCase): diff --git a/numpy/core/tests/test_shape_base.py b/numpy/core/tests/test_shape_base.py index 803e740a0..1f261375f 100644 --- a/numpy/core/tests/test_shape_base.py +++ b/numpy/core/tests/test_shape_base.py @@ -9,29 +9,34 @@ from numpy.core import (array, arange, atleast_1d, atleast_2d, atleast_3d, class TestAtleast1d(TestCase): def test_0D_array(self): - a = array(1); b = array(2); - res=map(atleast_1d,[a,b]) + a = array(1) + b = array(2) + res = [atleast_1d(a), atleast_1d(b)] desired = [array([1]),array([2])] - assert_array_equal(res,desired) + assert_array_equal(res, desired) def test_1D_array(self): - a = array([1,2]); b = array([2,3]); - res=map(atleast_1d,[a,b]) - desired = [array([1,2]),array([2,3])] - assert_array_equal(res,desired) + a = array([1, 2]) + b = array([2, 3]) + res = [atleast_1d(a), atleast_1d(b)] + desired = [array([1, 2]),array([2, 3])] + assert_array_equal(res, desired) def test_2D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - res=map(atleast_1d,[a,b]) - desired = [a,b] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + res = [atleast_1d(a), atleast_1d(b)] + desired = [a, b] + assert_array_equal(res, desired) def test_3D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - a = array([a,a]);b = array([b,b]); - res=map(atleast_1d,[a,b]) - desired = [a,b] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + a = array([a, a]) + b = array([b, b]) + res = [atleast_1d(a), atleast_1d(b)] + desired = [a, b] + assert_array_equal(res, desired) def test_r1array(self): """ Test to make sure equivalent Travis O's r1array function @@ -45,29 +50,34 @@ class TestAtleast1d(TestCase): class TestAtleast2d(TestCase): def test_0D_array(self): - a = array(1); b = array(2); - res=map(atleast_2d,[a,b]) - desired = [array([[1]]),array([[2]])] - assert_array_equal(res,desired) + a = array(1) + b = array(2) + res = [atleast_2d(a), atleast_2d(b)] + desired = [array([[1]]), array([[2]])] + assert_array_equal(res, desired) def test_1D_array(self): - a = array([1,2]); b = array([2,3]); - res=map(atleast_2d,[a,b]) - desired = [array([[1,2]]),array([[2,3]])] - assert_array_equal(res,desired) + a = array([1, 2]) + b = array([2, 3]) + res = [atleast_2d(a), atleast_2d(b)] + desired = [array([[1, 2]]), array([[2, 3]])] + assert_array_equal(res, desired) def test_2D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - res=map(atleast_2d,[a,b]) - desired = [a,b] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + res = [atleast_2d(a), atleast_2d(b)] + desired = [a, b] + assert_array_equal(res, desired) def test_3D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - a = array([a,a]);b = array([b,b]); - res=map(atleast_2d,[a,b]) - desired = [a,b] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + a = array([a, a]) + b = array([b, b]) + res = [atleast_2d(a), atleast_2d(b)] + desired = [a, b] + assert_array_equal(res, desired) def test_r2array(self): """ Test to make sure equivalent Travis O's r2array function @@ -79,46 +89,54 @@ class TestAtleast2d(TestCase): class TestAtleast3d(TestCase): def test_0D_array(self): - a = array(1); b = array(2); - res=map(atleast_3d,[a,b]) - desired = [array([[[1]]]),array([[[2]]])] - assert_array_equal(res,desired) + a = array(1) + b = array(2) + res = [atleast_3d(a), atleast_3d(b)] + desired = [array([[[1]]]), array([[[2]]])] + assert_array_equal(res, desired) def test_1D_array(self): - a = array([1,2]); b = array([2,3]); - res=map(atleast_3d,[a,b]) - desired = [array([[[1],[2]]]),array([[[2],[3]]])] - assert_array_equal(res,desired) + a = array([1, 2]) + b = array([2, 3]) + res = [atleast_3d(a), atleast_3d(b)] + desired = [array([[[1], [2]]]), array([[[2], [3]]])] + assert_array_equal(res, desired) def test_2D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - res=map(atleast_3d,[a,b]) - desired = [a[:,:,newaxis],b[:,:,newaxis]] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + res = [atleast_3d(a), atleast_3d(b)] + desired = [a[:,:,newaxis], b[:,:,newaxis]] + assert_array_equal(res, desired) def test_3D_array(self): - a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]); - a = array([a,a]);b = array([b,b]); - res=map(atleast_3d,[a,b]) - desired = [a,b] - assert_array_equal(res,desired) + a = array([[1, 2], [1, 2]]) + b = array([[2, 3], [2, 3]]) + a = array([a, a]) + b = array([b, b]) + res = [atleast_3d(a), atleast_3d(b)] + desired = [a, b] + assert_array_equal(res, desired) class TestHstack(TestCase): def test_0D_array(self): - a = array(1); b = array(2); + a = array(1) + b = array(2) res=hstack([a,b]) desired = array([1,2]) assert_array_equal(res,desired) def test_1D_array(self): - a = array([1]); b = array([2]); + a = array([1]) + b = array([2]) res=hstack([a,b]) desired = array([1,2]) assert_array_equal(res,desired) def test_2D_array(self): - a = array([[1],[2]]); b = array([[1],[2]]); + a = array([[1],[2]]) + b = array([[1],[2]]) res=hstack([a,b]) desired = array([[1,1],[2,2]]) assert_array_equal(res,desired) @@ -126,25 +144,29 @@ class TestHstack(TestCase): class TestVstack(TestCase): def test_0D_array(self): - a = array(1); b = array(2); + a = array(1) + b = array(2) res=vstack([a,b]) desired = array([[1],[2]]) assert_array_equal(res,desired) def test_1D_array(self): - a = array([1]); b = array([2]); + a = array([1]) + b = array([2]) res=vstack([a,b]) desired = array([[1],[2]]) assert_array_equal(res,desired) def test_2D_array(self): - a = array([[1],[2]]); b = array([[1],[2]]); + a = array([[1],[2]]) + b = array([[1],[2]]) res=vstack([a,b]) desired = array([[1],[2],[1],[2]]) assert_array_equal(res,desired) def test_2D_array2(self): - a = array([1,2]); b = array([1,2]); + a = array([1,2]) + b = array([1,2]) res=vstack([a,b]) desired = array([[1,2],[1,2]]) assert_array_equal(res,desired) diff --git a/numpy/f2py/auxfuncs.py b/numpy/f2py/auxfuncs.py index 3f0c6a988..b7d32976a 100644 --- a/numpy/f2py/auxfuncs.py +++ b/numpy/f2py/auxfuncs.py @@ -609,9 +609,9 @@ def stripcomma(s): def replace(str,d,defaultsep=''): if type(d)==types.ListType: - return map(lambda d,f=replace,sep=defaultsep,s=str:f(s,d,sep),d) + return [replace(str, _m, defaultsep) for _m in d] if type(str)==types.ListType: - return map(lambda s,f=replace,sep=defaultsep,d=d:f(s,d,sep),str) + return [replace(_m, d, defaultsep) for _m in str] for k in 2*list(d.keys()): if k=='separatorsfor': continue diff --git a/numpy/f2py/cfuncs.py b/numpy/f2py/cfuncs.py index 755f4203b..4e61b0634 100644 --- a/numpy/f2py/cfuncs.py +++ b/numpy/f2py/cfuncs.py @@ -1212,7 +1212,7 @@ def get_needs(): else: out.append(outneeds[n][0]) del outneeds[n][0] - if saveout and (0 not in map(lambda x,y:x==y,saveout,outneeds[n])) \ + if saveout and (0 not in map(lambda x,y:x==y, saveout, outneeds[n])) \ and outneeds[n] != []: print(n,saveout) errmess('get_needs: no progress in sorting needs, probably circular dependence, skipping.\n') diff --git a/numpy/f2py/common_rules.py b/numpy/f2py/common_rules.py index ed733a706..bfeaf4c9b 100644 --- a/numpy/f2py/common_rules.py +++ b/numpy/f2py/common_rules.py @@ -96,7 +96,7 @@ def buildhooks(m): cadd('\t{\"%s\",%s,{{%s}},%s},'%(n,dm['rank'],dms,at)) cadd('\t{NULL}\n};') inames1 = rmbadname(inames) - inames1_tps = ','.join(map(lambda s:'char *'+s,inames1)) + inames1_tps = ','.join(['char *'+s for s in inames1]) cadd('static void f2py_setup_%s(%s) {'%(name,inames1_tps)) cadd('\tint i_f2py=0;') for n in inames1: diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 52d198738..fe4091bcd 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -216,12 +216,14 @@ for n in ['int','double','float','char','short','long','void','case','while', 'type','default']: badnames[n]=n+'_bn' invbadnames[n+'_bn']=n + def rmbadname1(name): if name in badnames: errmess('rmbadname1: Replacing "%s" with "%s".\n'%(name,badnames[name])) return badnames[name] return name -def rmbadname(names): return map(rmbadname1,names) + +def rmbadname(names): return [rmbadname1(_m) for _m in names] def undo_rmbadname1(name): if name in invbadnames: @@ -229,7 +231,8 @@ def undo_rmbadname1(name): %(name,invbadnames[name])) return invbadnames[name] return name -def undo_rmbadname(names): return map(undo_rmbadname1,names) + +def undo_rmbadname(names): return [undo_rmbadname1(_m) for _m in names] def getextension(name): i=name.rfind('.') @@ -292,7 +295,7 @@ def readfortrancode(ffile,dowithline=show,istop=1): mline_mark = re.compile(r".*?'''") if istop: dowithline('',-1) ll,l1='','' - spacedigits=[' ']+map(str,list(range(10))) + spacedigits=[' '] + [str(_m) for _m in range(10)] filepositiontext='' fin=fileinput.FileInput(ffile) while 1: diff --git a/numpy/f2py/f2py2e.py b/numpy/f2py/f2py2e.py index 7be960ff7..80569ecc6 100755 --- a/numpy/f2py/f2py2e.py +++ b/numpy/f2py/f2py2e.py @@ -324,7 +324,7 @@ def buildmodules(lst): ret = {} for i in range(len(mnames)): if mnames[i] in isusedby: - outmess('\tSkipping module "%s" which is used by %s.\n'%(mnames[i],','.join(map(lambda s:'"%s"'%s,isusedby[mnames[i]])))) + outmess('\tSkipping module "%s" which is used by %s.\n'%(mnames[i],','.join(['"%s"'%s for s in isusedby[mnames[i]]]))) else: um=[] if 'use' in modules[i]: @@ -372,7 +372,7 @@ def run_main(comline_list): if postlist[i]['block']=='python module' and '__user__' in postlist[i]['name']: if postlist[i]['name'] in isusedby: #if not quiet: - outmess('Skipping Makefile build for module "%s" which is used by %s\n'%(postlist[i]['name'],','.join(map(lambda s:'"%s"'%s,isusedby[postlist[i]['name']])))) + outmess('Skipping Makefile build for module "%s" which is used by %s\n'%(postlist[i]['name'],','.join(['"%s"'%s for s in isusedby[postlist[i]['name']]]))) if 'signsfile' in options: if options['verbose']>1: outmess('Stopping. Edit the signature file and then run f2py on the signature file: ') diff --git a/numpy/f2py/f90mod_rules.py b/numpy/f2py/f90mod_rules.py index c251b2340..b68a79b64 100644 --- a/numpy/f2py/f90mod_rules.py +++ b/numpy/f2py/f90mod_rules.py @@ -158,7 +158,7 @@ def buildhooks(pymod): fadd('integer flag\n') fhooks[0]=fhooks[0]+fgetdims1 dms = eval('range(1,%s+1)'%(dm['rank'])) - fadd(' allocate(d(%s))\n'%(','.join(map(lambda i:'s(%s)'%i,dms)))) + fadd(' allocate(d(%s))\n'%(','.join(['s(%s)'%i for i in dms]))) fhooks[0]=fhooks[0]+use_fgetdims2 fadd('end subroutine %s'%(fargs[-1])) else: diff --git a/numpy/f2py/tests/test_array_from_pyobj.py b/numpy/f2py/tests/test_array_from_pyobj.py index 0621855f3..6707e8d8b 100644 --- a/numpy/f2py/tests/test_array_from_pyobj.py +++ b/numpy/f2py/tests/test_array_from_pyobj.py @@ -138,10 +138,10 @@ class Type(object): self.dtypechar = typeinfo[self.NAME][0] def cast_types(self): - return map(self.__class__,self._cast_dict[self.NAME]) + return [self.__class__(_m) for _m in self._cast_dict[self.NAME]] def all_types(self): - return map(self.__class__,self._type_names) + return [self.__class__(_m) for _m in self._type_names] def smaller_types(self): bits = typeinfo[self.NAME][3] 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. diff --git a/numpy/matrixlib/defmatrix.py b/numpy/matrixlib/defmatrix.py index 70f5683ff..080e83286 100644 --- a/numpy/matrixlib/defmatrix.py +++ b/numpy/matrixlib/defmatrix.py @@ -45,7 +45,7 @@ def _convert_from_string(data): newrow = [] for col in trow: temp = col.split() - newrow.extend(map(_eval,temp)) + newrow.extend(map(_eval, temp)) if count == 0: Ncols = len(newrow) elif len(newrow) != Ncols: diff --git a/numpy/oldnumeric/matrix.py b/numpy/oldnumeric/matrix.py index 4d04090b8..25dfe6302 100644 --- a/numpy/oldnumeric/matrix.py +++ b/numpy/oldnumeric/matrix.py @@ -40,7 +40,7 @@ def _convert_from_string(data): newrow = [] for col in trow: temp = col.split() - newrow.extend(map(_eval,temp)) + newrow.extend(map(_eval, temp)) if count == 0: Ncols = len(newrow) elif len(newrow) != Ncols: diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index cf35802ae..1b69d0ed2 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -531,7 +531,8 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True): """ import numpy as np - actual, desired = map(float, (actual, desired)) + + (actual, desired) = map(float, (actual, desired)) if desired==actual: return # Normalized the numbers to be in range (-10.0,10.0) |