deepcharles / ruptures

ruptures: change point detection in Python
BSD 2-Clause "Simplified" License
1.56k stars 161 forks source link

fix: Allow Binseg to hit minsize bounds for segments #249

Closed oboulant closed 2 years ago

oboulant commented 2 years ago

Binseg detection method fails at finding segments of length equals to min_size.


To reproduces 🔽

import numpy as np
from ruptures.detection import Binseg

signal = np.array([0,0.3,0.2,0.1, 10,11,12,13])
algo = Binseg(model="normal",jump=1).fit(signal)
computed_break_dict={n_bkps:algo.predict(n_bkps=n_bkps) for n_bkps in range(4)}
print(computed_break_dict)
expected_break_dict = {
    0:[8],
    1:[4,8],
    2:[4,6,8],
    3:[2,4,6,8]
    }
print(expected_break_dict)

Resolves https://github.com/deepcharles/ruptures/issues/244

codecov[bot] commented 2 years ago

Codecov Report

Merging #249 (a1633c3) into master (2bd37c2) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #249   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          40       40           
  Lines         978      978           
=======================================
  Hits          966      966           
  Misses         12       12           
Flag Coverage Δ
unittests 98.77% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/ruptures/detection/binseg.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2bd37c2...a1633c3. Read the comment docs.