A masked array is conceptually an array with missing values. MA represents such an array as a data array and a mask array. The mask array, if present, is an array of 1's and 0's, of the same shape as the data array, where a 1 represents a location with invalid data. When operations are performed, the resulting quantity has an appropriate mask. For example, if we add two masked arrays, the result has a mask consisting of the logical or of the operands' masks.
All operations avoid using the data from invalid locations.
For technical reasons it is not possible to inherit from the Numeric array object. While it would be possible to write a separate extension in C, it was felt important that MA arrays be convertible to and from Numeric arrays, and that a maintenance burden not be introduced by writing a compiled extension. Therefore, MA is implemented entirely in Python. As such, MA is a great case study of Python's power and flexibility. In designing these code, a great deal of care is given to the performance and capability of the underlying physics or mathematics of the simulation.