Skip to content

Commit 6a6face

Browse files
committed
renamed get_plot_data_bayesian to _get_plot_data_bayesian, get_plot_data_ols to _get_plot_data_ols, bayesian_plot to _bayesian_plot, and ols_plot to _ols_plot
1 parent 6dca884 commit 6a6face

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

causalpy/experiments/base.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,45 +60,45 @@ def print_coefficients(self, round_to=None):
6060
def plot(self, *args, **kwargs) -> tuple:
6161
"""Plot the model.
6262
63-
Internally, this function dispatches to either `bayesian_plot` or `ols_plot`
63+
Internally, this function dispatches to either `_bayesian_plot` or `_ols_plot`
6464
depending on the model type.
6565
"""
6666
if isinstance(self.model, PyMCModel):
67-
return self.bayesian_plot(*args, **kwargs)
67+
return self._bayesian_plot(*args, **kwargs)
6868
elif isinstance(self.model, RegressorMixin):
69-
return self.ols_plot(*args, **kwargs)
69+
return self._ols_plot(*args, **kwargs)
7070
else:
7171
raise ValueError("Unsupported model type")
7272

7373
@abstractmethod
74-
def bayesian_plot(self, *args, **kwargs):
74+
def _bayesian_plot(self, *args, **kwargs):
7575
"""Abstract method for plotting the model."""
76-
raise NotImplementedError("bayesian_plot method not yet implemented")
76+
raise NotImplementedError("_bayesian_plot method not yet implemented")
7777

7878
@abstractmethod
79-
def ols_plot(self, *args, **kwargs):
79+
def _ols_plot(self, *args, **kwargs):
8080
"""Abstract method for plotting the model."""
81-
raise NotImplementedError("ols_plot method not yet implemented")
81+
raise NotImplementedError("_ols_plot method not yet implemented")
8282

8383
def get_plot_data(self, *args, **kwargs) -> pd.DataFrame:
8484
"""Recover the data of a PrePostFit experiment along with the prediction and causal impact information.
8585
86-
Internally, this function dispatches to either `get_plot_data_bayesian` or `get_plot_data_ols`
86+
Internally, this function dispatches to either `_get_plot_data_bayesian` or `_get_plot_data_ols`
8787
depending on the model type.
8888
"""
8989
if isinstance(self.model, PyMCModel):
90-
return self.get_plot_data_bayesian(*args, **kwargs)
90+
return self._get_plot_data_bayesian(*args, **kwargs)
9191
elif isinstance(self.model, RegressorMixin):
92-
return self.get_plot_data_ols(*args, **kwargs)
92+
return self._get_plot_data_ols(*args, **kwargs)
9393
else:
9494
raise ValueError("Unsupported model type")
9595

9696
@abstractmethod
97-
def get_plot_data_bayesian(self, *args, **kwargs):
97+
def _get_plot_data_bayesian(self, *args, **kwargs):
9898
"""Abstract method for recovering plot data."""
99-
raise NotImplementedError("get_plot_data_bayesian method not yet implemented")
99+
raise NotImplementedError("_get_plot_data_bayesian method not yet implemented")
100100

101101
@abstractmethod
102-
def get_plot_data_ols(self, *args, **kwargs):
102+
def _get_plot_data_ols(self, *args, **kwargs):
103103
"""Abstract method for recovering plot data."""
104-
raise NotImplementedError("get_plot_data_ols method not yet implemented")
104+
raise NotImplementedError("_get_plot_data_ols method not yet implemented")

causalpy/experiments/diff_in_diff.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _causal_impact_summary_stat(self, round_to=None) -> str:
229229
"""Computes the mean and 94% credible interval bounds for the causal impact."""
230230
return f"Causal impact = {convert_to_string(self.causal_impact, round_to=round_to)}"
231231

