You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do you know of a good way to determine the expected shape, @shoyer? We probably could guess, but if there is a better way, would like to use it here if possible.
So one option would be to construct dummy arrays with as_strided() and then use np.broadcast along the lines of broadcast_shape() to get the result shape.
Activity
jakirkham commentedon Feb 26, 2018
Do you know of a good way to determine the expected shape, @shoyer? We probably could guess, but if there is a better way, would like to use it here if possible.
shoyer commentedon Feb 26, 2018
NumPy has an internal helper function
broadcast_shape():https://github.com/numpy/numpy/blob/v1.14.0/numpy/lib/stride_tricks.py#L176
So one option would be to construct dummy arrays with
as_strided()and then usenp.broadcastalong the lines ofbroadcast_shape()to get the result shape.Or we could rewrite the logic in Python -- it isn't that complicated, and you can find it in old versions of the numpy source code:
https://github.com/numpy/numpy/blob/e8590311a7b312711c7a4f40c1a15496e34d0ee6/numpy/lib/stride_tricks.py#L47
jcrist commentedon Feb 26, 2018
There's also
dask.array.core.broadcast_shapes(https://github.com/dask/dask/blob/master/dask/array/core.py#L2866-L2893), which may be useful here.jakirkham commentedon Feb 27, 2018
Thanks all. Added PR ( #3217 ) with an implementation of
broadcast_arrays. Feedback welcome.