[Numpy-discussion] numpy.ma.compress

Eric Firing efiring at hawaii.edu
Wed Jan 23 17:25:03 EST 2008


Pierre GM wrote:
> On Wednesday 23 January 2008 16:17:51 you wrote:
>> Pierre,
>>
>> numpy.compress exists, but numpy.ma.compress does not; is this intentional?
> 
> Probably not. I usually don't use this function, preferring to use indexing 
> instead. If you have a need for it, I can probably come up with something 
> relatively soon: the basis would be to apply compress first on the ._data 
> part, return a view with the same class as the original object, and update 
> the mask with compress as needed.

The only reason to add it would be backwards compatibility. Evidently it 
exists in original numpy.ma.  Mike D used it in mpl's path.py until 
today when someone pointed out that it did not work with the maskedarray 
branch. (I think I tripped over the same thing a couple days ago, but 
worked around it at a higher level.) I agree that it is better *not* to 
use it, and we can easily strip it out of mpl if it occurs anywhere 
else; but there may be other user code that will trip over its absence 
when 1.05 comes out, so it might be easier to put it in, preserving 
similarity to numpy as well as old numpy.ma, than to leave it out and 
have to field future questions about it.

Eric



More information about the NumPy-Discussion mailing list