[Numpy-discussion] Re: [SciPy-dev] masked_array drops fill_value

Sasha ndarray at mac.com
Sat Mar 25 10:13:05 CST 2006

Please post questions about "ma" on numpy-discussion.

I don't like per-array fill_value feature.  I believe fill_value
should be a mandatory argument to the filled method and default
fill_values only used internally to avoid passing bad data to ufuncs. 
The behavior that you describe seem to be historical.  I would like to
hear from other people who rely on per-array fill values before making
any change.

On 3/25/06, Tim Leslie <tim.leslie at gmail.com> wrote:
> Hi all,
> In ma.py the masked_array function the fill_value of the array passed in is
> not used. The code currently looks like this:
> def masked_array (a, mask=nomask, fill_value=None):
>     """masked_array(a, mask=nomask) =
>        array(a, mask=mask, copy=0, fill_value=fill_value)
>     """
>     return array(a, mask=mask, copy=0, fill_value=fill_value)
> It seems to me that using the fill_value from a (if it is a MaskedArray)
> would be the sane thing to do? Something like
> if fill_value == None and isinstance(a, MaskedArray):
>     fill_value = a.fill_value()
> return array(a, mask=mask, copy=0, fill_value=fill_value)
> As it stands, all the ma functions such as transpose, reshape, etc lose the
> fill_value which seems wrong to me.
> Tim
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-dev

More information about the Numpy-discussion mailing list