@@ -140,7 +140,7 @@ def algorithm(self) -> None:
140140 },
141141 ).set_xindex ("period" )
142142
143- # 4. Calculate unified impact with period coordinate - no more splitting!
143+ # 4. Calculate impact
144144 if isinstance (self .model , PyMCModel ):
145145 # Calculate impact for the entire time series at once
146146 self .impact = self .model .calculate_impact (self .data .y , self .predictions )
@@ -235,17 +235,6 @@ def post_y(self) -> xr.DataArray:
235235 """Post-intervention outcomes."""
236236 return self .data .y .sel (period = "post" )
237237
238- # Simple backward-compatible properties for impact only (still used in plotting)
239- @property
240- def pre_impact (self ):
241- """Pre-intervention impact (backward compatibility)."""
242- return self .impact .sel (period = "pre" )
243-
244- @property
245- def post_impact (self ):
246- """Post-intervention impact (backward compatibility)."""
247- return self .impact .sel (period = "post" )
248-
249238 def input_validation (self , data , treatment_time ):
250239 """Validate the input data and model formula for correctness"""
251240 if isinstance (data .index , pd .DatetimeIndex ) and not isinstance (
@@ -351,20 +340,22 @@ def _bayesian_plot(
351340 # MIDDLE PLOT -----------------------------------------------
352341 plot_xY (
353342 self .pre_X .obs_ind ,
354- self .pre_impact .isel (treated_units = 0 ),
343+ self .impact . sel ( period = "pre" ) .isel (treated_units = 0 ),
355344 ax = ax [1 ],
356345 plot_hdi_kwargs = {"color" : "C0" },
357346 )
358347 plot_xY (
359348 self .post_X .obs_ind ,
360- self .post_impact .isel (treated_units = 0 ),
349+ self .impact . sel ( period = "post" ) .isel (treated_units = 0 ),
361350 ax = ax [1 ],
362351 plot_hdi_kwargs = {"color" : "C1" },
363352 )
364353 ax [1 ].axhline (y = 0 , c = "k" )
365354 ax [1 ].fill_between (
366355 self .post_X .obs_ind ,
367- y1 = self .post_impact .mean (["chain" , "draw" ]).isel (treated_units = 0 ),
356+ y1 = self .impact .sel (period = "post" )
357+ .mean (["chain" , "draw" ])
358+ .isel (treated_units = 0 ),
368359 color = "C0" ,
369360 alpha = 0.25 ,
370361 label = "Causal impact" ,
@@ -448,10 +439,10 @@ def _ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, List[plt.Axes]
448439 title = f"$R^2$ on pre-intervention data = { round_num (self .score , round_to )} "
449440 )
450441
451- ax [1 ].plot (self .pre_X .obs_ind , self .pre_impact , "k." )
442+ ax [1 ].plot (self .pre_X .obs_ind , self .impact . sel ( period = "pre" ) , "k." )
452443 ax [1 ].plot (
453444 self .post_X .obs_ind ,
454- self .post_impact ,
445+ self .impact . sel ( period = "post" ) ,
455446 "k." ,
456447 label = counterfactual_label ,
457448 )
@@ -473,7 +464,7 @@ def _ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, List[plt.Axes]
473464 )
474465 ax [1 ].fill_between (
475466 self .post_X .obs_ind ,
476- y1 = np .squeeze (self .post_impact ),
467+ y1 = np .squeeze (self .impact . sel ( period = "post" ) ),
477468 color = "C0" ,
478469 alpha = 0.25 ,
479470 label = "Causal impact" ,
0 commit comments