From: Michael H. <mh...@al...> - 2001-05-11 18:32:02
|
"Paul F. Dubois" <pa...@pf...> writes: > The method __array__(self, typecode=None) is a special (existing) > hook for conversion to a Numeric array. Many operations in Numeric, > when presented with an object x to be operated upon, such as > Numeric.sqrt(x), will call x.__array__ as a final act of desperation > in an attempt to convert their argument to a Numeric > array. Heretofore it was essentially returning x.filled(). This > bothered me, because it was a silent conversion that replaced masked > values with the fill value. This bothered me too. > Solution: > > a. Add a method 'unmask()' which will replace the mask by None if > possible. It will not fail. > > b. Change MaskedArray.__array__ to work as follows: > a. self.unmask(), and then > b. Return the raw data if the mask is now None. > Otherwise, throw an MAError. Perfect. Great solution! Michael -- Michael Haggerty mh...@al... |