[Numpy-discussion] Re: ndarray.fill and ma.array.filled
Pierre GM
pgmdevlist at mailcan.com
Fri Apr 7 20:40:03 EDT 2006
> >2. It should return masked array (with trivial mask), not ndarray.
>
> So, just with mask = False? In a follow on message Pierre disagress and
> claims that what you really want is the ndarray since not everything
> will accept. Then I guess you'd need to call b.filled(fill).data. I
> agree with Sasha in principle but Pierre, perhaps in practice.
Well, if 'mask' became a default argument of ndarray, that wouldn't be a pb
any longer. I'm quite for that.
> I'm
> almost suggested it get renames a.asndarray(fill), except that asXXX has
> the wrong conotations. I think this one needs to bounce around some more.
tondarray(fill) ?
> >4. View/Copy inconsistency. Does not provide a method to fill values
> > in-place.
> seems to work for this purpose. Can we just have filled return a copy?
Yes !
> > The problem with mask is that it's not clear whether
> > True means the data is useful or unuseful.
I have to think twice all the time I want to create a mask that True means in
fact that I don't want the data, whereas True selects the data for ndarray...
> "hide" or "hidden"? A mask value of True essentially hides the
> underlying value.
Unless when there's no underlying value ;). Rose, rose... I'm happy with mask,
it reminds me of GRASS and gimp
> 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".
"putmask" really seems overkill indeed. I wouldn't miss it.
> How do you set the mask? I keep getting attribute errors when I try it.
> And unmask would be a noop on an ndarray.
I've implemented something like that for some classes (inheriting from
MA.MaskedArray). Never really used it yet, though
#--------------------------------------------
def applymask(self,m):
if not MA.is_mask(m):
raise MA.MAError,"Invalid mask !"
elif self._data.shape != m.shape:
raise MA.MAError,"Mask and data not compatible."
else:
self._dmask = m
> This may be an oportune time to propose something that's been cooking in
> the back of my head for a week or so now: A stripped down array
> superclass.
That'd be great indeed, and may solve some problems reported on th list about
subclassing ndarray. AAMOF, I gave up trying to use ndarray as a superclass,
and rely only on MA
More information about the NumPy-Discussion
mailing list