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.
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.
<Unimplemented 'footnote' '.. [1] https://en.wikipedia.org/wiki/IEEE_754'>
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.
Treatment for division by zero.
Treatment for floating-point overflow.
Treatment for floating-point underflow.
Treatment for invalid floating-point operation.
Dictionary containing the old settings.
Set how floating-point errors are handled.
seterrcall
Set a callback function for the 'call' mode.
>>> old_settings = np.seterr(all='ignore') #seterr to known valueThis example is valid syntax, but we were not able to check execution
... np.seterr(over='raise') {'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
>>> 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) 30464This example is valid syntax, but we were not able to check execution
>>> old_settings = np.seterr(all='warn', over='raise')This example is valid syntax, but we were not able to check execution
... np.int16(32000) * np.int16(3) Traceback (most recent call last): File "<stdin>", line 1, in <module> FloatingPointError: overflow encountered in short_scalars
>>> old_settings = np.seterr(all='print')This example is valid syntax, but we were not able to check execution
... np.geterr() {'divide': 'print', 'over': 'print', 'under': 'print', 'invalid': 'print'}
>>> np.int16(32000) * np.int16(3) 30464See :
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
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