fix: default S3 methods for the classic rfsrc/randomForest wrappers (3.4.1)#139
Merged
Merged
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
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(), andgg_brier.default()with clear class-reportingstop()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.
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.
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 nodefaultS3 method, so a wrong-class input got R's genericno applicable method for '...'error.Add
defaultmethods 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 togg_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.Rasserts 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
mainand will not be submitted immediately (CRAN discourages back-to-back updates). If you'd rather holdmainat 3.4.0 and accumulate more before opening 3.4.1, say so and I'll drop the version bump.🤖 Generated with Claude Code