tsdive.SwitchbackPlan
dataclass
¶
SwitchbackPlan(
start: Timestamp,
end: Timestamp,
block_s: int,
washout_s: int,
seed: int,
blocks: tuple[PlannedBlock, ...],
n_assignments: int,
enumerated: bool,
min_p: float,
digest: str,
*,
power: PowerReadout | None = None,
)
A balanced random schedule of settings A and B over one window.
start and end are the requested window; the schedule runs from
start to schedule_end, K
whole blocks. min_p is the smallest two-sided p-value the design can
reach. Build one with make_plan or
tsdive.switchback_plan.
Methods:
| Name | Description |
|---|---|
render |
The text |
to_dict |
The plan document: what |
write_json |
Write the plan document to |
read_json |
Read a plan document without checking its schedule. |
Attributes:
| Name | Type | Description |
|---|---|---|
start |
Timestamp
|
|
end |
Timestamp
|
|
block_s |
int
|
|
washout_s |
int
|
|
seed |
int
|
|
blocks |
tuple[PlannedBlock, ...]
|
|
n_assignments |
int
|
|
enumerated |
bool
|
|
min_p |
float
|
|
digest |
str
|
|
power |
PowerReadout | None
|
|
k |
int
|
|
schedule_end |
Timestamp
|
|
observed |
ndarray
|
(K,) int8, 1 marks a B block. |
reference_size |
int
|
Assignments the p-value is computed over, the observed one included. |
reference_size
property
¶
reference_size: int
Assignments the p-value is computed over, the observed one included.
render
¶
render() -> str
The text tsdive switchback plan prints, without its wrote line.
Examples:
>>> import tsdive
>>> plan = tsdive.switchback_plan("2024-06-03T00:00:00Z", "2024-06-04T00:00:00Z",
... block="PT1H", washout="PT15M", seed=7)
>>> print(plan.render().splitlines()[0])
switchback plan 24 blocks of 1 h A 12 B 12 digest 66da65ede04f
to_dict
¶
to_dict() -> dict[str, object]
The plan document: what write_json writes.
The document is ready for json.dumps.
write_json
¶
write_json(
path: str | Path, *, overwrite: bool = False
) -> Path
Write the plan document to path; an existing file raises FileExistsError.
read_json
classmethod
¶
read_json(path: str | Path) -> SwitchbackPlan
Read a plan document without checking its schedule.
verify_plan checks the schedule.
Raises:
| Type | Description |
|---|---|
ValueError
|
the file is not a plan document of this version. |