1209: Skip subgroups with too few comparators in get_pairwise_comparisons()#1214
1209: Skip subgroups with too few comparators in get_pairwise_comparisons()#1214nikosbosse wants to merge 2 commits into
Conversation
…odels (#1209) get_pairwise_comparisons() split scores by 'by' and aborted as soon as any subgroup had fewer than two comparators, discarding results for all valid subgroups and without naming the offending subgroup. Subgroups with fewer than two comparators are now skipped with a warning that names them (as col=value pairs), and results are returned for the remaining subgroups; add_relative_skill() fills NA for skipped subgroups. If no subgroup has at least two comparators, the previous error is kept, and the safeguard in pairwise_comparison_one_group() stays in place for direct calls. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1214 +/- ##
==========================================
+ Coverage 98.15% 98.17% +0.01%
==========================================
Files 41 41
Lines 2225 2246 +21
==========================================
+ Hits 2184 2205 +21
Misses 41 41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Automated review (Claude Fable, directed by @nikosbosse): Verdict: approve. Verified independently in a clean worktree:
Minor, non-blocking observations:
|
Follow-up to review findings on the subgroup-skipping change: - get_pairwise_comparisons() now splits scores with drop = TRUE, so truly empty subgroups (e.g. from an unused factor level in a `by` column) are dropped silently instead of being "skipped" with a nonsense warning label like "target_type=NA" derived from the first row of an empty table. Warnings now only ever name real subgroups. - pairwise_comparison_one_group() gets its own `by` documentation: it no longer inherits the "skipped with a warning" sentence, which does not apply because the internal function still errors when there are fewer than two comparators. - Added a regression test: a factor `by` column with an unused level produces no "NA" warning label and results identical to the same data without the unused level, and an unused level alone triggers no warning at all. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Follow-up (Claude Fable, directed by @nikosbosse): addressed both review observations in 7aa27f7.
Test evidence: |
Description
This PR closes #1209.
get_pairwise_comparisons()split scores into subgroups bybyand then aborted as soon as any subgroup had fewer than two comparators, discarding results for all valid subgroups and without saying which subgroup was the problem.add_relative_skill()inherited the same behaviour.With this PR, subgroups with fewer than two comparators are skipped with a warning that names them (as
col=valuepairs, e.g."target_type=Deaths"), and results are returned for the remaining subgroups.add_relative_skill()fillsNAfor the skipped subgroups. If no subgroup has at least two comparators (includingby = NULLwith a single model), the previous error is kept unchanged, and the safeguard insidepairwise_comparison_one_group()remains for direct calls.Tests were written first and failed on the unfixed code:
After the fix, the full test suite passes (0 failed, 915 passed). Note: the two
vdiffrdoppelganger snapshots forplot_pairwise_comparisons()fail locally on unmodifiedmainas well (environment-dependent rendering) and are unrelated to this change.Dev note: bug identified by an LLM audit (#1189); fix and tests implemented with LLM support, directed by @nikosbosse.
Checklist
lintron the changed files; no new style issues were introduced by my changes.