Skip to content

Commit b162d8f

Browse files
authored
Merge pull request #336 from CITCOM-project/jmafoster1/114-validate-treatment-outcome
Validation to check that outcome and treatment aren't the same
2 parents ac8005f + f2392dd commit b162d8f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

causal_testing/testing/base_test_case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ class BaseTestCase:
1717
treatment_variable: Variable
1818
outcome_variable: Variable
1919
effect: str = Effect.TOTAL.value
20+
21+
def __post_init__(self):
22+
if self.treatment_variable == self.outcome_variable:
23+
raise ValueError(f"Treatment variable {self.treatment_variable} cannot also be the outcome variable.")

tests/testing_tests/test_causal_test_case.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def setUp(self) -> None:
9898
def tearDown(self) -> None:
9999
shutil.rmtree(self.temp_dir_path)
100100

101+
def test_invalid_base_test_case(self):
102+
with self.assertRaises(ValueError):
103+
BaseTestCase(self.A, self.A)
104+
101105
def test_check_minimum_adjustment_set(self):
102106
"""Check that the minimum adjustment set is correctly made"""
103107
minimal_adjustment_set = self.causal_dag.identification(self.base_test_case_A_C)

0 commit comments

Comments
 (0)