errstate(**kwargs)
Using an instance of errstate
as a context manager allows statements in that context to execute with a known error handling behavior. Upon entering the context the error handling is set with seterr
and seterrcall
, and upon exiting it is reset to what it was before.
:None:None:`errstate`
is also usable as a function decorator, saving a level of indentation if an entire function is wrapped. See :py:class:`contextlib.ContextDecorator`
for more information.
For complete documentation of the types of floating-point exceptions and treatment options, see seterr
.
Keyword arguments. The valid keywords are the possible floating-point exceptions. Each keyword should have a string value that defines the treatment for the particular error. Possible values are {'ignore', 'warn', 'raise', 'call', 'print', 'log'}.
Context manager for floating-point error handling.
>>> olderr = np.seterr(all='ignore') # Set error handling to known state.This example is valid syntax, but we were not able to check execution
>>> np.arange(3) / 0. array([nan, inf, inf])This example is valid syntax, but we were not able to check execution
>>> with np.errstate(divide='warn'):This example is valid syntax, but we were not able to check execution
... np.arange(3) / 0. array([nan, inf, inf])
>>> np.sqrt(-1) nanThis example is valid syntax, but we were not able to check execution
>>> with np.errstate(invalid='raise'):
... np.sqrt(-1) Traceback (most recent call last): File "<stdin>", line 2, in <module> FloatingPointError: invalid value encountered in sqrt
Outside the context the error handling behavior has not changed:
This example is valid syntax, but we were not able to check execution>>> np.geterr() {'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}See :
The following pages refer to to this document either explicitly or contain code examples using this.
numpy.errstate
numpy.seterr
dask.array.ufunc.power
scipy.special._ufuncs.errstate
dask.array.ufunc.float_power
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