flopscope.

flopscope.numpy.geterr

flopscope.numpy.geterr()[flopscope source]

Get the current way of handling floating-point errors.

Returns

res:dict

A dictionary with keys "divide", "over", "under", and "invalid", whose values are from the strings "ignore", "print", "log", "warn", "raise", and "call". The keys represent possible floating-point exceptions, and the values define how these exceptions are handled.

See also

Notes

For complete documentation of the types of floating-point exceptions and treatment options, see seterr.

Examples

>>> import flopscope.numpy as fnp
>>> flops.geterr()
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
>>> flops.arange(3.) / flops.arange(3.)  # doctest: +SKIP
array([nan,  1.,  1.])
RuntimeWarning: invalid value encountered in divide
>>> oldsettings = flops.seterr(all='warn', invalid='raise')
>>> flops.geterr()
{'divide': 'warn', 'over': 'warn', 'under': 'warn', 'invalid': 'raise'}
>>> flops.arange(3.) / flops.arange(3.)
Traceback (most recent call last):
...
FloatingPointError: invalid value encountered in divide
>>> oldsettings = flops.seterr(**oldsettings)  # restore original