numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
seterr(all=None, divide=None, over=None, under=None, invalid=None)

Note that operations on integer scalar types (such as int16 ) are handled like floating point, and are affected by these settings.

Notes

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

            <Unimplemented 'footnote' '.. [1] https://en.wikipedia.org/wiki/IEEE_754'>
           

Parameters

all : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional

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

  • ignore: Take no action when the exception occurs.

  • warn: Print a :None:None:`RuntimeWarning` (via the Python warnings module).

  • raise: Raise a :None:None:`FloatingPointError`.

  • call: Call a function specified using the seterrcall function.

  • print: Print a warning directly to stdout .

  • log: Record error in a Log object specified by seterrcall .

The default is not to change the current behavior.

divide : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional

Treatment for division by zero.

over : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional

Treatment for floating-point overflow.

under : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional

Treatment for floating-point underflow.

invalid : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional

Treatment for invalid floating-point operation.

Returns

old_settings : dict

Dictionary containing the old settings.

Set how floating-point errors are handled.

See Also

errstate
geterr
geterrcall
seterrcall

Set a callback function for the 'call' mode.

Examples

This example is valid syntax, but we were not able to check execution
>>> old_settings = np.seterr(all='ignore')  #seterr to known value
... np.seterr(over='raise') {'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
This example is valid syntax, but we were not able to check execution
>>> np.seterr(**old_settings)  # reset to default
{'divide': 'ignore', 'over': 'raise', 'under': 'ignore', 'invalid': 'ignore'}
This example is valid syntax, but we were not able to check execution
>>> np.int16(32000) * np.int16(3)
30464
This example is valid syntax, but we were not able to check execution
>>> old_settings = np.seterr(all='warn', over='raise')
... np.int16(32000) * np.int16(3) Traceback (most recent call last): File "<stdin>", line 1, in <module> FloatingPointError: overflow encountered in short_scalars
This example is valid syntax, but we were not able to check execution
>>> old_settings = np.seterr(all='print')
... np.geterr() {'divide': 'print', 'over': 'print', 'under': 'print', 'invalid': 'print'}
This example is valid syntax, but we were not able to check execution
>>> np.int16(32000) * np.int16(3)
30464
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.geterrobj numpy.errstate numpy.seterrobj numpy.seterrcall numpy.geterr scipy.special._ufuncs.seterr numpy.geterrcall

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/_ufunc_config.py#32
type: <class 'function'>
Commit: