nlcpy.seterr(all=None, divide=None, over=None, under=None, invalid=None)[ソース]

Sets how floating-point errors are handled.

all{'ignore', 'warn', 'raise', 'print'}, optional

Sets treatment for all types of floating-point errors at once:

  • ignore: Take no action when the exception occurs.

  • warn: Print a RuntimeWarning.

  • raise: Raise a FloatingPointError.

  • print: Print a warning directly to stdout.

The default is not to change the current behavior.

divide{'ignore', 'warn', 'raise', 'print'}, optional

Treatment for division by zero.

over{'ignore', 'warn', 'raise', 'print'}, optional

Treatment for floating-point overflow.

under{'ignore', 'warn', 'raise', 'print'}, optional

Treatment for floating-point underflow.

invalid{'ignore', 'warn', 'raise', 'print'}, optional

Treatment for invalid floating-point operation.


Dictionary containing the old settings.



Gets the current way of handling floating-point errors.


  • This function is the wrapper function to utilize numpy.seterr().

  • The floating-point exceptions are defined in the IEEE 754 standard:

    • Division by zero: infinite result obtained from finite numbers.

    • Overflow: result too large to be expressed.

    • Underflow: result so close to zero that some precision was lost.

    • Invalid operation: result is not an expressible number, typically indicates that a NaN was produced.


  • If the 'call' mode or the 'log' mode is specified for each parameter, NotImplementedError occurs.


>>> import nlcpy as vp
>>> old_settings = vp.seterr(all='ignore')  #seterr to known value
>>> vp.seterr(over='raise')
{'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
>>> vp.seterr(**old_settings)  # reset to default
{'divide': 'ignore', 'over': 'raise', 'under': 'ignore', 'invalid': 'ignore'}