This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / special / _ufuncs / seterr

cython_function_or_method

scipy.special._ufuncs:seterr

Signature

def seterr(**kwargs)

Summary

Set how special-function errors are handled.

Parameters

**kwargs

The following may be passed as keyword arguments:

all

Set treatment for all type of special-function errors at once. The options are:

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

Treatment for singularities.

underflow

Treatment for underflow.

overflow

Treatment for overflow.

slow

Treatment for slow convergence.

loss

Treatment for loss of accuracy.

no_result

Treatment for failing to find a result.

domain

Treatment for an invalid argument to a function.

arg

Treatment for an invalid parameter to a function.

other

Treatment for an unknown error.

Returns

olderr : dict

Dictionary containing the old settings.

Examples

import scipy.special as sc
from pytest import raises
✓
sc.gammaln(0)
✗
np.float64(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)
✗
np.float64(inf)
with raises(sc.SpecialFunctionError):
    sc.spence(-1)
_ = sc.seterr(**olderr)
✓

See also

errstate

context manager for special-function error handling

geterr

get the current way of handling special-function errors

numpy.seterr

similar numpy function for floating-point errors

Aliases

  • scipy.special.seterr

Referenced by