Skip to content

Commit 5a2d4fb

Browse files
committed
Coverage exception recovery
1 parent 5069c7f commit 5a2d4fb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

causal_testing/json_front/json_class.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ def _execute_test_case(
271271
if "coverage" in test and test["coverage"]:
272272
adequacy = DataAdequacy(causal_test_case, causal_test_engine, estimation_model)
273273
effect_estimate, ci_low, ci_high, outcomes = adequacy.measure_adequacy(100)
274-
275274
self._append_to_file(f"KURTOSIS: {effect_estimate.mean()}", logging.INFO)
276275
self._append_to_file(f"PASSING: {sum(outcomes)}/{len(outcomes)}", logging.INFO)
277276

causal_testing/testing/causal_test_adequacy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ def measure_adequacy(self, bootstrap_size: int = 100):
4444
for i in range(bootstrap_size):
4545
estimator = deepcopy(self.estimator)
4646
estimator.df = estimator.df.sample(len(estimator.df), replace=True, random_state=i)
47-
results.append(self.test_engine.execute_test(estimator, self.test_case))
47+
try:
48+
results.append(self.test_engine.execute_test(estimator, self.test_case))
49+
except np.LinAlgError:
50+
continue
4851
outcomes = [self.test_case.expected_causal_effect.apply(c) for c in results]
4952
results = pd.DataFrame(c.to_dict() for c in results)[["effect_estimate", "ci_low", "ci_high"]]
5053

0 commit comments

Comments
 (0)