[Numpy-discussion] numpy masked array oddity
Mon May 5 14:23:03 CDT 2008
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.
But yes, it makes indeed more sense not to have a MaskedArray in output.
SVN5126 should now work as discussed.
> > * I need to fix a bug in compressed when the underlying array is a
> > matrix: I can take care of the alternative at the same time. What are the
> > opinions on that matter ?
> > _______________________________________________
> > Numpy-discussion mailing list
> > Numpyfirstname.lastname@example.org
> > http://projects.scipy.org/mailman/listinfo/numpy-discussion
> Numpy-discussion mailing list
More information about the Numpy-discussion