[Numpy-discussion] feedback request: proposal to add masks to the core ndarray

Pierre GM pgmdevlist@gmail....
Thu Jun 23 20:09:42 CDT 2011


On Jun 24, 2011, at 2:56 AM, Benjamin Root wrote:
> 
> As a heavy masked_array user, I regret not being able to participate more in this discussion as I am madly cranking out matplotlib code.  I would like to say that I have always seen masked arrays as being the "next step up" from using arrays with NaNs.  The hardmask/softmask/sharedmasked concepts are powerful, and I don't think they have yet to be exploited to their fullest potential.

Sweet, a user !
> 
> Also, just to make things messier, there is an incomplete feature that was made for record arrays with regards to masking.  The idea was to allow for element-by-element masking, but also allow for row-by-row (or was it column-by-column?) masking.  I thought it was a neat feature, and it is too bad that it was not finished.

You can still do that with a structured masked array: you can mask one element, or a whole record, or a whole field.
>>> x=np.ma.array([(1,1.),(2,2.),(3,3.)], dtype=[('a',int),('b',float)])
>>> x.mask=[1,0,0]
>>>x['b'] = np.ma.masked

True, I never bothered porting it to MaskedRecords, because I don't really see the point of records in the first place...



> Anyway, my opinion is that a mask should be True for a value that needs to be hidden.  Do not change this convention.  People coming into python already has to change code, a simple bit flip for them should be fine.  Breaking existing python code is worse.

+1


> I also don't see it as entirely necessary for *all* of masked arrays to be brought into numpy core.  Only the most important parts/hooks need  to be.  We could then still have a masked array class that provides the finishing touches such as the sharing of masks and special masked related functions.

+1

> 
> Lastly, I am not entirely familiar with R, so I am also very curious about what this magical "NA" value is, and how it compares to how NaNs work.  Although, Pierre brought up the very good point that NaNs woulldn't work anyway with integer arrays (and object arrays, etc.).
> 
> Back to toiling on matplotlib,

G'luck w/ that :)
P.



More information about the NumPy-Discussion mailing list