Skip to content

API reference / Switchback

tsdive.switchback.setting

setting(blocks: Blocks, observed: ndarray) -> np.ndarray

Per-sample setting: 1 in B blocks, 0 in A blocks and outside the schedule.

Examples:

>>> import numpy as np
>>> from tsdive.switchback import cut_blocks, setting
>>> times = np.array([0.0, 30.0, 60.0, 150.0, 250.0])
>>> blocks = cut_blocks(times, span=240.0, length=60.0)
>>> setting(blocks, np.array([0, 1, 1, 0])).tolist()
[0.0, 0.0, 1.0, 1.0, 0.0]