Skip to content

Validation to check that outcome and treatment aren't the same #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions causal_testing/testing/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ class BaseTestCase:
treatment_variable: Variable
outcome_variable: Variable
effect: str = Effect.TOTAL.value

def __post_init__(self):
if self.treatment_variable == self.outcome_variable:
raise ValueError(f"Treatment variable {self.treatment_variable} cannot also be the outcome variable.")
4 changes: 4 additions & 0 deletions tests/testing_tests/test_causal_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def setUp(self) -> None:
def tearDown(self) -> None:
shutil.rmtree(self.temp_dir_path)

def test_invalid_base_test_case(self):
with self.assertRaises(ValueError):
BaseTestCase(self.A, self.A)

def test_check_minimum_adjustment_set(self):
"""Check that the minimum adjustment set is correctly made"""
minimal_adjustment_set = self.causal_dag.identification(self.base_test_case_A_C)
Expand Down