[Numpy-discussion] Re: NumPy and None (null, NaN, missing)
Paul F. Dubois
pauldubois at home.com
Mon Apr 10 11:01:55 CDT 2000
I have sent this out before but here it is again. It is a beta of a
missing-observation class. Please help me refine it and complete it. I
intend to add it to the numpy distribution since this facility is
much-requested. MAtest.py shows how to use it.
The intention is that it is used the same way you use a Numeric, and in fact
if there are no masked values that there isn't a lot of overhead.
The basic concept is that each MA holds an array and a mask that indicates
which values of the array are valid. Note the change in semantics for
indexing shown below.
Later I imagine creating a compiled extension class for bit masks to improve
the space and time efficiency.
Paul
# Note copy semantics here differ from Numeric
def __getitem__(self, i):
m = self.__mask
if m is None:
return Numeric.array(self.__data[i])
else:
return MA(Numeric.array(self.__data[i]), Numeric.array(m[i]))
def __getslice__(self, i, j):
m = self.__mask
if m is None:
return Numeric.array(self.__data[i:j])
else:
return MA(Numeric.array(self.__data[i:j]),
Numeric.array(m[i:j]))
# --------
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: MA.py
Url: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20000410/c28ba913/attachment-0002.pl
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: MAtest.py
Url: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20000410/c28ba913/attachment-0003.pl
More information about the Numpy-discussion
mailing list