From aa50162b58e0226bf4f5c21ee1d74a94e85cd6d7 Mon Sep 17 00:00:00 2001 From: Stephan Hoyer Date: Fri, 15 May 2015 01:14:18 -0700 Subject: BUG: fix _broadcast_shape (and broadcast_array) for len(args) > 32 Fixes gh-5862 --- numpy/lib/stride_tricks.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'numpy/lib/stride_tricks.py') 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 -- cgit v1.2.1