Skip to content

Commit d6e058c

Browse files
committed
change all asserts outside of tests into checks which raise exceptions
1 parent 100784f commit d6e058c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

causalpy/expt_diff_in_diff.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def __init__(
113113
.first()
114114
.reset_index()
115115
)
116-
assert not self.x_pred_control.empty
116+
if self.x_pred_control.empty:
117+
raise ValueError("x_pred_control is empty")
117118
(new_x,) = build_design_matrices([self._x_design_info], self.x_pred_control)
118119
self.y_pred_control = self.model.predict(np.asarray(new_x))
119120

@@ -129,7 +130,8 @@ def __init__(
129130
.first()
130131
.reset_index()
131132
)
132-
assert not self.x_pred_treatment.empty
133+
if self.x_pred_treatment.empty:
134+
raise ValueError("x_pred_treatment is empty")
133135
(new_x,) = build_design_matrices([self._x_design_info], self.x_pred_treatment)
134136
self.y_pred_treatment = self.model.predict(np.asarray(new_x))
135137

@@ -148,7 +150,8 @@ def __init__(
148150
.first()
149151
.reset_index()
150152
)
151-
assert not self.x_pred_counterfactual.empty
153+
if self.x_pred_counterfactual.empty:
154+
raise ValueError("x_pred_counterfactual is empty")
152155
(new_x,) = build_design_matrices(
153156
[self._x_design_info], self.x_pred_counterfactual, return_type="dataframe"
154157
)

0 commit comments

Comments
 (0)