[Numpy-discussion] masked array with mask an instance of numpy.memmap
Pierre GM
pgmdevlist at gmail.com
Tue Mar 27 17:54:05 EDT 2007
On Tuesday 27 March 2007 17:42:18 Glen W. Mabey wrote:
> However, using a memmap for the mask value seems to load the entire
> object into memory, even if it is already of type bool.
>
> How hard would it be to change that behavior?
Oh, I have no idea about that...
> Also, it seems that median() is not implemented on masked arrays?
Great minds meet, I just uploaded some very basic stats functions for the new
implementation of masked array in the scipy SVN.
> Is there some method for a masked array like ravel() but that only
> includes the non-masked values?
Yep, compressed(). Note that it will flatten your array first, so if you work
with nd arrays, that's not the best solution. If you work with 2d arrays, you
can simply loop on the other dimension, such as
(n,p) = data.shape
med = numpy.empty((n,),dtype=data.dtype)
for i in range(p):
med[i] = numpy.median(data[:,i].compressed())
That works well if p < n/3.
More information about the NumPy-Discussion
mailing list