Skip to content

API reference / Switchback

tsdive.switchback.make_plan

make_plan(
    start: Timestamp,
    end: Timestamp,
    block_s: int,
    washout_s: int,
    seed: int,
) -> SwitchbackPlan

The balanced schedule seed draws over start to end.

Raises:

Type Description
ValueError

a naive bound, end not after start, a block of less than one second, a washout outside [0, block), or a negative seed.

DesignTooSmall

the window holds too few blocks for a randomization test at the 5% level.

Examples:

>>> import pandas as pd
>>> from tsdive.switchback import make_plan
>>> plan = make_plan(pd.Timestamp("2024-06-03T00:00:00Z"),
...                  pd.Timestamp("2024-06-04T00:00:00Z"),
...                  block_s=3600, washout_s=900, seed=7)
>>> plan.k, plan.blocks[0].setting, plan.blocks[0].washout_end.isoformat()
(24, 'A', '2024-06-03T00:15:00+00:00')