Skip to content

Add group-level outputs to PrePostNEGD.summary()#733

Open
drbenvincent wants to merge 5 commits intomainfrom
fix/727-prepostnegd-summary-stats
Open

Add group-level outputs to PrePostNEGD.summary()#733
drbenvincent wants to merge 5 commits intomainfrom
fix/727-prepostnegd-summary-stats

Conversation

@drbenvincent
Copy link
Copy Markdown
Collaborator

Summary

  • add experiment-specific output to PrePostNEGD.summary() with group-level n, pre_mean, and post_mean
  • keep existing causal impact and model coefficient reporting unchanged while improving interpretability
  • add integration-test assertions and rerun ancova_pymc.ipynb so docs show updated summary output

Test plan

  • conda run -n CausalPy pytest causalpy/tests/test_integration_pymc_examples.py -k test_ancova -v --no-cov
  • conda run -n CausalPy pre-commit run --all-files
  • Re-ran docs/source/notebooks/ancova_pymc.ipynb

Closes #727

Made with Cursor

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@drbenvincent drbenvincent added the enhancement New feature or request label Feb 21, 2026
@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Feb 21, 2026

Documentation build overview

📚 causalpy | 🛠️ Build #32078068 | 📁 Comparing b8fced1 against latest (55256f5)

  🔍 Preview build  

Show files changed (3 files in total): 📝 3 modified | ➕ 0 added | ➖ 0 deleted
File Status
404.html 📝 modified
notebooks/ancova_pymc.html 📝 modified
_modules/causalpy/experiments/prepostnegd.html 📝 modified

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.49%. Comparing base (eec45f7) to head (b8fced1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #733      +/-   ##
==========================================
+ Coverage   93.48%   93.49%   +0.01%     
==========================================
  Files          75       75              
  Lines       11272    11291      +19     
  Branches      658      662       +4     
==========================================
+ Hits        10538    10557      +19     
  Misses        544      544              
  Partials      190      190              

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

@drbenvincent drbenvincent force-pushed the fix/727-prepostnegd-summary-stats branch from d4af2f2 to ccc25fb Compare February 25, 2026 20:19
drbenvincent and others added 2 commits February 28, 2026 10:55
Add experiment-specific summary statistics for PrePostNEGD by printing group-level sample sizes and pre/post means, and cover the new output in integration tests and the ANCOVA docs notebook.

Closes #727

Co-authored-by: Cursor <cursoragent@cursor.com>
Execute the `round_to` path in `PrePostNEGD._group_level_summary_stats()` so Codecov patch coverage includes the new group-level summary logic.

Co-authored-by: Cursor <cursoragent@cursor.com>
@drbenvincent drbenvincent force-pushed the fix/727-prepostnegd-summary-stats branch from ccc25fb to da3abb5 Compare February 28, 2026 10:56
@drbenvincent
Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor
Copy link
Copy Markdown

cursor bot commented Feb 28, 2026

PR Summary

Low Risk
Low risk: adds additional printed summary output and a small helper method, plus updates one integration test to assert the new output; core modeling/plotting logic is unchanged.

Overview
PrePostNEGD.summary() now prints group-level descriptive stats (per-group n, pre_mean, post_mean) before the existing causal impact and coefficient output, backed by a new _group_level_summary_stats() helper with optional rounding.

The test_ancova integration test is updated to capture stdout and assert the new section/columns and rounding behavior. .gitignore is expanded to ignore dashed variants of generated GitHub summary/comment directories.

Written by Cursor Bugbot for commit ad14767. This will update automatically on new commits. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread causalpy/experiments/prepostnegd.py Outdated
if round_to is not None:
summary_df[["pre_mean", "post_mean"]] = summary_df[
["pre_mean", "post_mean"]
].round(round_to)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Inconsistent rounding semantics within summary() output

Medium Severity

_group_level_summary_stats uses DataFrame.round(round_to) which interprets round_to as decimal places, while _causal_impact_summary_stat and print_coefficients use round_num() which interprets round_to as significant figures. When summary(round_to=2) is called, group-level means get rounded to 2 decimal places (e.g., 3.14) but the causal impact and coefficients get rounded to 2 significant figures (e.g., 3.1). This makes the single round_to parameter behave inconsistently within the same output.

Additional Locations (1)

Fix in Cursor Fix in Web

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.

Good catch — this was indeed inconsistent. Fixed in 1fb0a82: _group_level_summary_stats now uses round_num() (significant figures) element-wise via .map(), matching the behavior of _causal_impact_summary_stat and print_coefficients. The integration test assertions were updated accordingly.

…oup-level stats

_group_level_summary_stats was using DataFrame.round() (decimal places)
while the rest of summary() uses round_num() (significant figures).
This made the single round_to parameter behave inconsistently.

Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add experiment-specific outputs to PrePostNEGD.summary()

1 participant