Skip to content

Commit 206f95b

Browse files
committed
do not use assert and raise instead
1 parent c12053f commit 206f95b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

causalpy/pymc_models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ def fit(self, X, y, coords: Optional[Dict[str, Any]] = None) -> None:
236236
self.build_model(X, y, coords)
237237
with self:
238238
self.idata = pm.sample(**self.sample_kwargs)
239-
assert self.idata is not None
239+
if self.idata is None:
240+
raise RuntimeError("pm.sample() returned None")
240241
self.idata.extend(pm.sample_prior_predictive(random_seed=random_seed))
241242
self.idata.extend(
242243
pm.sample_posterior_predictive(
@@ -350,7 +351,8 @@ def calculate_cumulative_impact(self, impact):
350351
return impact.cumsum(dim="obs_ind")
351352

352353
def print_coefficients(self, labels, round_to=None) -> None:
353-
assert self.idata is not None
354+
if self.idata is None:
355+
raise RuntimeError("Model has not been fit")
354356

355357
def print_row(
356358
max_label_length: int, name: str, coeff_samples: xr.DataArray, round_to: int

0 commit comments

Comments
 (0)