Skip to content

Commit 9e35c06

Browse files
Try & catch type error for different risk_ratio implementations
1 parent 10b773d commit 9e35c06

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

causal_testing/testing/causal_test_engine.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ def _return_causal_test_results(self, estimator, causal_test_case):
162162
)
163163
elif causal_test_case.estimate_type == "risk_ratio":
164164
logger.debug("calculating risk_ratio")
165-
risk_ratio, confidence_intervals = estimator.estimate_risk_ratio(causal_test_case.estimate_params)
165+
try:
166+
risk_ratio, confidence_intervals = estimator.estimate_risk_ratio(causal_test_case.estimate_params)
167+
except TypeError:
168+
risk_ratio, confidence_intervals = estimator.estimate_risk_ratio()
166169
causal_test_result = CausalTestResult(
167170
estimator=estimator,
168171
test_value=TestValue("risk_ratio", risk_ratio),

causal_testing/testing/estimators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def estimate_unit_ate(self) -> float:
360360
ci_high = ci_high[0]
361361
return unit_effect, [ci_low, ci_high]
362362

363-
def estimate_ate(self, estimator_params: dict = None) -> tuple[float, list[float, float], float]:
363+
def estimate_ate(self) -> tuple[float, list[float, float], float]:
364364
"""Estimate the average treatment effect of the treatment on the outcome. That is, the change in outcome caused
365365
by changing the treatment variable from the control value to the treatment value.
366366
@@ -411,7 +411,7 @@ def estimate_control_treatment(self, adjustment_config: dict = None) -> tuple[pd
411411

412412
return y.iloc[1], y.iloc[0]
413413

414-
def estimate_risk_ratio(self, estimator_params: dict = None) -> tuple[float, list[float, float]]:
414+
def estimate_risk_ratio(self) -> tuple[float, list[float, float]]:
415415
"""Estimate the risk_ratio effect of the treatment on the outcome. That is, the change in outcome caused
416416
by changing the treatment variable from the control value to the treatment value.
417417

0 commit comments

Comments
 (0)