[Numpy-discussion] numpy masked array oddity

Pierre GM pgmdevlist@gmail....
Mon May 5 13:15:43 CDT 2008


On Monday 05 May 2008 13:19:40 Russell E. Owen wrote:
> The object returned by maskedArray.compressed() appears to be a normal
> numpy array (based on repr output), but in reality it has some
> surprising differences:

Russell:

* I assume you're not using the latest version of numpy, are you ? If you 
were, the .sort() method would work.

* Currently, the output of MaskedArray.compressed() is indeed a MaskedArray, 
where the missing values are skipped. If you need a regular ndarray, just a 
view as Robert suggested. Christopher's suggestion is equivalent.

* 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. 

* 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 ?


More information about the Numpy-discussion mailing list