diff --git a/piker/tsp/_anal.py b/piker/tsp/_anal.py index 42c3aa6c..26c3740e 100644 --- a/piker/tsp/_anal.py +++ b/piker/tsp/_anal.py @@ -578,11 +578,22 @@ def detect_time_gaps( # NOTE: this flag is to indicate that on this (sampling) time # scale we expect to only be filtering against larger venue # closures-scale time gaps. + # + # Map to total_ method since `dt_diff` is a duration type, + # not datetime - modern polars requires `total_*` methods + # for duration types (e.g. `total_days()` not `day()`) + # Ensure plural form for polars API (e.g. 'day' -> 'days') + unit_plural: str = ( + gap_dt_unit + if gap_dt_unit.endswith('s') + else f'{gap_dt_unit}s' + ) + duration_method: str = f'total_{unit_plural}' return step_gaps.filter( # Second by an arbitrary dt-unit step size getattr( pl.col('dt_diff').dt, - gap_dt_unit, + duration_method, )().abs() > gap_thresh )