Skip to content

Update AGENTS backwards compatibility guidance#685

Closed
drbenvincent wants to merge 9 commits intomainfrom
issue-684-avoid-back-compat
Closed

Update AGENTS backwards compatibility guidance#685
drbenvincent wants to merge 9 commits intomainfrom
issue-684-avoid-back-compat

Conversation

@drbenvincent
Copy link
Collaborator

@drbenvincent drbenvincent commented Jan 24, 2026

Summary

Clarify that backwards compatibility should only be preserved for released APIs, not for APIs introduced within the same PR.

Fixes #684

Changes

  • Document the backwards compatibility guidance in AGENTS.md.

Testing

  • Not run (documentation-only change).

Checklist

  • Pre-commit checks pass
  • All tests pass
  • Documentation updated (if applicable)
  • Follows project coding conventions

📚 Documentation preview 📚: https://causalpy--685.org.readthedocs.build/en/685/

Fixes #295

This adds an hdi_type parameter to _bayesian_plot methods across all
experiment classes, allowing users to choose between:

- 'expectation': HDI of model expectation (μ), excluding observation noise
  (default, current behavior)
- 'prediction': HDI of posterior predictive (ŷ), including observation noise

Changes:
- Add HdiType type alias and add_hdi_annotation() helper to plot_utils.py
- Update _bayesian_plot() methods in:
  - InterruptedTimeSeries
  - SyntheticControl
  - DifferenceInDifferences
  - PrePostNEGD
  - RegressionDiscontinuity
  - RegressionKink
- Add text annotation to figures explaining what the HDI represents
- Update docstrings with comprehensive parameter documentation
- Move annotation text lower to avoid overlap with axis labels
- Add subplots_adjust to make room for annotation below axes
- Add show_hdi_annotation parameter (default True) to all _bayesian_plot methods
- Users can set show_hdi_annotation=False to hide the text annotation
Introduces the hdi_type parameter to allow users to choose between 'expectation' (model mean, excluding observation noise) and 'prediction' (posterior predictive, including observation noise) for HDI intervals in plots, effect summaries, and data extraction methods. Updates plotting and reporting utilities to support this option, adds logging and annotation for HDI type, and refactors experiment classes to calculate impacts and counterfactuals on demand based on hdi_type. Documentation and notebook examples are updated to reflect these changes.
- Add comprehensive tests in test_hdi_type.py for hdi_type='prediction'
  and show_hdi_annotation=True across all experiment classes (ITS, SC,
  DiD, RD, RKink, PrePostNEGD)
- Add tests for effect_summary and get_plot_data_bayesian with prediction
- Add unit tests for add_hdi_annotation and logging functions in
  test_plot_utils.py
- Fix bug in _extract_window where it assumed result.post_y exists
  (ITS only); now correctly handles result.datapost_treated for
  SyntheticControl as well
- These tests specifically cover the partial coverage branches reported
  by Codecov
Align plotting and summary APIs with response_type naming, update logging helpers,
and adjust tests for the new parameter name.
Cover datapre/datapost properties for ITS and synthetic control, and
assert RegressionKink gradient change uses the instance epsilon.
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@github-actions github-actions bot added the agents: dev ops Agent related issues specifically for use by developers label Jan 24, 2026
@drbenvincent
Copy link
Collaborator Author

Closing: PR was opened from dev branch; will reopen from main.

@codecov
Copy link

codecov bot commented Jan 24, 2026

Codecov Report

❌ Patch coverage is 96.29630% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.42%. Comparing base (bfb93d9) to head (eab770a).

Files with missing lines Patch % Lines
causalpy/experiments/interrupted_time_series.py 84.44% 6 Missing and 1 partial ⚠️
causalpy/reporting.py 68.42% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #685      +/-   ##
==========================================
+ Coverage   94.35%   94.42%   +0.06%     
==========================================
  Files          44       46       +2     
  Lines        7517     7839     +322     
  Branches      456      477      +21     
==========================================
+ Hits         7093     7402     +309     
- Misses        262      271       +9     
- Partials      162      166       +4     

☔ View full report in Codecov by Sentry.
📢 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

agents: dev ops Agent related issues specifically for use by developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update AGENTS.md to avoid unnecessary back compatibility

1 participant