Skip to content

Commit f174ed6

Browse files
committed
add tests for warning
1 parent f8d6df5 commit f174ed6

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/test_core.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,36 @@ def test_check_max_window_size():
192192
core.check_window_size(m, max_size=3)
193193

194194

195+
def test_check_window_size_excl_zone_case1():
196+
# To ensure warning is raised if there is no subsequence
197+
# with non-trivial neighbor
198+
T = np.random.rand(64)
199+
m = 60
200+
last_start_index = len(T) - m
201+
202+
excl_zone = int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))
203+
204+
with pytest.warns(UserWarning):
205+
core.check_window_size(
206+
m, max_size=len(T), excl_zone=excl_zone, last_start_index=last_start_index
207+
)
208+
209+
210+
def test_check_window_size_excl_zone_case2():
211+
# To ensure warning is raised if there is at least one subsequence
212+
# that has no non-trivial neighbor
213+
T = np.random.rand(64)
214+
m = 48
215+
last_start_index = len(T) - m
216+
217+
excl_zone = int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))
218+
219+
with pytest.warns(UserWarning):
220+
core.check_window_size(
221+
m, max_size=len(T), excl_zone=excl_zone, last_start_index=last_start_index
222+
)
223+
224+
195225
@pytest.mark.parametrize("Q, T", test_data)
196226
def test_njit_sliding_dot_product(Q, T):
197227
ref_mp = naive_rolling_window_dot_product(Q, T)

0 commit comments

Comments
 (0)