[Numpy-discussion] NA masks in the next numpy release?

Han Genuit hangenuit@gmail....
Fri Oct 28 01:22:00 CDT 2011


There is a way to assign whole masks in the current implementation:

>>> a = np.arange(9, maskna=True).reshape((3,3))
>>> a
array([[0, 1, 2],
         [3, 4, 5],
         [6, 7, 8]])
>>> mask = np.array([[False, False, True],
                               [False, True, False],
                               [True, False, True]])
>>> np.copyto(a, np.NA, where=mask)
>>> a
array([[0, 1, NA],
         [3, NA, 5],
         [NA, 7, NA]])

I think the "ValueError: Cannot assign NA to an array which does not
support NAs" when trying to copy an array with a mask to an array
without a mask is a bug..

>>> a = np.arange(9, maskna=True).reshape((3,3))
>>> a.flags.maskna
True
>>> b = a.copy(maskna=False)
>>> b.flags.maskna
False

It should be possible to remove a mask when copying an array.


More information about the NumPy-Discussion mailing list