Skip to content

masked arrays and views (Trac #1305) #1903

Open

Description

@thouis

Original ticket http://projects.scipy.org/numpy/ticket/1305 on 2009-11-26 by trac user tgirod, assigned to @pierregm.

when creating a view on a masked array with mask=False, changing the mask in the view won't propagate to the mask in the original array.

However, when the mask is already an array before the view is created, altering the mask in the view alters the mask in the original array.

this difference of behaviour can lead to troubles

import numpy as np
import numpy.ma as ma

x = ma.zeros(25)
xv = x.reshape((5,5))

print x.mask

> False

print xv.mask

> False

xv.mask = np.identity(5)

print x.mask

> False

print xv.mask

> [[ True False False False False]
>  [False  True False False False]
>  [False False  True False False]
>  [False False False  True False]
>  [False False False False  True]]

Activity

  1. thouis commented on Oct 19, 2012

    @thouis
    ContributorAuthor

    Milestone changed to Unscheduled by @mwiebe on 2011-03-25

  2. efiring commented on Jun 17, 2013

    @efiring
    Contributor

    It looks like the solution will be for the masked array view method to unshrink the source array's nomask into an array. This is not the nicest behavior, but I don't see any better alternative.

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