Skip to content

Commit 47884e6

Browse files
committed
Add test to catch warning divide-by-zero raised by process_diagonal
1 parent 3077d0d commit 47884e6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_core.py

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

67
import naive
@@ -1753,3 +1754,16 @@ def test_process_isconstant_2d():
17531754
T_subseq_isconstant_comp = core.process_isconstant(T, m, T_subseq_isconstant)
17541755

17551756
npt.assert_array_equal(T_subseq_isconstant_ref, T_subseq_isconstant_comp)
1757+
1758+
1759+
def test_preprocess_diagonal_std_inverse():
1760+
T = np.random.rand(64)
1761+
m = 3
1762+
T[:m] = np.nan
1763+
1764+
with warnings.catch_warnings(record=True) as w:
1765+
warnings.simplefilter("always")
1766+
core.preprocess_diagonal(T, m)
1767+
for item in w:
1768+
if issubclass(item.category, RuntimeWarning):
1769+
assert "divide by zero encountered in divide" not in str(item.message)

0 commit comments

Comments
 (0)