Skip to content

Lock SDiD synthetic trajectory under joint reordering of controls and weights - #1210

Merged
drbenvincent merged 3 commits into
pymc6_and_pymcmarketing1_migrationfrom
feat/sdid-reorder-controls
Sep 26, 2026
Merged

drbenvincent merged 3 commits into
pymc6_and_pymcmarketing1_migrationfrom
feat/sdid-reorder-controls

Conversation

@drbenvincent

Copy link
Copy Markdown
Collaborator

Closes #1203

Summary

  • Add a regression test that permuting control units and applying the same permutation to the unit weights leaves the synthetic trajectory unchanged.
  • Leave _compute_synthetic_and_gaps unchanged.

Test plan

  • pytest causalpy/tests/test_sdid_helpers.py::TestComputeSyntheticAndGaps --no-cov

Made with Cursor

… weights.

The einsum formula is invariant to that permutation, and no test asserted it.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the bug Something isn't working label Sep 26, 2026

@drbenvincent drbenvincent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: PR 1210 vs issue #1203

Verdict: APPROVE (posted as a comment because GitHub disallows self-approval on this PR).

Definition of done (issue #1203)

  • Add a regression test that a joint permutation of control rows and the omega unit axis leaves sc_all unchanged.
  • Do not change _compute_synthetic_and_gaps.

Assessment

This PR meets the definition of done.

Evidence

  • Diff touches only causalpy/tests/test_sdid_helpers.py (+21). Production helper is untouched.
  • New test TestComputeSyntheticAndGaps::test_joint_reordering_of_controls_and_weights_is_invariant matches the issue probe: omega shape (2, 4, 5), fixed perm [3, 0, 4, 1, 2], joint reorder via omega[..., perm] and Y_co[perm], assert on sc_all.
  • Locally: pytest causalpy/tests/test_sdid_helpers.py::TestComputeSyntheticAndGaps --no-cov → 2 passed.

Findings by file

No correctness, contract, or DoD gaps found.

Residual notes (non-blocking)

  • atol=1e-12 is looser than the issue’s observed ~1e-15 max abs diff; still appropriate for float invariance and not flaky.
  • Gaps are not asserted; that is fine because #1203 only requires sc_all invariance.
  • pre-commit.ci - pr reported failure while the repo prek check succeeded; unrelated to this test-only change.

Verdict

APPROVE — regression lock for the claimed invariance is in place without modifying _compute_synthetic_and_gaps.

@drbenvincent
drbenvincent marked this pull request as ready for review September 26, 2026 14:31
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.15%. Comparing base (a931037) to head (4b0eba1).

Additional details and impacted files
@@                         Coverage Diff                         @@
##           pymc6_and_pymcmarketing1_migration    #1210   +/-   ##
===================================================================
  Coverage                               97.14%   97.15%           
===================================================================
  Files                                     130      130           
  Lines                                   24033    24044   +11     
  Branches                                 1349     1349           
===================================================================
+ Hits                                    23348    23359   +11     
  Misses                                    477      477           
  Partials                                  208      208           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@drbenvincent drbenvincent added tests Add or strengthen tests for behavior that is already correct and removed bug Something isn't working labels Sep 26, 2026
@daimon-pymclabs
daimon-pymclabs changed the base branch from main to pymc6_and_pymcmarketing1_migration September 26, 2026 16:01
…der-controls

Bring the branch up to date after #1214 synced main into the migration branch.
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 causalpy | 🛠️ Build #34779050 | 📁 Comparing 4b0eba1 against latest (89f18de)

  🔍 Preview build  

397 files changed · + 126 added · ± 251 modified · - 20 deleted

+ Added

± Modified

- Deleted

@drbenvincent
drbenvincent merged commit f8fa199 into pymc6_and_pymcmarketing1_migration Sep 26, 2026
16 checks passed
@drbenvincent
drbenvincent deleted the feat/sdid-reorder-controls branch September 26, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Add or strengthen tests for behavior that is already correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lock SDiD synthetic trajectory under joint reordering of controls and weights

1 participant