summaryrefslogtreecommitdiff
path: root/numpy/core/shape_base.py
diff options
context:
space:
mode:
authorJamie Townsend <jamiehntownsend@gmail.com>2017-11-01 13:16:24 +0000
committerJamie Townsend <jamiehntownsend@gmail.com>2017-11-03 11:14:33 +0000
commiteaddf3935ab94def7439f8674e1444af2f12cfbb (patch)
tree4ecc7302ccc2a3539580640cae940b06af044941 /numpy/core/shape_base.py
parent2c1734b192e0d5cb3973b76f9319b18be2a44697 (diff)
downloadnumpy-eaddf3935ab94def7439f8674e1444af2f12cfbb.tar.gz
Avoid using zip(*...) syntax
Diffstat (limited to 'numpy/core/shape_base.py')
-rw-r--r--numpy/core/shape_base.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py
index b7fe71310..29765d078 100644
--- a/numpy/core/shape_base.py
+++ b/numpy/core/shape_base.py
@@ -402,11 +402,13 @@ def _block_check_depths_match(arrays, parent_index=[]):
)
)
elif type(arrays) is list and len(arrays) > 0:
- indexes, arr_ndims = zip(*[_block_check_depths_match(arr, parent_index + [i])
- for i, arr in enumerate(arrays)])
+ idxs_ndims = (_block_check_depths_match(arr, parent_index + [i])
+ for i, arr in enumerate(arrays))
- first_index = indexes[0]
- for i, index in enumerate(indexes):
+ first_index, max_arr_ndim = idxs_ndims.__next__()
+ for i, (index, ndim) in enumerate(idxs_ndims, 1):
+ if ndim > max_arr_ndim:
+ max_arr_ndim = ndim
if len(index) != len(first_index):
raise ValueError(
"List depths are mismatched. First element was at depth "
@@ -416,7 +418,7 @@ def _block_check_depths_match(arrays, parent_index=[]):
format_index(index)
)
)
- return first_index, max(arr_ndims)
+ return first_index, max_arr_ndim
elif type(arrays) is list and len(arrays) == 0:
# We've 'bottomed out' on an empty list
return parent_index + [None], 0