From 49391ba7a622f93e0c1c65fc785a1373f3ca0384 Mon Sep 17 00:00:00 2001 From: Olivier Boulant Date: Mon, 18 Jan 2021 15:41:17 +0100 Subject: [PATCH] test(detection): handle various cases in search methods and cost on constant signal input --- tests/test_detection.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tests/test_detection.py b/tests/test_detection.py index a262cbdc..7514d685 100644 --- a/tests/test_detection.py +++ b/tests/test_detection.py @@ -83,8 +83,25 @@ def test_model_1D_constant(signal_bkps_1D_constant, algo, model): signal, bkps = signal_bkps_1D_constant algo_t = algo(model=model) ret = algo_t.fit_predict(signal, 1) - if not isinstance(algo_t, Pelt): + if isinstance(algo_t, Dynp) or isinstance(algo_t, BottomUp): + # With constant signal, those search methods + # will return another break points alongside signal.shape[0] assert len(ret) == 2 + if isinstance(algo_t, Binseg): + if model == "normal": + # With constant signal, this search method with normal cost + # will return only signal.shape[0] as breaking points + assert len(ret) == 1 + else: + # With constant signal, this search method with another cost + # will return another break points alongside signal.shape[0] + assert len(ret) == 2 + if isinstance(algo_t, Window): + # With constant signal, this search methods + # will return only signal.shape[0] as breaking points + assert len(ret) == 1 + if isinstance(algo_t, Pelt): + assert len(ret) <= 2 assert ret[-1] == signal.shape[0]