Masking of floating-point errors in the results of arithmetic operations.
If masking is allowed then only floating-point errors which would otherwise be raised as FloatingPointError exceptions are masked. Whether FloatingPointError exceptions may be raised is determined by cf.Data.seterr.
If called without an argument then the current behaviour is returned.
Note that if the raising of FloatingPointError exceptions has suppressed then invalid values in the results of arithmetic operations may be subsequently converted to masked values with the mask_invalid method.
Parameters : |
|
---|---|
Returns : |
|
See also
Examples
>>> d = cf.Data([0., 1])
>>> e = cf.Data([1., 2])
>>> old = cf.Data.mask_fpe(False)
>>> old = cf.Data.seterr('raise')
>>> e/d
FloatingPointError: divide by zero encountered in divide
>>> e**123456
FloatingPointError: overflow encountered in power
>>> old = cf.Data.mask_fpe(True)
>>> old = cf.Data.seterr('raise')
>>> e/d
<CF Data: [--, 2.0] >
>>> e**123456
<CF Data: [1.0, --] >
>>> old = cf.Data.mask_fpe(True)
>>> old = cf.Data.seterr('ignore')
>>> e/d
<CF Data: [inf, 2.0] >
>>> e**123456
<CF Data: [1.0, inf] >