"Paul F. Dubois" <paul@pfdubois.com> 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 mhagger@alum.mit.edu