We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
I think this is an easy fix for someone familiar with the ma module.
In [1]: x = np.ones(3, dtype=[('a', 'i4'), ('b', 'f4')]).view(ma.MaskedArray) In [2]: y = np.zeros(3, dtype=[('a', 'i4'), ('b', 'f4')]).view(ma.MaskedArray) In [3]: ma.where([True, False, True], x, y) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-3-5e3a8c327920> in <module>() ----> 1 ma.where([True, False, True], x, y) /home/charris/.local/lib/python2.7/site-packages/numpy/ma/core.pyc in where(condition, x, y) 6786 # Create an empty mask and fill it 6787 mask = np.zeros(fc.shape, dtype=MaskType) -> 6788 np.copyto(mask, getmask(x), where=fc) 6789 np.copyto(mask, getmask(y), where=notfc) 6790 mask |= getmaskarray(condition) TypeError: Cannot cast scalar from dtype([('a', '?'), ('b', '?')]) to dtype('bool') according to the rule 'same_kind'
The text was updated successfully, but these errors were encountered:
BUG: Make ma.where work with structured types.
ad85c47
Closes numpy#5826.
Not easy fix?
It might have to use result_type in where function
if x is masked: ndtype = yv.dtype elif y is masked: ndtype = xv.dtype else: ndtype = np.result_type(xv.dtype, yv.dtype)
might help but cause further error because you can't do OR operation on structured mask
e.g.
_mask |= getmaskarray(condition)
throws error
Sorry, something went wrong.
This is fixed in 1.14-dev:
masked_array(data = [(1, 1.0) (0, 0.0) (1, 1.0)], mask = [(False, False) (False, False) (False, False)], fill_value = (999999, 1.00000002e+20), dtype = [('a', '<i4'), ('b', '<f4')])
Edit: #8647
Successfully merging a pull request may close this issue.
I think this is an easy fix for someone familiar with the ma module.
The text was updated successfully, but these errors were encountered: