Skip to content

MaskArray.take does not work with scalar indices #7585

Closed

Description

@eric-wieser

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)

Activity

  1. changed the title [-]MaskArray.take does not work[/-] [+]MaskArray.take does not work on scalars[/+] on Apr 28, 2016
  2. changed the title [-]MaskArray.take does not work on scalars[/-] [+]MaskArray.take does not work with scalar indices[/+] on Apr 28, 2016
  3. charris commented on Apr 28, 2016

    @charris
    Member

    Interesting. @ahaldane Thoughts?

  4. eric-wieser commented on Apr 28, 2016

    @eric-wieser
    MemberAuthor

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

  5. eric-wieser commented on Apr 28, 2016

    @eric-wieser
    MemberAuthor

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

  6. eric-wieser commented on Apr 28, 2016

    @eric-wieser
    MemberAuthor

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

  7. charris commented on May 2, 2016

    @charris
    Member

    Closed by #7586.

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