Skip to content

Implementing broadcast_arrays #3209

Closed
Closed

Description

@jakirkham

Would be great to have a Dask Array implementation of broadcast_arrays. It may be possible to pull code from the Dask Array meshgrid to get this to work.

Activity

  1. jakirkham commented on Feb 26, 2018

    @jakirkham
    MemberAuthor

    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.

  2. shoyer commented on Feb 26, 2018

    @shoyer
    Member

    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 use np.broadcast along the lines of broadcast_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

  3. jcrist commented on Feb 26, 2018

    @jcrist
    Member
  4. jakirkham commented on Feb 27, 2018

    @jakirkham
    MemberAuthor

    Thanks all. Added PR ( #3217 ) with an implementation of broadcast_arrays. Feedback welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions