Skip to content

Update notebooks to use new xr.Dataset API #848

@drbenvincent

Description

@drbenvincent

Depends on: #849 must be merged first.

Update notebooks to use new xr.Dataset API

Following the consolidation of experiment design-matrix attributes into xr.Dataset objects (#199), the old attribute names (pre_X, pre_y, post_X, post_y, datapre_control, datapre_treated, datapost_control, datapost_treated, X, y) are deprecated. They still work via backward-compatible @property accessors that emit DeprecationWarning, but notebooks should be migrated to the new API.

New API

Experiment type Old attributes New access pattern
InterruptedTimeSeries result.pre_X, result.pre_y, result.post_X, result.post_y result.pre_design["X"], result.pre_design["y"], result.post_design["X"], result.post_design["y"]
SyntheticControl result.datapre_control, result.datapre_treated, result.datapost_control, result.datapost_treated result.pre_design["control"], result.pre_design["treated"], result.post_design["control"], result.post_design["treated"]
Formula-based (DiD, RD, RK, PrePostNEGD, PiecewiseITS, PanelRegression) result.X, result.y result.design["X"], result.design["y"]

Affected notebooks

These notebooks access deprecated attributes directly and should be updated:

  • docs/source/notebooks/did_pymc.ipynbresult.causal_impact (not deprecated, but review for other attrs)
  • docs/source/notebooks/did_pymc_banks.ipynbresult.causal_impact
  • docs/source/notebooks/rd_donut_pymc.ipynbresult.discontinuity_at_threshold, result.fit_data
  • docs/source/notebooks/its_pymc.ipynbresult.post_impact, result.datapost
  • docs/source/notebooks/sc_pymc.ipynbresult.post_impact_cumulative
  • docs/source/notebooks/geolift1.ipynbresult.post_impact_cumulative

Notes

  • The deprecated properties will be removed in a future release.
  • Notebooks should be re-run after updating to verify outputs are unchanged.
  • Some notebooks may access attributes that were not deprecated (e.g., result.causal_impact, result.post_impact); these should be reviewed but may not need changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions