s6.utils.filtersΒΆ
Generic temporal smoothing filters.
This module provides a lightweight sliding-window smoother that accepts lists/tuples/arrays of arbitrary length and returns a moving-average value. An optional acceptance function allows rejecting outlier measurements before they are added to the window, which is useful for stabilizing detectors.
- class s6.utils.filters.TupleSmoother(window: int = 3, accept_fn: ~typing.Callable[[~numpy.ndarray, ~numpy.ndarray], bool] | None = None, dtype: ~numpy.dtype = <class 'numpy.float64'>)
Bases:
objectSliding-window smoother for numeric tuples/lists/arrays.
Accepts 1D numeric sequences (list/tuple/ndarray) of any length.
Maintains a fixed-size history of accepted measurements.
Returns the moving average over the history as the smoothed value.
Supports an optional
accept_fn(new, prev) -> boolpredicate to reject outliers before they are incorporated into the history.
- reset() None
- property window: int
- property has_value: bool
- property history: List[ndarray]
Return a list copy of internal history arrays (oldest..newest).
- property value: ndarray | None
Return the current smoothed value (moving average) or None if empty.
- update(value: Sequence[float]) Tuple[ndarray, bool]
Push a new measurement and return (smoothed_value, accepted).
The measurement is only appended to history if
accept_fnallows it (or if there is no prior history). The smoothed value is the moving average over the current history window.