Repository navigation
Reduce MAD over sample_dims in summary median kinds - #496
Merged
aloctavodia merged 2 commits intoOct 20, 2026
Merged
Conversation
summary(kind="stats_median" or "all_median") computed the MAD over a
hardcoded ("chain", "draw"), while the median and eti use sample_dims,
so with sample_dims=["draw"] it reported the pooled MAD for every chain.
Fixes #492
Documentation build overview
12 files changed ·
|
aloctavodia
reviewed
Oct 20, 2026
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
aloctavodia
approved these changes
Oct 20, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 84.63% 84.75% +0.11%
==========================================
Files 48 49 +1
Lines 6978 7111 +133
==========================================
+ Hits 5906 6027 +121
- Misses 1072 1084 +12 ☔ View full report in Codecov by Harness. 🚀 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.
Fixes #492.
summary(kind="stats_median")andkind="all_median"computed the MAD withstats.median_abs_deviation(dataset, dims=("chain", "draw"), ...), while the median and the ETI next to it reduce oversample_dims. Withsample_dims=["draw"], each chain got the MAD pooled over all chains. The MAD now usesdims=validate_dims(sample_dims), like the rest of the function.Tests in
tests/test_summary.py, using the dataset from the issue (2 chains × 4 draws):test_summary_stats_median_reduces_mad_over_sample_dimswithsample_dims="draw"and["draw"]: median[1.5, 103.0]and MAD[1.0, 2.0]. Before the change, the MAD was[50.5, 50.5].test_summary_median_kind_pools_mad_by_default: the default call still gives the pooled MAD[50.5].all_mediangoes through the same line, but it can't run withsample_dims=["draw"]because the diagnostics (r_hat) need two dims, so the test usesstats_median.ruff checkandruff format --checkare clean. Intests/test_summary.pyon my machine,test_summary_data_frame,test_rope_coords,test_ci_in_rope_default_ci_kindandtest_summary_sd_uses_sample_stdfail or error the same way with and without this change (missingtest-xarrayextras locally). Everything else passes.