This section discusses other classes defined in module numarray.ma.
| T) |
A constant named masked in numarray.ma serves several purposes.
x.mask()[3] is 1, then x[3] is masked.
x[3] = masked,
x[3] is masked.
== or !=.
() with one masked element. For example, using + for
illustration,
Another constant, masked_print_option controls what happens when masked arrays and the constant masked are printed:
| ) |
| string) |
| flag) |
str(self.filled()).
| ) |
>>> from numarray.ma import *
>>> x=arange(5)
>>> x[3] = masked
>>> print x
[0 ,1 ,2 ,-- ,4 ,]
>>> print repr(x)
array(data =
[0,1,2,0,4,],
mask =
[0,0,0,1,0,],
fill_value=[0,])
>>> print x[3]
--
>>> print x[3] + 1.0
--
>>> print masked + x
[-- ,-- ,-- ,-- ,-- ,]
>>> masked_print_option.enable(0)
>>> print x
[0,1,2,0,4,]
>>> print x + masked
[0,0,0,0,0,]
>>> print filled(x+masked, -99)
[-99,-99,-99,-99,-99,]
| f, fill=0, domain=None) |
filled(x, fill), with a mask equal to
mask_or(getmask(x), domain(x)).
The argument domain therefore should be a callable object that returns true where x is not in the domain of f.
The following domains are also supplied as members of module numarray.ma:
| a, b)(x) |
x < a or y > b.
| eps) |
abs(cos (x)) < eps, that is, a domain suitable for
the tangent function.
| v)(x) |
x <= v.
| v)(x) |
| f, fillx=0, filly=0) |
masked_binary_function(f,
fillx=0, filly=0) defines a function whose value at x is
f(filled(x, fillx), filled (y, filly)) with a resulting mask of
mask_or(getmask (x), getmask(y)). The values fillx and
filly must be chosen so that (fillx, filly) is in the domain of
f.
In addition, an instance of masked_binary_function has two methods defined upon it:
| target, axis = 0) |
| target, axis = 0) |
| a, b) |
| ) |
The following domains are available for use as the domain argument:
| )(x, y) |
absolute(x)*divide_tolerance > absolute(y). As the
comments in the code say, better ideas welcome. The constant
divide_tolerance
is set to 1.e-35 in the source and can be changed by editing its
value in MA.py and reinstalling. This domain is used for the divide
operator.
Send comments to the NumArray community.