Repository navigation
1155: List duplicated forecast units in the duplicate-forecast error - #1246
Draft
nikosbosse wants to merge 4 commits into
Draft
nikosbosse wants to merge 4 commits into
nikosbosse wants to merge 4 commits into
Conversation
The duplicate-forecast error now lists up to five duplicated forecast units with the number of duplicated rows for each, plus a count of any further units, so users can diagnose the problem without a second call to get_duplicate_forecasts(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summarise the already-computed duplicates instead of calling get_duplicate_forecasts() a second time, which avoided a repeated grouping/sort and the setdiff() workaround for the count column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group with by = c(fu) so a data column named `fu` cannot hijack the grouping, label the per-unit count as "(N rows)" and document that it includes the original rows, and add tests for a quantile forecast and for a `fu` column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1246 +/- ##
=======================================
Coverage 99.18% 99.19%
=======================================
Files 41 41
Lines 2333 2347 +14
=======================================
+ Hits 2314 2328 +14
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
CLAUDE:
Description
This PR closes #1155.
The duplicate-forecast error (raised by
as_forecast_<type>()/assert_forecast()via the internalcheck_duplicates()) now lists the first few duplicated forecast units inline, so users can see what is wrong without a separate call toget_duplicate_forecasts(). The existing message and theget_duplicate_forecasts(...)hint are unchanged; the new part is appended. Example: one 23-quantile forecast fromexample_quantileduplicated once:... and K more forecast unit(s)if there are more.(N rows): the number of rows involved in the duplication for that unit, original rows included, across all quantile levels / samples (so one exact duplicate of a 23-quantile forecast gives 46). This count goes slightly beyond what the issue thread agreed on (listing the units); it is cheap and tells the user how many rows to look at, but it can be dropped if maintainers prefer.duplicatestable thatcheck_duplicates()has already computed, soget_duplicate_forecasts()runs only once.Implementation: two independent drafts were compared by a judge agent; draft B was chosen as base. One improvement was taken from the comparison: the counts reuse the existing
duplicatestable instead of callingget_duplicate_forecasts()a second time.Checklist
devtools::test()passes (0 failures, 0 errors).tests/testthat/test-get-duplicate-forecasts.R: one duplicated point unit with its count and no "more" line; seven duplicated units truncated to 5 plus "... and 2 more"; a duplicated 23-quantile forecast reporting(46 rows); and a regression test for data containing a column namedfu. Verified they fail before and pass after the change: the first two fail againstorigin/main'sR/get-duplicate-forecasts.R; the quantile andfu-column tests failed (5 failing expectations in total) against the previous commit of this PR, before the grouping fix and relabelling.check_duplicates()description now mentions the listed units and what the count means (man/check_duplicates.Rd).lintr::lint_package()to check for style issues introduced by my changes. I linted the changed files withlintr::lint(). The only hits areobject_usage_linter"no visible binding/global function" false positives (the package was not installed), which also hit pre-existing code in the same file.Review
An independent adversarial agent reviewed the full diff. Changes made in response:
by = fu, a bare symbol that data.table resolves as a column name first. Data with a column namedfumerged all units into one bullet with blank values. Nowby = c(fu), matching the idiom used inget_duplicate_forecasts(), with a regression test that failed before the fix.(N duplicated rows)read like "extra copies" although it includes the originals. It is now(N rows), and the roxygen/Rd and NEWS say it counts all rows involved, originals included. The earlier PR-description claim that the count separates an exact duplicate from a missing forecast-unit column was removed, since for quantile/sample forecasts an exact duplicate also gives a large count.(46 rows)for one duplicated 23-quantile forecast, plus thefu-column regression test.by = c(...).Rebutted / not applied:
get_duplicate_forecasts(counts = TRUE)would need a second full duplicate pass, which this PR deliberately avoids. A helper for a one-liner adds indirection without removing real duplication.inherits(data, "forecast")branch is pre-existing and out of scope.🤖 Generated with Claude Code