BOT: Fix #780: Add verbose argument to as_forecast_*() constructors#1089
BOT: Fix #780: Add verbose argument to as_forecast_*() constructors#1089nikosbosse wants to merge 1 commit intomainfrom
Conversation
Thread the existing verbose parameter from assert_forecast() through all 7 as_forecast_<type>.default() methods so users can suppress messages and warnings by passing verbose = FALSE instead of wrapping calls in suppressMessages()/suppressWarnings(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1089 +/- ##
=======================================
Coverage 97.83% 97.83%
=======================================
Files 35 35
Lines 1845 1846 +1
=======================================
+ Hits 1805 1806 +1
Misses 40 40 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nikosbosse
left a comment
There was a problem hiding this comment.
CLAUDE: Approve. Clean, well-scoped implementation that correctly threads the existing verbose parameter from assert_forecast() through all 7 as_forecast_.default() constructors. The change is minimal, follows existing patterns, and preserves default behavior. Quantile rounding cli_warn() is properly gated while the rounding behavior itself still executes. Tests are thorough for quantile (6 tests) and adequate for other types. Minor gaps: no tests for ordinal/multivariate_sample types (low risk, identical code pattern) and the nominal test uses na.omit() so doesn't exercise actual suppression. The optional cleanup of existing suppressMessages/suppressWarnings wrappers was reasonably deferred to a follow-up.
Summary
verbose = TRUEparameter to all 7as_forecast_<type>.default()methodsverbosethrough toassert_forecast()to suppress messages/warnings whenverbose = FALSEcli_warn()inas_forecast_quantile.default()behind theverboseflag@inheritParams assert_forecastroxygen tags for documentationFixes #780
Root cause
The
verboseparameter existed onassert_forecast()andassert_forecast_generic()(added in PR #778), but was never threaded through to theas_forecast_<type>()constructors. Users were forced to wrap calls insuppressMessages()/suppressWarnings()to silence informational output.What the fix does
Each
.default()method now acceptsverbose = TRUEand forwards it toassert_forecast(data, verbose = verbose). The quantile constructor additionally gates its owncli_warn()about rounding issues behindif (verbose). Default behavior (verbose = TRUE) is unchanged.Test coverage added
as_forecast_quantile()verbose suppresses NA messages, rounding warnings, and unequal-quantile warningsas_forecast_quantile()verbose = FALSE does not suppress errorsas_forecast_quantile()default verbose = TRUE preserves messagesas_forecast_sample()verbose suppresses NA messagesas_forecast_binary()verbose suppresses NA messagesas_forecast_point()verbose suppresses NA messagesas_forecast_nominal()verbose works correctlyTest plan
🤖 Generated with Claude Code