Skip to content

Comments

BOT: Fix #625: Implement get_unique_values() function#1095

Draft
nikosbosse wants to merge 1 commit intomainfrom
fix/625-get-unique-values
Draft

BOT: Fix #625: Implement get_unique_values() function#1095
nikosbosse wants to merge 1 commit intomainfrom
fix/625-get-unique-values

Conversation

@nikosbosse
Copy link
Collaborator

Summary

  • Closes Implement a get_unique_values() function #625
  • Adds a new exported get_unique_values() function that counts the number of unique values in each forecast unit column of a forecast object
  • Accepts an optional by argument for grouping (e.g., by = "model" to see unique value counts per model)
  • Follows the same patterns as get_forecast_counts(): validates input via clean_forecast(), uses get_forecast_unit() to identify relevant columns, returns a plain data.table

Root cause

No diagnostic function existed to quickly summarize the scope of a forecast dataset (how many locations, models, dates, etc.).

What the fix does

  • Creates R/get-unique-values.R with the exported get_unique_values() function
  • The function takes a forecast object, identifies forecast unit columns via get_forecast_unit(), and returns a data.table with columns "column" and "N_unique"
  • Supports optional by argument for grouped summaries
  • Adds N_unique to globalVariables in R/z-globalVariables.R

Test coverage

  • 6 test cases in tests/testthat/test-get-unique-values.R (26 expectations total):
    • Works with quantile forecasts and verifies exact unique counts
    • Works across different forecast types (binary, sample)
    • Returns correct structure with minimal point forecast data
    • Supports by argument for grouped output
    • Errors on non-forecast input
    • Handles data with NAs correctly
  • Full test suite: 704 tests pass, 0 failures
  • R CMD check: 0 errors, 0 warnings, 2 notes (pre-existing)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.85%. Comparing base (ac0c01a) to head (1c63583).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1095      +/-   ##
==========================================
+ Coverage   97.83%   97.85%   +0.02%     
==========================================
  Files          35       36       +1     
  Lines        1845     1865      +20     
==========================================
+ Hits         1805     1825      +20     
  Misses         40       40              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Collaborator Author

@nikosbosse nikosbosse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLAUDE: Clean implementation of get_unique_values() that follows established patterns (get_forecast_counts). Function correctly uses clean_forecast + get_forecast_unit, supports optional by argument for grouping, and has comprehensive test coverage (6 tests, 26 expectations). All changes are well-scoped to the issue. Minor nits: out_list variable could be simplified, and Test 4 assertions could be more precise — neither blocking. Verdict: approve.

@nikosbosse nikosbosse marked this pull request as draft February 13, 2026 08:28
@nikosbosse nikosbosse changed the title Fix #625: Implement get_unique_values() function BOT: Fix #625: Implement get_unique_values() function Feb 13, 2026
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.

Implement a get_unique_values() function

1 participant