Skip to content

BUG: np.ma.where does not broadcast correctly #8599

Closed

Description

@eric-wieser
>>> x = np.eye(3)
>>> y = np.eye(3)
>>> np.where([0, 1, 0], x, y)
array([[ 1.,  0.,  0.],
       [ 0.,  1.,  0.],
       [ 0.,  0.,  1.]])
>>> np.ma.where([0, 1, 0], x, y)
Traceback (most recent call last):
  File "<pyshell#24>", line 1, in <module>
    np.ma.where([0, 1, 0], x, y)
  File "C:\Program Files\Python 3.5\lib\site-packages\numpy\ma\core.py", line 6964, in where
    np.copyto(d._data, xv.astype(ndtype), where=fc)
ValueError: could not broadcast input array from shape (3,3) into shape (3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions