MCPcopy
hub / github.com/numpy/numpy / test_dot_errstate

Method test_dot_errstate

numpy/_core/tests/test_multiarray.py:3858–3883  ·  view source on GitHub ↗
(self, dtype)

Source from the content-addressed store, hash-verified

3856 @pytest.mark.parametrize("dtype", [np.half, np.double, np.longdouble])
3857 @pytest.mark.skipif(IS_WASM, reason="no wasm fp exception support")
3858 def test_dot_errstate(self, dtype):
3859 # Some dtypes use BLAS for 'dot' operation and
3860 # not all BLAS support floating-point errors.
3861 if not BLAS_SUPPORTS_FPE and dtype == np.double:
3862 pytest.skip("BLAS does not support FPE")
3863
3864 a = np.array([1, 1], dtype=dtype)
3865 b = np.array([-np.inf, np.inf], dtype=dtype)
3866
3867 with np.errstate(invalid='raise'):
3868 # there are two paths, depending on the number of dimensions - test
3869 # them both
3870 with pytest.raises(FloatingPointError,
3871 match="invalid value encountered in dot"):
3872 np.dot(a, b)
3873
3874 # test that fp exceptions are properly cleared
3875 np.dot(a, a)
3876
3877 with pytest.raises(FloatingPointError,
3878 match="invalid value encountered in dot"):
3879 np.dot(a[np.newaxis, np.newaxis, ...],
3880 b[np.newaxis, ..., np.newaxis])
3881
3882 np.dot(a[np.newaxis, np.newaxis, ...],
3883 a[np.newaxis, ..., np.newaxis])
3884
3885 def test_dot_type_mismatch(self):
3886 c = 1.

Callers

nothing calls this directly

Calls 1

dotMethod · 0.80

Tested by

no test coverage detected