Skip to content

[Repo Assist] fix(estimators): default target_units to "ate" in propensity score estimators - #1737

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/fix-ps-estimators-target-units-default-20260804-2c8d6fbbb7920bef
Draft

[Repo Assist] fix(estimators): default target_units to "ate" in propensity score estimators#1737
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/fix-ps-estimators-target-units-default-20260804-2c8d6fbbb7920bef

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🤖 This is an automated PR from Repo Assist, an AI assistant for this repository.

Problem

All three propensity score estimators — PropensityScoreWeightingEstimator, PropensityScoreMatchingEstimator, and PropensityScoreStratificationEstimator — had target_units=None as the default for their estimate_effect() method.

When called without specifying target_units, the None value falls through all if/elif branches and raises:

ValueError: Target units string value not supported
```

or

```
ValueError: Target units value None not supported

This is a latent bug that is hidden in the standard workflow because:

  • CausalModel.estimate_effect() defaults to target_units="ate" and always passes it through
  • The module-level estimate_effect() function also defaults to target_units="ate"

But it becomes visible when a user creates an estimator directly and calls estimate_effect():

estimator = PropensityScoreWeightingEstimator(identified_estimand=...)
estimator.fit(data)
estimator.estimate_effect(data)  # ← raises ValueError: Target units value None not supported

Root Cause

The signature of estimate_effect() in all three propensity score estimators:

# Before (incorrect)
def estimate_effect(self, data, treatment_value=1, control_value=0, target_units=None, **_):

The None default was inconsistent with the calling conventions of both the module-level API (default "ate") and CausalModel (default "ate").

Fix

Changed the default to match the rest of the API:

# After (correct)
def estimate_effect(self, data, treatment_value=1, control_value=0, target_units: str = "ate", **_):

Files changed:

  • dowhy/causal_estimators/propensity_score_weighting_estimator.py
  • dowhy/causal_estimators/propensity_score_matching_estimator.py
  • dowhy/causal_estimators/propensity_score_stratification_estimator.py

Tests

Three regression tests added to tests/causal_estimators/test_propensity_score_weighting_estimator.py:

  • test_psw_estimate_effect_default_target_units_does_not_raise — PSW estimator
  • test_psm_estimate_effect_default_target_units_does_not_raise — PSM estimator
  • test_pss_estimate_effect_default_target_units_does_not_raise — PSS estimator

Each test creates a minimal confounded binary-treatment dataset, fits the estimator, and calls estimate_effect(data) without specifying target_units — verifying no exception is raised and the result is finite.

Test Status

Format: ✅ black --check passes (no changes needed to source files).
Lint: ✅ No new hard flake8 errors (E9/F63/F7/F82). Pre-existing soft warnings (E501 line length) in the estimator files are unchanged.
Tests: ⏳ CI blocked pending maintainer approval of bot PR — test suite cannot be executed in this environment (missing Poetry/venv). The fix logic has been verified against the code path.

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

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

Generated by 🌈 Repo Assist, see workflow run. Learn more.

To install this agentic workflow, run

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

…timators

All three propensity score estimators (Weighting, Matching, Stratification)
had target_units=None as the default in their estimate_effect() method.
When called without specifying target_units, the None value fell through
all the if/elif branches and raised:
  ValueError("Target units string value not supported")

The module-level estimate_effect() and CausalModel.estimate_effect()
both default to target_units="ate", so the natural expectation when
calling an estimator directly is the same default.

Fix: change target_units=None to target_units: str = "ate" in all three
propensity score estimators.

Add regression tests in test_propensity_score_weighting_estimator.py
to verify that calling estimate_effect() without target_units succeeds
for all three estimators.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@github-actions github-actions Bot added automation bug Something isn't working repo-assist labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation bug Something isn't working repo-assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants