Skip to content

Commit 5e53871

Browse files
committed
Fixed linalg error
1 parent 979e005 commit 5e53871

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

causal_testing/testing/causal_test_case.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,23 @@ def _return_causal_test_results(self, estimator) -> CausalTestResult:
7979
if not hasattr(estimator, f"estimate_{self.estimate_type}"):
8080
raise AttributeError(f"{estimator.__class__} has no {self.estimate_type} method.")
8181
estimate_effect = getattr(estimator, f"estimate_{self.estimate_type}")
82-
effect, confidence_intervals = estimate_effect(**self.estimate_params)
83-
causal_test_result = CausalTestResult(
84-
estimator=estimator,
85-
test_value=TestValue(self.estimate_type, effect),
86-
effect_modifier_configuration=self.effect_modifier_configuration,
87-
confidence_intervals=confidence_intervals,
88-
)
89-
90-
return causal_test_result
82+
try:
83+
effect, confidence_intervals = estimate_effect(**self.estimate_params)
84+
causal_test_result = CausalTestResult(
85+
estimator=estimator,
86+
test_value=TestValue(self.estimate_type, effect),
87+
effect_modifier_configuration=self.effect_modifier_configuration,
88+
confidence_intervals=confidence_intervals,
89+
)
90+
except np.linalg.LinAlgError:
91+
causal_test_result = CausalTestResult(
92+
estimator=estimator,
93+
test_value=TestValue(self.estimate_type, "LinAlgError"),
94+
effect_modifier_configuration=self.effect_modifier_configuration,
95+
confidence_intervals=None,
96+
)
97+
finally:
98+
return causal_test_result
9199

92100
def __str__(self):
93101
treatment_config = {self.treatment_variable.name: self.treatment_value}

0 commit comments

Comments
 (0)