MCPcopy Create free account
hub / github.com/numpy/numpy / test_ufunc_methods_floaterrors

Function test_ufunc_methods_floaterrors

numpy/core/tests/test_ufunc.py:2793–2803  ·  view source on GitHub ↗
(method)

Source from the content-addressed store, hash-verified

2791 pytest.param(lambda x: np.add.reduceat(x, [0]), id="reduceat"),
2792 pytest.param(lambda x: np.log.at(x, [2]), id="at")])
2793def test_ufunc_methods_floaterrors(method):
2794 # adding inf and -inf (or log(-inf) creates an invalid float and warns
2795 arr = np.array([np.inf, 0, -np.inf])
2796 with np.errstate(all="warn"):
2797 with pytest.warns(RuntimeWarning, match="invalid value"):
2798 method(arr)
2799
2800 arr = np.array([np.inf, 0, -np.inf])
2801 with np.errstate(all="raise"):
2802 with pytest.raises(FloatingPointError):
2803 method(arr)
2804
2805
2806def _check_neg_zero(value):

Callers

nothing calls this directly

Calls 1

methodFunction · 0.85

Tested by

no test coverage detected