8000 MaskArray.take does not work with scalar indices · Issue #7585 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MaskArray.take does not work with scalar indices #7585

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 Apr 28, 2016 · 5 comments
Closed

MaskArray.take does not work with scalar indices #7585

eric-wieser opened this issue Apr 28, 2016 · 5 comments

Comments

@eric-wieser
Copy link
Member
eric-wieser commented Apr 28, 2016

Python 3.5, numpy 1.10.1

>>> m = np.ma.array([1, 2, 3, 4], mask=[True, 0, 0, 0])

>>> m[0]
masked
>>> m.take(0)  #This is wrong
1

>>> m[[0,1]]
masked_array(data = [-- 2],
             mask = [ True False],
       fill_value = 999999)
>>> m.take([0, 1])
masked_array(data = [-- 2],
             mask = [ True False],
       fill_value = 999999)
@eric-wieser eric-wieser changed the title MaskArray.take does not work MaskArray.take does not work on scalars Apr 28, 2016
@eric-wieser eric-wieser changed the title MaskArray.take does not work on scalars MaskArray.take does not work with scalar indices Apr 28, 2016
@charris
Copy link
Member
charris commented Apr 28, 2016

Interesting. @ahaldane Thoughts?

@eric-wieser
Copy link
Member Author

Fixed by adding a np.asarray and a [...], I think

@eric-wieser
Copy link
Member Author

The underlying issue is that np.int32(1).view(MaskedArray) does not return a MaskedArray!

@eric-wieser
Copy link
Member Author

Workaround: m.take(keys[np.newaxis])[0] in place of m.take(keys)

eric-wieser added a commit to eric-wieser/numpy that referenced this issue Apr 29, 2016
eric-wieser added a commit to eric-wieser/numpy that referenced this issue Apr 29, 2016
By promoting and demoting between scalars and arrays where appropriate

See numpy#7585
@charris
Copy link
Member
charris commented May 2, 2016

Closed by #7586.

@charris charris closed this as completed May 2, 2016
charris pushed a commit to charris/numpy that referenced this issue May 2, 2016
charris pushed a commit to charris/numpy that referenced this issue May 2, 2016
By promoting and demoting between scalars and arrays where appropriate

See numpy#7585
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0