diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2013-03-05 21:43:22 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2013-03-27 18:42:34 -0600 |
commit | 91aa03f4a1065319e85c6ee90306971c301fd58c (patch) | |
tree | c4d40c32610eccebb71ad1f52c4f389c0d1b86b0 /numpy/lib/tests | |
parent | 1a816c79f7212102634c28e0896547671d347a60 (diff) | |
download | numpy-91aa03f4a1065319e85c6ee90306971c301fd58c.tar.gz |
2to3: Replace xrange by range and use list(range(...)) where needed
In python3 range is an iterator and `xrange` has been removed. This has
two consequence for code:
1) Where a list is needed `list(range(...))` must be used.
2) `xrange` must be replaced by `range`
Both of these changes also work in python2 and this patch makes both.
There are three places fixed that do not need it, but I left them in
so that the result would be `xrange` clean.
Closes #3092
Diffstat (limited to 'numpy/lib/tests')
-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 |
4 files changed, 6 insertions, 6 deletions
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)) |