[Numpy-discussion] bug with with fill_values in masked arrays?
Chris Withers
chris at simplistix.co.uk
Tue Mar 25 10:33:58 EDT 2008
Pierre GM wrote:
>
> Well, yeah, my bad, that depends on whether you use masked_invalid or
> fix_invalid or just build a basic masked array.
Yeah, well, if there were any docs I'd have a *clue* what you were
talking about ;-)
>>>> y=ma.fix_invalid(x)
I've never done this ;-)
> Having NaNs in an array usually reduces performance: the option we follow w/
> fix_invalid is to clear the masked array of the NaNs, and keeping track of
> where they were by setting the mask to True at the appropriate location.
That's good to know....
> That
> way, you don't have the drop of performance of having NaNs in your underlying
> array.
> Oh, and NaNs will be transformed to 0 if you use ints...
"use ints" in what context?
> Nope, the idea is really is to make things as efficient as possible.
For you, maybe. And for me, yes, except I wanted the NaNs to stick around...
> y=ma.masked_invalid(x)
I'm not using masked_invalid. I didn't even know it existed.
> Because in your particular case, you're inspecting elements one by one, and
> then, your masked data becomes the masked singleton which is a special value.
I'd argue that the masked singleton having a different fill value to the
ma it comes from is a bug.
> And once again, it's not. numpy.ma.masked is a special value, like numpy.nan
> or numpy.inf
...which is silly, since that forces it to have a fixed fill value,
which it should not.
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the NumPy-Discussion
mailing list