[Numpy-discussion] feedback request: proposal to add masks to the core ndarray
Thu Jun 23 18:39:07 CDT 2011
On Jun 24, 2011, at 12:43 AM, Mark Wiebe wrote:
> On Thu, Jun 23, 2011 at 5:24 PM, Pierre GM <firstname.lastname@example.org> wrote:
> Mmh, after timeseries, now masked arrays... Mark, I start to see a pattern here ;)
> I think it speaks to what's on Enthought's mind, in any case. :)
> Anyhow, yes, there should be some work to address some of numpy.ma shortcomings. I may a bit conservative, but I don't really see the reason to follow a radically different approach. Your idea of switching the current convention of mask (a True meaning that the data can be accessed) will lead to a lot of fun indeed. And sorry, what "general consensus about masks elsewhere" are you referring to ?
> I've used masks for many things in many contexts, and was quite surprised the first time I saw the convention being used in numpy.ma. In image processing, it's well established that a mask is white (1) for valid pixels and black (0) for missing/transparent pixels. Applying a mask to an image is a multiplication, something which works out very nicely. It also corresponds nicely with array boolean indexing, where a[a != 0] uses the mask "a != 0" to select nonzero elements.
OK. At the time I worked on numpy.ma, I was still doing GIS, and a mask was just an extra layer that would hide some unwanted features. So True if the mask is on, False otherwise made sense. Besides, that was the existing convention in Numeric, so my hands were tied.
> For at least a couple of releases, arrays with masks and instances of numpy.ma will have to coexist, and I'm hoping the new implementation will be intuitive enough that the transition won't be too crazy.
Well, "intuitive" can be a fairly subjective notion... And frankly, I still fail to see the point. After all, it's a convention.
> > There is some consternation about the conventional True/False
> > interpretation of the mask, centered around the name "mask".
> Don't call it "mask" at all then. "accessible" ? "access" ? Avoid "valid", it's too connotated.
> Coming up with a good name will take some thinking. Of the names so far, "validity" is my favorite.
A rose by any other name...
Anyhow, more comments to follow.
More information about the NumPy-Discussion