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 upon exiting it is restored to what it was before.
Keyword arguments. The valid keywords are possible special-function errors. Each keyword should have a string value that defines the treatement for the particular type of error. Values must be 'ignore', 'warn', or 'other'. See seterr
for details.
Context manager for special-function error handling.
geterr
get the current way of handling special-function errors
numpy.errstate
similar numpy function for floating-point errors
seterr
set how special-function errors are handled
>>> import scipy.special as sc
... from pytest import raises
... sc.gammaln(0) inf
>>> with sc.errstate(singular='raise'):
... with raises(sc.SpecialFunctionError):
... sc.gammaln(0) ...
>>> sc.gammaln(0) inf
We can also raise on every category except one.
>>> with sc.errstate(all='raise', singular='ignore'):See :
... sc.gammaln(0)
... with raises(sc.SpecialFunctionError):
... sc.spence(-1) ... inf
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.special._ufuncs.geterr
scipy.special._ufuncs.seterr
scipy.special._ufuncs.errstate
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