summaryrefslogtreecommitdiff
path: root/numpy/lib/stride_tricks.py
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@climate.com>2015-05-15 01:14:18 -0700
committerStephan Hoyer <shoyer@climate.com>2015-05-15 01:14:18 -0700
commitaa50162b58e0226bf4f5c21ee1d74a94e85cd6d7 (patch)
tree69055d6029c586d6c9ac59dda95f95a31c779e76 /numpy/lib/stride_tricks.py
parent0174f2ae5d9efc7d7459c20c99e31ace20a341ed (diff)
downloadnumpy-aa50162b58e0226bf4f5c21ee1d74a94e85cd6d7.tar.gz
BUG: fix _broadcast_shape (and broadcast_array) for len(args) > 32
Fixes gh-5862
Diffstat (limited to 'numpy/lib/stride_tricks.py')
-rw-r--r--numpy/lib/stride_tricks.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/lib/stride_tricks.py b/numpy/lib/stride_tricks.py
index c05d56e2f..416776ff4 100644
--- a/numpy/lib/stride_tricks.py
+++ b/numpy/lib/stride_tricks.py
@@ -126,6 +126,10 @@ def _broadcast_shape(*args):
b = np.broadcast(*args[:32])
# unfortunately, it cannot handle 32 or more arguments directly
for pos in range(32, len(args), 31):
+ # ironically, np.broadcast does not properly handle np.broadcast
+ # objects (it treats them as scalars)
+ # use broadcasting to avoid allocating the full array
+ b = broadcast_to(0, b.shape)
b = np.broadcast(b, *args[pos:(pos + 31)])
return b.shape