IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
18.2 Using numarray.ma


18.2 Using numarray.ma

Use numarray.ma as a replacement for numarray:

from numarray.ma import *
>>> x = array([1, 2, 3])
To create an array with the second element invalid, we would do:
>>> y = array([1, 2, 3], mask = [0, 1, 0])
To create a masked array where all values ``near'' 1.e20 are invalid, we can do:
>>> z = masked_values([1.0, 1.e20, 3.0, 4.0], 1.e20)
For a complete discussion of creation methods for masked arrays please see section 18.3.3 ``Constructing masked arrays''.

The numarray module is an attribute in numarray.ma, so to execute a method foo from numarray, you can reference it as numarray.foo.

Usually people use both numarray.ma and numarray this way, but of course you can always fully-qualify the names:

>>> import numarray.ma
>>> x = numarray.ma.array([1, 2, 3])

The principal feature of module numarray.ma is class MaskedArray, the class whose instances are returned by the array constructors and most functions in module numarray.ma. We will discuss this class first, and later cover the attributes and functions in module numarray.ma. For now suffice it to say that among the attributes of the module are the constants from module numarray including those for declaring typecodes, NewAxis, and the mathematical constants such as pi and e. An additional typecode, MaskType, is the typecode used for masks.

Send comments to the NumArray community.