Skip to content

fix: default S3 methods for the classic rfsrc/randomForest wrappers (3.4.1)#139

Merged
ehrlinger merged 2 commits into
mainfrom
fix/classic-wrappers-default-dispatch
Jul 2, 2026
Merged

fix: default S3 methods for the classic rfsrc/randomForest wrappers (3.4.1)#139
ehrlinger merged 2 commits into
mainfrom
fix/classic-wrappers-default-dispatch

Conversation

@ehrlinger

Copy link
Copy Markdown
Owner

Post-release consistency pass

Finishes the dispatch cleanup started for the varPro family in 3.4.0 (#136). The five classic wrappers — gg_error(), gg_vimp(), gg_variable(), gg_rfsrc(), gg_brier() — had no default S3 method, so a wrong-class input got R's generic no applicable method for '...' error.

Add default methods emitting a clear, class-naming error:
"gg_error: expected an 'rfsrc' or 'randomForest' object; got an object of class <...>."

gg_roc() intentionally left as-is — its default is aliased to gg_roc.rfsrc (gg_roc.default <- gg_roc.rfsrc), so it accepts rfsrc-shaped objects. Changing that is a behavior change, not a mechanical add, so it's out of scope.

Safety

Purely additive — no change to valid-input behavior. Existing wrapper tests all pass (gg_error 58 / gg_vimp 61 / gg_variable 85 / gg_rfsrc 67 / gg_brier 14, FAIL 0). New fit-free test_default_dispatch.R asserts all five error paths + the class-name interpolation; it runs on CRAN (no model fit needed).

Version — your call

Patch bump to 3.4.1 (DESCRIPTION + NEWS; grep test matches). This starts the post-3.4.0 dev line on main and will not be submitted immediately (CRAN discourages back-to-back updates). If you'd rather hold main at 3.4.0 and accumulate more before opening 3.4.1, say so and I'll drop the version bump.

🤖 Generated with Claude Code

…s (3.4.1)

Post-release consistency pass. gg_error(), gg_vimp(), gg_variable(),
gg_rfsrc(), and gg_brier() had no default S3 method, so a wrong-class input
got R's generic "no applicable method" error. Add default methods emitting a
clear "expected an 'rfsrc' or 'randomForest' object" message (naming the
class received), matching the varPro-family cleanup done in 3.4.0.

gg_roc() is intentionally left as-is: its default is aliased to gg_roc.rfsrc
(accepts rfsrc-shaped objects); changing that is a behavior change, not a
mechanical add.

Additive only — no change to valid-input behavior. New fit-free dispatch
test (runs on CRAN). Patch bump to 3.4.1 (DESCRIPTION + NEWS); will not be
submitted immediately (CRAN discourages back-to-back updates) — it starts the
post-3.4.0 dev line on main.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.29%. Comparing base (89a10d7) to head (a9c0738).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #139      +/-   ##
==========================================
+ Coverage   88.25%   88.29%   +0.04%     
==========================================
  Files          48       48              
  Lines        4360     4375      +15     
==========================================
+ Hits         3848     3863      +15     
  Misses        512      512              
Files with missing lines Coverage Δ
R/gg_brier.R 89.74% <100.00%> (+0.41%) ⬆️
R/gg_error.R 89.88% <100.00%> (+0.18%) ⬆️
R/gg_rfsrc.R 76.54% <100.00%> (+0.29%) ⬆️
R/gg_variable.R 85.85% <100.00%> (+0.44%) ⬆️
R/gg_vimp.R 76.76% <100.00%> (+0.35%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds missing .default S3 methods for the package’s classic rfsrc/randomForest wrapper generics so that wrong-class inputs fail with a consistent, explicit error message (instead of R’s generic “no applicable method…”), and adds fit-free tests to lock in this behavior.

Changes:

  • Add gg_error.default(), gg_vimp.default(), gg_variable.default(), gg_rfsrc.default(), and gg_brier.default() with clear class-reporting stop() messages.
  • Add a new fit-free test (test_default_dispatch.R) that asserts these default-dispatch error paths and class interpolation.
  • Bump package version and NEWS to 3.4.1 to reflect the dispatch-consistency change.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/testthat/test_default_dispatch.R Adds fit-free tests ensuring wrong-class inputs hit new .default methods with clear messages.
R/gg_error.R Adds gg_error.default() to provide a consistent wrong-class error.
R/gg_vimp.R Adds gg_vimp.default() to provide a consistent wrong-class error.
R/gg_variable.R Adds gg_variable.default() to provide a consistent wrong-class error.
R/gg_rfsrc.R Adds gg_rfsrc.default() to provide a consistent wrong-class error.
R/gg_brier.R Adds gg_brier.default() to provide a clearer wrong-class error specific to survival rfsrc.
NAMESPACE Registers the new S3method(*, default) entries.
NEWS.md Documents the dispatch-consistency change under v3.4.1.
DESCRIPTION Bumps Version/Date to 3.4.1 / 2026-07-02.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ehrlinger ehrlinger merged commit 2daf863 into main Jul 2, 2026
15 checks passed
@ehrlinger ehrlinger deleted the fix/classic-wrappers-default-dispatch branch July 2, 2026 18:27
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.

2 participants