diff options
author | Stephan Hoyer <shoyer@climate.com> | 2015-05-15 01:14:18 -0700 |
---|---|---|
committer | Stephan Hoyer <shoyer@climate.com> | 2015-05-15 01:14:18 -0700 |
commit | aa50162b58e0226bf4f5c21ee1d74a94e85cd6d7 (patch) | |
tree | 69055d6029c586d6c9ac59dda95f95a31c779e76 /numpy/lib/stride_tricks.py | |
parent | 0174f2ae5d9efc7d7459c20c99e31ace20a341ed (diff) | |
download | numpy-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.py | 4 |
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 |