1204: Error when summarise_scores() by contains metric columns#1213
Open
nikosbosse wants to merge 1 commit into
Open
1204: Error when summarise_scores() by contains metric columns#1213nikosbosse wants to merge 1 commit into
nikosbosse wants to merge 1 commit into
Conversation
summarise_scores() silently returned an unsummarised table with
duplicate column names when `by` contained a metric column (e.g.
by = c("model", "wis")): the score column was used both as a grouping
column and as a column to summarise. summarise_scores() now errors
with a clear message naming the offending columns, consistent with
the #1179 precedent for the empty-metrics case.
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 #1213 +/- ##
=======================================
Coverage 98.15% 98.16%
=======================================
Files 41 41
Lines 2225 2234 +9
=======================================
+ Hits 2184 2193 +9
Misses 41 41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
Automated review (Claude Fable, directed by @nikosbosse): Verdict: approve. All checks passed.
One out-of-scope observation (no action needed): if a user renames a metric column without updating the |
nikosbosse
marked this pull request as draft
July 18, 2026 13:53
nikosbosse
commented
Jul 18, 2026
nikosbosse
left a comment
Collaborator
Author
There was a problem hiding this comment.
It's a behaviour change, but I think a good one
nikosbosse
marked this pull request as ready for review
July 18, 2026 21:09
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.
Description
This PR closes #1204.
summarise_scores()accepted metric/score columns inby(e.g.summarise_scores(scores, by = c("model", "wis"))) and silently returned a broken result: an unsummarised table (same row count as the input, since grouping by near-unique numeric score values aggregates nothing) with a duplicated column name (wisappearing both as a grouping column and as a "summarised" score column), which breaks downstream data.table operations.The fix adds a check after the
metricsattribute is retrieved: ifbycontains any metric column,summarise_scores()now errors viacli_abort(), naming the offending columns. Erroring (rather than warn-and-drop) is consistent with the precedent set by #1179, which introduced an error for the sibling empty-metrics duplicate-column case in the same function. The@param bydocumentation was updated accordingly, and a NEWS entry added.New tests failed before the fix, as expected:
After the fix, the full test suite passes locally (0 failed, 909 passed).
Dev note: bug identified by an LLM audit (#1189); fix and tests implemented with LLM support, directed by @nikosbosse.
Checklist
man/summarise_scores.Rdupdate matches the roxygen2 output; only this file's documentation changed.)