232-
def bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
232+
def _bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
233233
"""
234234
Plot the results
235235
@@ -367,7 +367,7 @@ def _plot_causal_impact_arrow(results, ax):
367367
)
368368
return fig, ax
369369

370-
def ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
370+
def _ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
371371
"""Generate plot for difference-in-differences"""
372372
round_to = kwargs.get("round_to")
373373
fig, ax = plt.subplots()

causalpy/experiments/prepostfit.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def summary(self, round_to=None) -> None:
123123
print(f"Formula: {self.formula}")
124124
self.print_coefficients(round_to)
125125

126-
def bayesian_plot(
126+
def _bayesian_plot(
127127
self, round_to=None, **kwargs
128128
) -> tuple[plt.Figure, List[plt.Axes]]:
129129
"""
@@ -231,7 +231,7 @@ def bayesian_plot(
231231

232232
return fig, ax
233233

234-
def ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]:
234+
def _ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]:
235235
"""
236236
Plot the results
237237
@@ -303,7 +303,7 @@ def ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]
303303

304304
return (fig, ax)
305305

306-
def get_plot_data_bayesian(self, hdi_prob: float = 0.94) -> pd.DataFrame:
306+
def _get_plot_data_bayesian(self, hdi_prob: float = 0.94) -> pd.DataFrame:
307307
"""
308308
Recover the data of a PrePostFit experiment along with the prediction and causal impact information.
309309
"""
@@ -343,7 +343,7 @@ def get_plot_data_bayesian(self, hdi_prob: float = 0.94) -> pd.DataFrame:
343343
else:
344344
raise ValueError("Unsupported model type")
345345

346-
def get_plot_data_ols(self) -> pd.DataFrame:
346+
def _get_plot_data_ols(self) -> pd.DataFrame:
347347
"""
348348
Recover the data of a PrePostFit experiment along with the prediction and causal impact information.
349349
"""
@@ -436,7 +436,7 @@ class SyntheticControl(PrePostFit):
436436
supports_ols = True
437437
supports_bayes = True
438438

439-
def bayesian_plot(self, *args, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]:
439+
def _bayesian_plot(self, *args, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]:
440440
"""
441441
Plot the results
442442
@@ -447,7 +447,7 @@ def bayesian_plot(self, *args, **kwargs) -> tuple[plt.Figure, List[plt.Axes]]:
447447
Whether to plot the control units as well. Defaults to False.
448448
"""
449449
# call the super class method
450-
fig, ax = super().bayesian_plot(*args, **kwargs)
450+
fig, ax = super()._bayesian_plot(*args, **kwargs)
451451

452452
# additional plotting functionality for the synthetic control experiment
453453
plot_predictors = kwargs.get("plot_predictors", False)

causalpy/experiments/prepostnegd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def summary(self, round_to=None) -> None:
200200
print(self._causal_impact_summary_stat(round_to))
201201
self.print_coefficients(round_to)
202202

203-
def bayesian_plot(
203+
def _bayesian_plot(
204204
self, round_to=None, **kwargs
205205
) -> tuple[plt.Figure, List[plt.Axes]]:
206206
"""Generate plot for ANOVA-like experiments with non-equivalent group designs."""

causalpy/experiments/regression_discontinuity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def summary(self, round_to=None) -> None:
218218
print("\n")
219219
self.print_coefficients(round_to)
220220

221-
def bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
221+
def _bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
222222
"""Generate plot for regression discontinuity designs."""
223223
fig, ax = plt.subplots()
224224
# Plot raw data
@@ -267,7 +267,7 @@ def bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
267267
)
268268
return (fig, ax)
269269

270-
def ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
270+
def _ols_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
271271
"""Generate plot for regression discontinuity designs."""
272272
fig, ax = plt.subplots()
273273
# Plot raw data

causalpy/experiments/regression_kink.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def summary(self, round_to=None) -> None:
189189
)
190190
self.print_coefficients(round_to)
191191

192-
def bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
192+
def _bayesian_plot(self, round_to=None, **kwargs) -> tuple[plt.Figure, plt.Axes]:
193193
"""Generate plot for regression kink designs."""
194194
fig, ax = plt.subplots()
195195
# Plot raw data

0 commit comments

Comments
 (0)