Skip to content

Commit f154e2e

Browse files
committed
add test for divide-by-zero warning
1 parent 096b332 commit f154e2e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

tests/test_core.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import functools
22
import math
33
import os
4-
import warnings
54
from unittest.mock import patch
65

76
import naive
@@ -1758,14 +1757,11 @@ def test_process_isconstant_2d():
17581757
npt.assert_array_equal(T_subseq_isconstant_ref, T_subseq_isconstant_comp)
17591758

17601759

1761-
def test_preprocess_diagonal_std_inverse():
1760+
@pytest.mark.filterwarnings(
1761+
"error:divide by zero encountered in divide", category=RuntimeWarning
1762+
)
1763+
def test_preprocess_diagonal_divide_by_zero():
17621764
T = np.random.rand(64)
17631765
m = 3
17641766
T[:m] = np.nan
1765-
1766-
with warnings.catch_warnings(record=True) as w:
1767-
warnings.simplefilter("always")
1768-
core.preprocess_diagonal(T, m)
1769-
for item in w:
1770-
if issubclass(item.category, RuntimeWarning):
1771-
assert "divide by zero encountered in divide" not in str(item.message)
1767+
core.preprocess_diagonal(T, m)

0 commit comments

Comments
 (0)