Skip to content

Commit 368b1b2

Browse files
Raise specific exceptions
1 parent e76b1e0 commit 368b1b2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

causal_testing/testing/causal_test_engine.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def execute_test_suite(self, test_suite: CausalTestSuite) -> list[CausalTestResu
6060
causal_test_result objects
6161
"""
6262
if self.scenario_execution_data_df.empty:
63-
raise Exception("No data has been loaded. Please call load_data prior to executing a causal test case.")
63+
raise ValueError("No data has been loaded. Please call load_data prior to executing a causal test case.")
6464
test_suite_results = {}
6565
for edge in test_suite:
6666
print("edge: ")
@@ -75,7 +75,7 @@ def execute_test_suite(self, test_suite: CausalTestSuite) -> list[CausalTestResu
7575
list(minimal_adjustment_set) + [edge.treatment_variable.name] + [edge.outcome_variable.name]
7676
)
7777
if self._check_positivity_violation(variables_for_positivity):
78-
raise Exception("POSITIVITY VIOLATION -- Cannot proceed.")
78+
raise ValueError("POSITIVITY VIOLATION -- Cannot proceed.")
7979

8080
estimators = test_suite[edge]["estimators"]
8181
tests = test_suite[edge]["tests"]
@@ -122,7 +122,7 @@ def execute_test(
122122
:return causal_test_result: A CausalTestResult for the executed causal test case.
123123
"""
124124
if self.scenario_execution_data_df.empty:
125-
raise Exception("No data has been loaded. Please call load_data prior to executing a causal test case.")
125+
raise ValueError("No data has been loaded. Please call load_data prior to executing a causal test case.")
126126
if estimator.df is None:
127127
estimator.df = self.scenario_execution_data_df
128128
treatment_variable = causal_test_case.treatment_variable
@@ -138,7 +138,7 @@ def execute_test(
138138
variables_for_positivity = list(minimal_adjustment_set) + [treatment_variable.name] + [outcome_variable.name]
139139

140140
if self._check_positivity_violation(variables_for_positivity):
141-
raise Exception("POSITIVITY VIOLATION -- Cannot proceed.")
141+
raise ValueError("POSITIVITY VIOLATION -- Cannot proceed.")
142142

143143
causal_test_result = self._return_causal_test_results(estimate_type, estimator, causal_test_case)
144144
return causal_test_result

causal_testing/testing/estimators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ def estimate_cates(self) -> pd.DataFrame:
611611
if self.effect_modifiers:
612612
effect_modifier_df = reduced_df[list(self.effect_modifiers)]
613613
else:
614-
raise Exception("CATE requires the user to define a set of effect modifiers.")
614+
raise ValueError("CATE requires the user to define a set of effect modifiers.")
615615

616616
if self.adjustment_set:
617617
confounders_df = reduced_df[list(self.adjustment_set)]

0 commit comments

Comments
 (0)