[Numpy-discussion] Re: ndarray.fill and ma.array.filled

Sasha ndarray at mac.com
Fri Apr 7 18:47:09 CDT 2006


On 4/7/06, Tim Hochberg <tim.hochberg at cox.net> wrote:
> [...]
> >1. I don't like default fill value.   It should  be mandatory to
> >supply fill value.
> >
> >
> That makes perfect sense. If anything should have a default fill value,
> it's the functsion calling filled, not the arrays themselves.
>
It looks like we are getting close to a consensus on this one.  I will
remove fill_value attribute.

[...]

> >3. The name conflicts with the "fill" method.
> >
> >
> I thought you wanted to kill that. I'd certainly support that. Can't we
> just special case __setitem__ for that one case so that the performance
> is just as good if performance is really the issue?
>
I'll propose a patch.

> >4. View/Copy inconsistency.  Does not provide a method to fill values in-place.
> >
> >
> b[b.mask] = fill_value; b.unmask()
>
> seems to work for this purpose. Can we just have filled return a copy?
>
+1

> >mask:
> >
> >1. I've got rid of mask returning None in favor of False_ (boolean
> >array scalar), but it is still not perfect.  I would prefer data.shape
> >== mask.shape invariant and if space saving/performance  is deemed
> >necessary use zero-stride arrays.
> >
> >
> Interesting idea. Is that feasible yet?
>
It is not feasible in pure python module like ma, but easy in ndarray.
 We can also reset the writeable flag to avoid various problems that
zero strides may cause.  I'll propose a patch.

> >2. I don't like the name. "Missing" or "na" would be better.
> >
> >
> I'm not on board here, although really I'd like to here from other
> people who use the package. 'na' seems to cryptic to me and 'missing' to
> specific -- there might be other reasons to mask a value other it being
> missing. The problem with mask is that it's not clear whether
> True means the data is useful or unuseful. Keep throwing out names,
> maybe one will stick.
>
The problem with the "mask" name is that ndarray already has unrelated
"putmask" method.  On the other hand putmask is redundant with fancy
indexing.  I have no other problem with "mask" name, so we may just
decide to get rid of "putmask".

> [...]
> How do you set the mask? I keep getting attribute errors when I try it.

a[i] = masked makes i-th element masked.  If mask is an array, you can
just set its elements.

> And unmask would be a noop on an ndarray.
>
Yes.

[...]




More information about the Numpy-discussion mailing list