cf.Data.mask_fpe¶
-
static
Data.mask_fpe(*arg)[source]¶ Masking of floating-point errors in the results of arithmetic operations.
Deprecated at version 3.14.0. It is currently not possible to control how floating-point errors are handled, due to the use of
daskfor handling all array manipulations. This may change in the future (see https://github.com/dask/dask/issues/3245 for more details).If masking is allowed then only floating-point errors which would otherwise be raised as
FloatingPointErrorexceptions are masked. WhetherFloatingPointErrorexceptions may be raised is determined bycf.Data.seterr.If called without an argument then the current behaviour is returned.
Note that if the raising of
FloatingPointErrorexceptions has been suppressed then invalid values in the results of arithmetic operations may be subsequently converted to masked values with themask_invalidmethod.See also
- Parameters
- arg:
bool, optional The new behaviour. True means that
FloatingPointErrorexceptions are suppressed and replaced with masked values. False means thatFloatingPointErrorexceptions are raised. The default is not to change the current behaviour.
- arg:
- Returns
boolThe behaviour prior to the change, or the current behaviour if no new value was specified.
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] >