Update AGENTS backwards compatibility guidance#685
Closed
drbenvincent wants to merge 9 commits intomainfrom
Closed
Update AGENTS backwards compatibility guidance#685drbenvincent wants to merge 9 commits intomainfrom
drbenvincent wants to merge 9 commits intomainfrom
Conversation
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.
Addresses #684.
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Collaborator
Author
|
Closing: PR was opened from dev branch; will reopen from main. |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Clarify that backwards compatibility should only be preserved for released APIs, not for APIs introduced within the same PR.
Fixes #684
Changes
AGENTS.md.Testing
Checklist
📚 Documentation preview 📚: https://causalpy--685.org.readthedocs.build/en/685/