[Numpy-discussion] numpy masked array oddity

Eric Firing efiring@hawaii....
Mon May 5 14:35:35 CDT 2008

Pierre GM wrote:
> On Monday 05 May 2008 15:10:56 Eric Firing wrote:
>> Pierre GM wrote:
>>> * An alternative would be to force the output of MaskedArray.compressed()
>>> to type(MaskedArray._baseclass), where the _baseclass attribute is the
>>> class of the underlying array: usually it's only ndarray, but it can be
>>> any subclass. Changing this behavior would not break anything in
>>> TimeSeries.
>> This alternative makes sense to me--I expect most use cases would be
>> most efficient with compressed yielding a plain ndarray.  I don't see
>> any gain in keeping it as a masked array, and having to manually convert
>> it.  (I don't see how the _baseclass conversion would work with the
>> baseclass as a matrix, though.)
> In fact, it's straightforward:
> - ravel the _data part to get a type(_baseclass) object
> - use .compress on the _data part, using logical_not(mask) as the condition.
> When you have a matrix as _baseclass, the result will be a ravelled version of 
> the initial matrix.

What I meant was that I don't see that such a ravelled version of a 
matrix would be likely to make sense in a linear algebra context, so 
leaving it as a matrix is likely to cause confusion rather than 
convenience.  Still, it would be consistent, so I am not objecting to it.


More information about the Numpy-discussion mailing list