Skip to content

Fix report crash when a cohort has subgroups and unequal model coverage - #3

Draft
aRealGem wants to merge 2 commits into
mainfrom
claude/project-thread-n263n3
Draft

aRealGem wants to merge 2 commits into
mainfrom
claude/project-thread-n263n3

Conversation

@aRealGem

@aRealGem aRealGem commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Requested by Precious · project thread

Before: write_report crashed with ValueError: The truth value of a Series is ambiguous whenever a cohort declared a subgroup and the models had unequal coverage. The PCam and GUSTO fixtures never combine the two, so it went unnoticed. It surfaced running a 10-model HELM BoolQ roster with a perturbation subgroup.

After: the report renders, and the coverage-delta column shows one value per model.

coverage_delta built its full-vs-common table with pivot_table(dropna=False), which takes the cartesian product of the index levels. Overall rows were repeated once per subgroup level, so cov_auroc.get(model) in _primary_rows returned a Series instead of a scalar.

How: replaced the pivot with groupby(..., dropna=False).first().unstack("subset"), which keeps only key combinations that exist. The other caller (identical_coverage in build_context) drops NaN values first, and the spurious rows were all NaN, so its result is unchanged. A new test in tests/test_evaluate.py fails on the old code and passes on the new. ruff check, ruff format --check, and pytest all pass locally. The golden tests skip here because their fixtures are not in the repo.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LeQ5eAyfbApPDkXxbExQS9


Generated by Claude Code

claude added 2 commits October 6, 2026 15:33
…ed coverage coexist

pivot_table(dropna=False) builds the cartesian product of the index levels, so with
a declared subgroup every overall row was repeated per subgroup level and
_primary_rows crashed on a Series from cov_auroc.get(). Found running the HELM
BoolQ roster (10 models with unequal coverage plus a perturbation subgroup).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeQ5eAyfbApPDkXxbExQS9
…overage

Fails on the pre-fix pivot_table (duplicated overall rows per model) and passes
with the groupby version.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeQ5eAyfbApPDkXxbExQS9
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