[Numpy-discussion] empty_like for masked arrays

Nathaniel Smith njs at pobox.com
Mon Jun 10 15:47:28 EDT 2013

Hi all,

Is there anyone out there using numpy masked arrays, who has an
opinion on how empty_like (and its friends ones_like, zeros_like)
should handle the mask?

Right now apparently if you call np.ma.empty_like on a masked array,
you get a new masked array that shares the original array's mask, so
modifying one modifies the other. That's almost certainly wrong. This
makes it so instead the new array has values that are all set to
empty/zero/one, and a mask which is set to match the input array's
mask (so whenever something was masked in the original array, the
empty/zero/one in that place is also masked). We don't know if this is
the desired behaviour for these functions, though. Maybe it's more
intuitive for the new array to match the original array in shape and
dtype, but to always have an empty mask. Or maybe not. None of us
really use np.ma, so if you do and have an opinion then please speak


More information about the NumPy-Discussion mailing list