[SciPy-User] mary, a masked array

Keith Goodman kwgoodman@gmail....
Sat Jun 26 12:10:27 CDT 2010

On Sat, Jun 26, 2010 at 9:42 AM, Pierre GM <pgmdevlist@gmail.com> wrote:
> 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.

Ah, that's good to know. I'll take a look. Thank you.

>> 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 ?

Same as np.sqrt(-1) which gives NaN. But, as coded, the mask does not
get updated even if the marker is NaN. So far only assignment by
indexing updates the mask.

More information about the SciPy-User mailing list