Skip to content

[Repo Assist] test: add tests for RandomCommonCause refuter#1413

Open
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/test-random-common-cause-refuter-2b4c3976fb68d46d
Open

[Repo Assist] test: add tests for RandomCommonCause refuter#1413
github-actions[bot] wants to merge 2 commits intomainfrom
repo-assist/test-random-common-cause-refuter-2b4c3976fb68d46d

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist.

Summary

The RandomCommonCause refuter (method_name="random_common_cause") had zero test coverage — no test file existed for it, and tests/causal_refuters/base.py had no handler for it either. This PR fills that gap.

Changes

tests/causal_refuters/test_random_common_cause_refuter.py (new file)

Six tests covering:

Test What it checks
test_refutation_random_common_cause_continuous Continuous treatment via SimpleRefuter — estimate stays within 10% tolerance after introducing random confounder
test_refutation_random_common_cause_binary Binary treatment via SimpleRefuter
test_refutation_random_common_cause_category Categorical treatment via SimpleRefuter
test_refutation_random_common_cause_refutation_type ref.refutation_type contains the expected string
test_refute_random_common_cause_functional_api Calls refute_random_common_cause() directly, verifies non-None finite result
test_refute_random_common_cause_reproducible_with_random_state Same random_state=0 seed produces identical new_effect on two runs

tests/causal_refuters/base.py

Adds a random_common_cause branch in SimpleRefuter.null_refutation_test() so SimpleRefuter can drive this refuter — matching the existing pattern for bootstrap_refuter, data_subset_refuter, etc.

Test Status

✅ All 6 new tests pass locally:

6 passed in 5.09s

No existing tests were changed or broken.

Generated by Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@b897c2f3e43bde9ff7923c8fa9211055b26e27cc

The `random_common_cause` refuter had no dedicated test file. This
commit adds `tests/causal_refuters/test_random_common_cause_refuter.py`
with 6 tests covering:

- Continuous treatment (linear regression)
- Binary treatment (linear regression)
- Categorical treatment (linear regression)
- Refutation type string validation
- Functional API (`refute_random_common_cause` directly)
- Reproducibility with fixed `random_state`

Also adds the corresponding handler in `tests/causal_refuters/base.py`
so `SimpleRefuter` can drive the refuter via `null_refutation_test()`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@emrekiciman emrekiciman marked this pull request as ready for review March 23, 2026 00:06
@emrekiciman emrekiciman marked this pull request as draft March 25, 2026 05:09
@emrekiciman emrekiciman marked this pull request as ready for review March 25, 2026 05:09
@emrekiciman
Copy link
Copy Markdown
Member

failing linter

Run poetry run poe format_check
Poe => black --check .
would reformat /home/runner/work/dowhy/dowhy/tests/causal_refuters/test_random_common_cause_refuter.py

Oh no! 💥 💔 💥
1 file would be reformatted, 251 files would be left unchanged.
Poe => isort --check .
Skipped 1 files
Error: Subtask '_black_check' returned non-zero exit status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant