tsdive.SwitchbackAnalysis
dataclass
¶
SwitchbackAnalysis(
plan: SwitchbackPlan,
target: Window,
covariates: tuple[Window, ...],
unused: tuple[str, ...],
direct: SwitchbackEstimate,
adjusted: SwitchbackEstimate | None,
*,
assumptions: str = ASSUMPTIONS,
covariate_checks: tuple[CovariateCheck, ...] = (),
)
The difference between settings A and B on one target, under a verified plan.
target and covariates are the reads over the schedule.
unused names the archives passed in that are neither. adjusted
is None when no covariate was declared. covariate_checks holds
one CovariateCheck per
covariate, in the order they were named; the analysis does not refuse
on one that moves, it reports it.
Methods:
| Name | Description |
|---|---|
render |
The text |
to_dict |
The document |
Attributes:
| Name | Type | Description |
|---|---|---|
plan |
SwitchbackPlan
|
|
target |
Window
|
|
covariates |
tuple[Window, ...]
|
|
unused |
tuple[str, ...]
|
|
direct |
SwitchbackEstimate
|
|
adjusted |
SwitchbackEstimate | None
|
|
assumptions |
str
|
|
covariate_checks |
tuple[CovariateCheck, ...]
|
|
moving_covariates |
tuple[CovariateCheck, ...]
|
The covariates whose own B - A difference has p below 0.05. |
tag |
str
|
|
unit |
str | None
|
|
good_share |
float | None
|
GOOD rows over all rows of the target read. |
censored |
bool | None
|
Whether a target sample sits at its engineering range limit. |
frame |
DataFrame
|
One row per block: index, start, setting, kept samples of each analysis. |
covariate_checks
class-attribute
instance-attribute
¶
covariate_checks: tuple[CovariateCheck, ...] = ()
moving_covariates
property
¶
moving_covariates: tuple[CovariateCheck, ...]
The covariates whose own B - A difference has p below 0.05.
censored
property
¶
censored: bool | None
Whether a target sample sits at its engineering range limit.
None when the target declares no engineering range and no
digital range state flags a sample.
frame
property
¶
frame: DataFrame
One row per block: index, start, setting, kept samples of each analysis.
render
¶
render() -> str
The text tsdive switchback analyze prints.
Examples:
>>> import tsdive
>>> plan = tsdive.switchback_plan("2024-06-03T00:00:00Z", "2024-06-04T00:00:00Z",
... block="PT1H", washout="PT15M", seed=7)
>>> archives = ["data/switchback_demo/ti201.parquet",
... "data/switchback_demo/fi200.parquet",
... "data/switchback_demo/tt001.parquet"]
>>> result = tsdive.switchback_analyze(archives, plan, target="TI201.PV",
... covariates=["FI200.PV", "TT001.PV"])
>>> print(result.render().splitlines()[0])
demo:TI201.PV B - A +0.6024 degrees Celsius p 0.154
to_dict
¶
to_dict() -> dict[str, object]
The document tsdive switchback analyze --json prints, ready for json.dumps.
The command adds result_kind and tsdive_version in front.