Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eric-wieser opened this issue Feb 10, 2017 · 0 comments · Fixed by #8647
Closed

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

eric-wieser opened this issue Feb 10, 2017 · 0 comments · Fixed by #8647

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Feb 10, 2017

>>> 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)
eric-wieser added a commit to eric-wieser/numpy that referenced this issue Mar 8, 2017
Fixes numpy#8600 and numpy#8599
Also makes np.ma.masked work with structured dtypes.
@mhvk mhvk closed this as completed in #8647 Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant