Skip to content

fix(pooling): exact within-model draw indices, keep score labels on-axis - #217

Merged
thomaspinder merged 1 commit into
feat/151-predictive-poolingfrom
fix/165-166-pooling-followups
Jul 29, 2026
Merged

fix(pooling): exact within-model draw indices, keep score labels on-axis#217
thomaspinder merged 1 commit into
feat/151-predictive-poolingfrom
fix/165-166-pooling-followups

Conversation

@thomaspinder

Copy link
Copy Markdown
Owner

Summary

Two follow-ups on the pooling branch (#164), stacked on feat/151-predictive-pooling:

  • Use rng.integers for within-model draw selection in _mixture_draws #165: _mixture_draws selected within-model indices via floor(rng.random(N) * sizes); now rng.integers(0, sizes[membership]) — exact (no theoretical index == size rounding edge), clearer, equally vectorised. Behaviour note: membership is drawn before the index draw, so model membership under fixed seeds is bit-identical and only within-model positions shift — all 103 pre-existing pooling tests pass unmodified, and no doc pins the old mechanism.
  • plot_pool_weights score annotation can spill past the axis for weights near 1 #166: plot_pool_weights placed the score annotation at w + 1% with xlim max(1, 1.05·w), overflowing the axis for weights near 1 (reproduced: label edge ~75 px past the axis). Labels now render inside the bar (right-aligned, white) when the bar exceeds 75% of the axis, outside otherwise. New test asserts alignment and get_window_extent().x1 <= ax.bbox.x1 for both placements, red-verified against the pre-fix code.

Closes #165
Closes #166

Gates

122 pooling+plotting tests green; branch fast suite 638 passed; ruff/ty clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV

@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.7%. Comparing base (ba8129b) to head (47ef90b).

Additional details and impacted files
@@                     Coverage Diff                     @@
##           feat/151-predictive-pooling    #217   +/-   ##
===========================================================
  Coverage                         94.7%   94.7%           
===========================================================
  Files                               44      44           
  Lines                             3009    3014    +5     
  Branches                           376     377    +1     
===========================================================
+ Hits                              2851    2856    +5     
  Misses                             114     114           
  Partials                            44      44           

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

@thomaspinder
thomaspinder force-pushed the feat/151-predictive-pooling branch from c35fc2d to ba8129b Compare July 29, 2026 13:45
Closes #165: `_mixture_draws` picked the within-model draw index with
`floor(rng.random(N) * sizes[membership])`. `rng.integers(0, sizes[membership])`
is exact — no theoretical `index == size` rounding edge at extreme sizes —
clearer, and equally vectorised. Pooled draws shift under a fixed seed;
membership is drawn before the index, so it is unchanged.

Closes #166: `plot_pool_weights` parked every score annotation at `w + 1%`,
so a long label (`log score -1,234.5`) ran past the right axis when a model
carried nearly all the weight. Bars covering more than 75% of the x-axis now
label inside, right-aligned against the bar end and recoloured for contrast;
shorter bars keep the outside placement.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Egjd7ToFeb9TQqFnfRQZxV
@thomaspinder
thomaspinder force-pushed the fix/165-166-pooling-followups branch from ae04c50 to 47ef90b Compare July 29, 2026 13:51
@thomaspinder
thomaspinder merged commit 06a0c67 into feat/151-predictive-pooling Jul 29, 2026
9 checks passed
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.

2 participants