seterr#
- scipy.special.seterr(**kwargs)#
Set how special-function errors are handled.
- Parameters:
- all{โignoreโ, โwarnโ โraiseโ}, optional
Set treatment for all type of special-function errors at once. The options are:
โignoreโ Take no action when the error occurs
โwarnโ Print a
SpecialFunctionWarning
when the error occurs (via the Pythonwarnings
module)โraiseโ Raise a
SpecialFunctionError
when the error occurs.
The default is to not change the current behavior. If behaviors for additional categories of special-function errors are specified, then
all
is applied first, followed by the additional categories.- singular{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for singularities.
- underflow{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for underflow.
- overflow{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for overflow.
- slow{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for slow convergence.
- loss{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for loss of accuracy.
- no_result{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for failing to find a result.
- domain{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for an invalid argument to a function.
- arg{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for an invalid parameter to a function.
- other{โignoreโ, โwarnโ, โraiseโ}, optional
Treatment for an unknown error.
- Returns:
- olderrdict
Dictionary containing the old settings.
See also
geterr
get the current way of handling special-function errors
errstate
context manager for special-function error handling
numpy.seterr
similar numpy function for floating-point errors
Examples
>>> import scipy.special as sc >>> from pytest import raises >>> sc.gammaln(0) inf >>> olderr = sc.seterr(singular='raise') >>> with raises(sc.SpecialFunctionError): ... sc.gammaln(0) ... >>> _ = sc.seterr(**olderr)
We can also raise for every category except one.
>>> olderr = sc.seterr(all='raise', singular='ignore') >>> sc.gammaln(0) inf >>> with raises(sc.SpecialFunctionError): ... sc.spence(-1) ... >>> _ = sc.seterr(**olderr)