BOT: Fix #825: Remove Metrics package from Imports#1084
BOT: Fix #825: Remove Metrics package from Imports#1084nikosbosse wants to merge 1 commit intomainfrom
Conversation
Replace Metrics::ae, Metrics::se, and Metrics::ape with inline one-liner implementations in get_metrics.forecast_point(). Move Metrics to Suggests (still used for cross-validation in binary metric tests). Update vignette code chunks and prose to use base-R equivalents instead of Metrics:: calls. 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 #1084 +/- ##
=======================================
Coverage 97.83% 97.83%
=======================================
Files 35 35
Lines 1845 1845
=======================================
Hits 1805 1805
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: Review found issues that need fixing.
Bug in Test 4 ("Metrics package is not in DESCRIPTION Imports"): The regex "^Imports:|^\\s+Metrics" matches ANY indented "Metrics" line regardless of DESCRIPTION section. Since Metrics was moved to Suggests, the Metrics, line under Suggests matches ^\\s+Metrics, and the subsequent grepl("\\bMetrics\\b", imports_lines) returns TRUE — causing the test to incorrectly fail when run against the rebuilt package (e.g. during R CMD check). Fix: use read.dcf() to parse only the Imports field, or use section-aware parsing.
Missing guard: test-metrics-binary.R uses Metrics::ll() without a skip_if_not_installed("Metrics") guard. Now that Metrics is in Suggests, this could cause test failures in environments where Metrics is not installed.
The core fix (replacing Metrics::ae/se/ape with inline functions, updating vignette, moving Metrics to Suggests) is correct and well-scoped.
Summary
Metrics::ae,Metrics::se, andMetrics::apewith equivalent inline one-liner functions inget_metrics.forecast_point()Metricsfrom DESCRIPTIONImportsand moves it toSuggests(still used for cross-validation in binary metric tests)scoring-rules.Rmdvignette to use base-R equivalents instead ofMetrics::callsFixes #825
Root cause
The
Metricspackage was imported solely for three trivially simple functions: absolute error (abs(actual - predicted)), squared error ((actual - predicted)^2), and absolute percentage error (abs(actual - predicted) / abs(actual)). This added an unnecessary runtime dependency.What was changed
R/class-forecast-point.R: ReplacedMetrics::ae/se/apereferences with inline anonymous functions; removed@importFrom Metricsdirective; updated roxygen docsDESCRIPTION: MovedMetricsfromImportstoSuggestsNAMESPACE: Regenerated (Metrics imports removed)vignettes/scoring-rules.Rmd: ReplacedMetrics::ae()/Metrics::se()calls with base-R equivalents; removed?Metrics::*prose referencesman/get_metrics.forecast_point.Rd: RegeneratedTest plan
🤖 Generated with Claude Code