[Numpy-discussion] bug with with fill_values in masked arrays?

Chris Withers chris@simplistix.co...
Fri Mar 21 11:55:11 CDT 2008


Pierre GM wrote:
> On Wednesday 19 March 2008 19:47:37 Matt Knox wrote:
>>> 1. why am I not getting my NaN's back?
> 
> Because they're gone when you create your masked array. 

Really? At least one other post has disagreed with that.
And it does seem odd that a value, even if it's a nan, would be destroyed...

> The idea here is to 
> get rid of the nan in your data 

No, it's to mask them, otherwise I would have used a normal array, not a ma.

> to avoid potential problems while keeping 
> track of where the nans were in the first place.

...like plotting them on a graph, which the current behaviour makes 
unworkable, that you end up doing a myarray.filled(0) to get around it, 
with imperfect results.

> So, the .data part of your 
> masked array should be nan-free,

Why? Surely that should be the source data, of which nan is a valid part?

> and the mask tells you where the nans were.

Right, but why when the masked array is cast back to a list of numbers 
if the fill_value of the ma not respected?

>>> 2. why is the wrong fill value being used here?
>> the second element in the array iteration here is actually the
>> numpy.ma.masked constant, which always has the same fill value...

...and that's a bug.

cheers,

Chris

-- 
Simplistix - Content Management, Zope & Python Consulting
            - http://www.simplistix.co.uk


More information about the Numpy-discussion mailing list