Skip to content

Commit af5c78d

Browse files
committed
Updating doctest
1 parent ed6d759 commit af5c78d

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

causalpy/experiments/interrupted_time_series.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,15 +1275,26 @@ def analyze_persistence(
12751275
12761276
Examples
12771277
--------
1278+
>>> import causalpy as cp
1279+
>>> import pandas as pd
1280+
>>> df = (
1281+
... cp.load_data("its")
1282+
... .assign(date=lambda x: pd.to_datetime(x["date"]))
1283+
... .set_index("date")
1284+
... )
12781285
>>> result = cp.InterruptedTimeSeries(
12791286
... df,
1280-
... treatment_time=pd.Timestamp("2024-01-01"),
1281-
... treatment_end_time=pd.Timestamp("2024-04-01"),
1282-
... formula="y ~ 1 + t",
1287+
... treatment_time=pd.Timestamp("2017-01-01"),
1288+
... treatment_end_time=pd.Timestamp("2017-06-01"),
1289+
... formula="y ~ 1 + t + C(month)",
1290+
... model=cp.pymc_models.LinearRegression(
1291+
... sample_kwargs={"random_seed": 42, "progressbar": False}
1292+
... ),
12831293
... )
1284-
>>> persistence = result.analyze_persistence()
1285-
>>> # Results are automatically printed
1286-
>>> print(f"Persistence ratio: {persistence['persistence_ratio']:.2f}")
1294+
>>> persistence = result.analyze_persistence() # doctest: +SKIP
1295+
... # Note: Results are automatically printed to console
1296+
>>> persistence["persistence_ratio"] # doctest: +SKIP
1297+
-1.224
12871298
"""
12881299
if self.treatment_end_time is None:
12891300
raise ValueError(

0 commit comments

Comments
 (0)