diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-28 07:10:01 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-03-28 07:10:01 -0700 |
commit | 40742184df68fc01f3392c9865f35d5402e74b01 (patch) | |
tree | 4d4832417a28e128ed989fc273d322a551d1cfdb /numpy/lib | |
parent | db75eb44a31fe1bb04a0f673fd459614bfd02b85 (diff) | |
parent | b995d00e2e54bc6ff97f21bd179d1fc4dc3c92cb (diff) | |
download | numpy-40742184df68fc01f3392c9865f35d5402e74b01.tar.gz |
Merge pull request #3122 from charris/2to3-apply-xrange-fixer
2to3: Replace xrange by range and use list(range(...)) where needed
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/arraypad.py | 2 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 4 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 2 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 6 | ||||
-rw-r--r-- | numpy/lib/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/lib/tests/test_financial.py | 6 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_io.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_twodim_base.py | 2 |
9 files changed, 15 insertions, 15 deletions
diff --git a/numpy/lib/arraypad.py b/numpy/lib/arraypad.py index e6ebd97e4..bfb96fc24 100644 --- a/numpy/lib/arraypad.py +++ b/numpy/lib/arraypad.py @@ -760,7 +760,7 @@ def pad(array, pad_width, mode=None, **kwargs): function = mode # Create a new padded array - rank = range(len(narray.shape)) + rank = list(range(len(narray.shape))) total_dim_increase = [np.sum(pad_width[i]) for i in rank] offset_slices = [slice(pad_width[i][0], pad_width[i][0] + narray.shape[i]) diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index cd79dd67f..540092d45 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -2589,7 +2589,7 @@ def _chbevl(x, vals): b0 = vals[0] b1 = 0.0 - for i in xrange(1,len(vals)): + for i in range(1,len(vals)): b2 = b1 b1 = b0 b0 = x*b1 - b2 + vals[i] @@ -3467,7 +3467,7 @@ def delete(arr, obj, axis=None): new[slobj] = arr[slobj2] elif isinstance(obj, slice): start, stop, step = obj.indices(N) - numtodel = len(xrange(start, stop, step)) + numtodel = len(list(range(start, stop, step))) if numtodel <= 0: if wrap: return wrap(new) diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 9c58bf747..07e7c1e39 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -307,7 +307,7 @@ class AxisConcatenator(object): k2 = ndmin-tempobj.ndim if (trans1d < 0): trans1d += k2 + 1 - defaxes = range(ndmin) + defaxes = list(range(ndmin)) k1 = trans1d axes = defaxes[:k1] + defaxes[k2:] + \ defaxes[k1:k2] diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index ca410a24a..bd96a17f6 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -780,7 +780,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, defconv = _getconv(dtype) # Skip the first `skiprows` lines - for i in xrange(skiprows): + for i in range(skiprows): fh.next() # Read until we find a line with some values, and use @@ -804,7 +804,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, converters = [_getconv(dt) for dt in dtype_types] else: # All fields have the same dtype - converters = [defconv for i in xrange(N)] + converters = [defconv for i in range(N)] if N > 1: packing = [(N, tuple)] @@ -1339,7 +1339,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None, DeprecationWarning) skip_header = skiprows # Skip the first `skip_header` rows - for i in xrange(skip_header): + for i in range(skip_header): fhd.next() # Keep on until we find the first valid values diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index 575f6149d..1aa8f686c 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -74,7 +74,7 @@ def apply_along_axis(func1d,axis,arr,*args): % (axis,nd)) ind = [0]*(nd-1) i = zeros(nd,'O') - indlist = range(nd) + indlist = list(range(nd)) indlist.remove(axis) i[axis] = slice(None,None) outshape = asarray(arr.shape).take(indlist) @@ -754,7 +754,7 @@ def kron(a,b): nd = nda result = outer(a,b).reshape(as_+bs) axis = nd-1 - for _ in xrange(nd): + for _ in range(nd): result = concatenate(result, axis=axis) wrapper = get_array_prepare(a, b) if wrapper is not None: diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py index e06c50ef6..d11195f0d 100644 --- a/numpy/lib/tests/test_financial.py +++ b/numpy/lib/tests/test_financial.py @@ -124,15 +124,15 @@ class TestFinancial(TestCase): assert_almost_equal(np.nper(0.075,-2000,0,100000.,[0,1]), [ 21.5449442 , 20.76156441], 4) - assert_almost_equal(np.ipmt(0.1/12,range(5), 24, 2000), + assert_almost_equal(np.ipmt(0.1/12,list(range(5)), 24, 2000), [-17.29165168, -16.66666667, -16.03647345, -15.40102862, -14.76028842], 4) - assert_almost_equal(np.ppmt(0.1/12,range(5), 24, 2000), + assert_almost_equal(np.ppmt(0.1/12,list(range(5)), 24, 2000), [-74.998201 , -75.62318601, -76.25337923, -76.88882405, -77.52956425], 4) - assert_almost_equal(np.ppmt(0.1/12,range(5), 24, 2000, 0, + assert_almost_equal(np.ppmt(0.1/12,list(range(5)), 24, 2000, 0, [0,0,1,'end','begin']), [-74.998201 , -75.62318601, -75.62318601, -76.88882405, -76.88882405], 4) diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 25c498312..73af90386 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -887,7 +887,7 @@ class TestHistogramdd(TestCase): assert_array_equal(H, answer) Z = np.zeros((5, 5, 5)) - Z[range(5), range(5), range(5)] = 1. + Z[list(range(5)), list(range(5)), list(range(5))] = 1. H, edges = histogramdd([np.arange(5), np.arange(5), np.arange(5)], 5) assert_array_equal(H, Z) diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py index 9144138d1..ba28cf73a 100644 --- a/numpy/lib/tests/test_io.py +++ b/numpy/lib/tests/test_io.py @@ -160,7 +160,7 @@ class TestSavezLoad(RoundtripTest, TestCase): errors = [] threads = [threading.Thread(target=writer, args=(errors,)) - for j in xrange(3)] + for j in range(3)] for t in threads: t.start() for t in threads: diff --git a/numpy/lib/tests/test_twodim_base.py b/numpy/lib/tests/test_twodim_base.py index 702f9a6f5..f6b4ba4c3 100644 --- a/numpy/lib/tests/test_twodim_base.py +++ b/numpy/lib/tests/test_twodim_base.py @@ -191,7 +191,7 @@ class TestHistogram2d(TestCase): assert_array_equal(H.T, answer) H = histogram2d(x, y, xedges)[0] assert_array_equal(H.T, answer) - H,xedges,yedges = histogram2d(range(10),range(10)) + H,xedges,yedges = histogram2d(list(range(10)),list(range(10))) assert_array_equal(H, eye(10,10)) assert_array_equal(xedges, np.linspace(0,9,11)) assert_array_equal(yedges, np.linspace(0,9,11)) |