from dascore.utils.gaps import RunRecord, contiguous_runs
runs = [RunRecord(3, 0, 2, 1, 0), RunRecord(2, 5, 6, 1, 5)]
[(x.count, x.min, x.max) for x in contiguous_runs(runs, step=1)][(3, 0, 2), (2, 5, 6)]
| function of dascore.utils.gaps | source |
contiguous_runs(
records ,
step = None,
jittered: bool = False,
)-> ‘list[RunRecord]’
Join a coordinate’s runs into the stretches its holes leave.
On a coordinate with a step a stretch ends at each hole, and keeps the step unless the labels are jittered. On one without, it ends where a run changes step or starts further from its predecessor than the default tolerance allows, and keeps a step only as one lone run; runs holding labels with no step (e.g. an exact array of jittered times) are irregular rather than gapped, so they make one stretch.