summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_shape_base.py
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-08-30 11:01:34 +1200
committerMike Taves <mwtoews@gmail.com>2021-09-01 21:50:59 +1200
commit64f15a94708095bf9d29af5dbfcc4b654a57248a (patch)
tree77bd3bf8a4f38561fee95fcfa3ea9e5247e6500b /numpy/lib/tests/test_shape_base.py
parent5ae53e93b2be9ccf47bf72a85d71ea15d15a2eed (diff)
downloadnumpy-64f15a94708095bf9d29af5dbfcc4b654a57248a.tar.gz
MAINT: refactor "for ... in range(len(" statements
Diffstat (limited to 'numpy/lib/tests/test_shape_base.py')
-rw-r--r--numpy/lib/tests/test_shape_base.py10
1 files changed, 7 insertions, 3 deletions
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)