Skip to content

Commit 39714f2

Browse files
authored
Merge pull request #190 from pymc-labs/small-did-notebook-fix
fix small error in DiD notebook
2 parents ed61617 + d934d9e commit 39714f2

File tree

2 files changed

+34
-112
lines changed

2 files changed

+34
-112
lines changed

causalpy/pymc_experiments.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ def _input_validation(self, data, treatment_time):
134134
)
135135

136136
def plot(self):
137-
138137
"""Plot the results"""
139138
fig, ax = plt.subplots(3, 1, sharex=True, figsize=(7, 8))
140139

@@ -488,7 +487,13 @@ def _plot_causal_impact_arrow(self, ax):
488487
self.y_pred_counterfactual["posterior_predictive"].mu.mean().data
489488
)
490489
# Calculate the x position to plot at
491-
diff = np.ptp(self.x_pred_treatment[self.time_variable_name].values)
490+
# Note that we force to be float to avoid a type error using np.ptp with boolean
491+
# values
492+
diff = np.ptp(
493+
np.array(self.x_pred_treatment[self.time_variable_name].values).astype(
494+
float
495+
)
496+
)
492497
x = np.max(self.x_pred_treatment[self.time_variable_name].values) + 0.1 * diff
493498
# Plot the arrow
494499
ax.annotate(

docs/source/notebooks/did_pymc_banks.ipynb

+27-110
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)