calamari.repeats.group_consecutive#
- calamari.repeats.group_consecutive(keys, tols, *, partition=None, max_repeats=32)#
Group consecutive rows that share every key to within tolerance.
The generic primitive under
repeat_groups(), operating on plain arrays. Unlikecalamari.sweeps.segment_by_constant(), which starts a new segment on a large consecutive difference, this bounds the total span of each group. The difference matters: consecutive-difference chaining tolerates unbounded cumulative drift by design – correct for finding a plateau, and catastrophic here, where it would fold a slow measure-while-sweeping ramp into a single “repeat group” and average a whole sweep to a point.- Parameters:
keys (
Sequence[ArrayLike]) – The setpoint columns, all the same length. A group is extended only while every key stays within its tolerance.tols (
Sequence[float]) – One absolute tolerance per key, in that key’s own units.partition (
ArrayLike|None) – Row labels that may never be grouped together. Rows of one label need not be adjacent in the input: “consecutive” means adjacent within a partition, because in a real interleaved VSM/AC file no two rows of the same kind are ever file-adjacent, and requiring file-adjacency would make grouping such a file impossible.max_repeats (
int) – Raise rather than build a group larger than this. DefaultMAX_REPEATS.
- Return type:
- Returns:
listofnumpy.ndarray– One integer index array per group, in file order (sorted by first row), together covering every row exactly once. Index arrays – not slices – so a caller can build a row mask directly forrestrict().- Raises:
RepeatGroupError – If a group would exceed
max_repeats, which means the tolerances do not match the file.ValueError – If
keysandtolsdiffer in length, or the arrays differ in length from one another or frompartition.