[SciPy-User] mary, a masked array

Pierre GM pgmdevlist at gmail.com
Sat Jun 26 12:42:32 EDT 2010


On Jun 25, 2010, at 8:30 PM, Keith Goodman wrote:

> An outer join of two data objects (labeled arrays, larrys, in my case)
> can introduce missing values when one data object contains labels that
> are not in the other data object. For float data I fill the missing
> values with NaN. But I couldn't come up with a good fill value for int
> or bool data. Coverting int and bool to float is one way to go, but
> not ideal. The obvious solution is to use np.ma to mask the missing
> values. But my masking needs are modest so I coded up a quick proof of
> concept for a stripped down masked array class that is tailored to my
> needs. Here's what I came up with: http://github.com/kwgoodman/mary

You're re-implementing the original version of MaskedArray :)
(in numpy <1.2, a masked array was the combination of a standard ndarray (your data) and either a boolean ndarray or a boolean (your mask)... That's quite OK, as long as you're not bothered by the fact that a larray/mary is not an array.

> Comments and suggestions are welcomed. I'm not familiar with np.ma so
> I imagine there are many issues I haven't thought through.

What happens if you calculate sqrt(-1) with a mary ?


More information about the SciPy-User mailing list