Coverage for tests/unit_test.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-10-01 10:11 +0000

1# This test is based on the toy example notebook 

2import os 

3from pathlib import Path 

4from kcpdi.kcp_ds import kcp_ds 

5import pickle 

6 

7ROOT_PATH = str(Path(__file__).parent.resolve()) + os.sep # To point on test directory 

8 

9def test_kcpdi(): 

10 

11 # Save to pickle file 

12 with open(ROOT_PATH+'test-ds.pkl', 'rb') as f: 

13 my_data=pickle.load(f) 

14 

15 detected_change_points, interval_end_points = kcp_ds(my_data, expected_frac_anomaly=15/1000) 

16 expected_change_point=[113, 213, 291, 336, 412, 520, 667, 807, 930] 

17 # print('The detected change-points are at times: ', detected_change_points) 

18 assert detected_change_points==expected_change_point 

19