diff options
author | Matti Picus <matti.picus@gmail.com> | 2021-09-01 16:51:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 16:51:41 +0300 |
commit | 68299575d8595d904aff6f28e12d21bf6428a4ba (patch) | |
tree | f59f89c4786b8298fe25ef4f082f51366b388bb3 /numpy/lib/tests | |
parent | 0656fc493591be2200b0b0df5e14fb547aa4702f (diff) | |
parent | 64f15a94708095bf9d29af5dbfcc4b654a57248a (diff) | |
download | numpy-68299575d8595d904aff6f28e12d21bf6428a4ba.tar.gz |
Merge pull request #19781 from mwtoews/foreach-item
MAINT: refactor "for ... in range(len(" statements
Diffstat (limited to 'numpy/lib/tests')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 5 | ||||
-rw-r--r-- | numpy/lib/tests/test_shape_base.py | 10 |
2 files changed, 7 insertions, 8 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 1d694e92f..829691b1c 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2772,11 +2772,6 @@ class TestInterp: assert_almost_equal(np.interp(x, xp, fp, period=360), y) -def compare_results(res, desired): - for i in range(len(desired)): - assert_array_equal(res[i], desired[i]) - - class TestPercentile: def test_basic(self): diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py index fb7ba7874..a148e53da 100644 --- a/numpy/lib/tests/test_shape_base.py +++ b/numpy/lib/tests/test_shape_base.py @@ -392,7 +392,7 @@ class TestArraySplit: assert_(a.dtype.type is res[-1].dtype.type) # Same thing for manual splits: - res = array_split(a, [0, 1, 2], axis=0) + res = array_split(a, [0, 1], axis=0) tgt = [np.zeros((0, 10)), np.array([np.arange(10)]), np.array([np.arange(10)])] compare_results(res, tgt) @@ -713,5 +713,9 @@ class TestMayShareMemory: # Utility def compare_results(res, desired): - for i in range(len(desired)): - assert_array_equal(res[i], desired[i]) + """Compare lists of arrays.""" + if len(res) != len(desired): + raise ValueError("Iterables have different lengths") + # See also PEP 618 for Python 3.10 + for x, y in zip(res, desired): + assert_array_equal(x, y) |