Skip to content

Remove deprecated design-matrix alias shims (follow-up to #849)#958

Draft
drbenvincent wants to merge 8 commits into
mainfrom
remove-design-alias-deprecation-shims
Draft

Remove deprecated design-matrix alias shims (follow-up to #849)#958
drbenvincent wants to merge 8 commits into
mainfrom
remove-design-alias-deprecation-shims

Conversation

@drbenvincent

Copy link
Copy Markdown
Collaborator

Summary

  • Removes the backward-compatibility layer introduced in Consolidate experiment design-matrix attributes into xr.Dataset #849: the BaseExperiment.__getattr__ deprecation forwarding, the declarative _deprecated_design_aliases mappings on each experiment class, and the test_deprecated_design_aliases.py compatibility test suite.
  • After this lands, the old attribute names (X, y, pre_X, pre_y, post_X, post_y, datapre_control, datapre_treated, datapost_control, datapost_treated) raise AttributeError on the migrated experiment classes; use design[...], pre_design[...] and post_design[...] instead.

Do not merge until

Test plan

  • Full test suite passes (1084 passed) with the shims removed, confirming no internal code depends on the deprecated aliases
  • prek run --all-files passes
  • Docs notebooks contain no references to the removed aliases (only iv_pymc.ipynb uses .X, and InstrumentalVariable was never migrated/deprecated)

Made with Cursor

drbenvincent and others added 8 commits April 15, 2026 20:32
Add _predictor_data_name and _target_data_name class attributes to
PyMCModel so subclasses using non-default data node names can
customize without re-implementing _data_setter. Validate at predict
time and raise a clear ValueError if expected nodes are missing.

Also fix pre-existing mypy type: ignore codes in panel_regression.py
(attr-defined -> union-attr).

Made-with: Cursor
Remove _predictor_data_name / _target_data_name class attributes
(added complexity for a case no existing subclass needs). Keep the
validation that raises a clear ValueError when expected data nodes
are missing. Revert undeclared y_dtype behavioral change. Improve
test coverage with separate X-missing and y-missing error paths.

Made-with: Cursor
Bundle loose xr.DataArray attributes on experiment classes into
xr.Dataset objects to reduce attribute sprawl. Pre/post classes
(ITS, SC) use pre_design/post_design; formula-based classes use
a single design Dataset. Deprecated @Property accessors preserve
backward compatibility. Closes #199.

Made-with: Cursor
Move _build_design_dataset helper and __getattr__ deprecation forwarding
into BaseExperiment, replacing per-class @Property blocks with a
declarative _deprecated_design_aliases dict. Fix convex_hull.py and
maketables_adapters.py to use the new API directly. Add parametrized
backward-compatibility tests covering all deprecated aliases.

Made-with: Cursor
…y-datasets

Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	causalpy/experiments/base.py
#	causalpy/experiments/diff_in_diff.py
#	causalpy/experiments/panel_regression.py
#	causalpy/experiments/piecewise_its.py
#	causalpy/pymc_models.py
- Migrate SyntheticDifferenceInDifferences (added on main in #823) to the pre_design/post_design Dataset pattern with deprecated aliases, matching SyntheticControl, and extend the alias test suite to cover it.
- Normalize convex-hull call sites on xarray inputs and document that check_convex_hull_violation accepts numpy or xarray.
- Replace type: ignore escape hatches in ConvexHullCheck.run with an isinstance assertion that narrows the type for mypy.
- Point users at BayesianBasisExpansionTimeSeries in the _data_setter error message.

Co-authored-by: Cursor <cursoragent@cursor.com>
Removes the BaseExperiment.__getattr__ deprecation forwarding, the per-class _deprecated_design_aliases mappings, and the backward-compatibility test suite introduced in #849. After this lands, the old attribute names (X, y, pre_X, pre_y, post_X, post_y, datapre_control, datapre_treated, datapost_control, datapost_treated) raise AttributeError; use design[...], pre_design[...] and post_design[...] instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.13%. Comparing base (0197f17) to head (82be770).

Files with missing lines Patch % Lines
causalpy/tests/test_pymc_models.py 93.18% 2 Missing and 1 partial ⚠️
causalpy/experiments/base.py 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #958      +/-   ##
==========================================
- Coverage   95.14%   95.13%   -0.01%     
==========================================
  Files          92       92              
  Lines       14860    14938      +78     
  Branches      890      895       +5     
==========================================
+ Hits        14138    14212      +74     
- Misses        505      507       +2     
- Partials      217      219       +2     

☔ 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.

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