Reduce mantelhaen.test() choice-argument defaults to scalars for R-devel#349
Merged
Conversation
R-devel added a two.sided.method = c("minlike", "central") argument to
stats::mantelhaen.test(). ard_stats_mantelhaen_test() harvests all formals
and previously only special-cased alternative, so the new multi-value
choice default was passed through unreduced. The length-2 value broke the
spliced call, causing the statistic and p-value to be captured as NULL and
the test to fail under R-devel.
Generalize the harvesting: drop no-default formals and reduce any
multi-value choice default to its first element, matching match.arg()
semantics and remaining resilient to future signature additions.
Co-authored-by: Ona <no-reply@ona.com>
Contributor
Unit Tests Summary 1 files 193 suites 1m 25s ⏱️ Results for commit 1103d4a. ♻️ This comment has been updated with latest results. |
Contributor
Unit Test Performance DifferenceAdditional test case details
Results for commit b3c9bbf ♻️ This comment has been updated with latest results. |
Contributor
Code Coverage SummaryDiff against mainResults for commit: 1103d4a Minimum allowed coverage is ♻️ This comment has been updated with latest results |
ddsjoberg
enabled auto-merge (squash)
July 6, 2026 16:25
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What changes are proposed in this pull request?
ard_stats_mantelhaen_test()where multi-value choice defaults harvested fromstats::mantelhaen.test()(such as thetwo.sided.methodargument added in R-devel) were passed through unreduced, producingNULLstatistics under R-devel. Choice defaults are now reduced to their default value. (Fix ard_stats_mantelhaen_test() failure on R-devel #343)R-devel added a new argument to
stats::mantelhaen.test():ard_stats_mantelhaen_test()harvests all formals except the first three and previously special-cased onlyalternativeto collapse its multi-value choice default to a scalar. The newly addedtwo.sided.methoddefault is an unevaluated length-2 vector, which was spliced into themantelhaen.test()call where a single value is expected. This broke the computation so the statistic and p-value were captured asNULL, causing a test failure on R-devel (observed on win-builder forcardx0.3.3.9001, which already includes the earlier #343 fix).The fix generalizes the harvesting: formals with no default (symbols) are dropped, and any multi-value choice default is reduced to its default (first) element, matching
match.arg()semantics. This removes thealternative-specific special case and is resilient to future signature additions.No snapshot change is required: on release/oldrel R the assembled arguments are identical to before (
alternative,correct,exact,conf.level), so the recorded ARD keeps its 8 rows. The additionaltwo.sided.methodargument exists only under R-devel, where the CRAN/win-builder checks run with snapshots skipped.win-builder log: https://win-builder.r-project.org/GEW5mk3m5xGG/00check.log
Reference GitHub issue associated with pull request.
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()ard_*()function was added, it passes the ARD structural checks fromcards::check_ard_structure().ard_*()function was added,set_cli_abort_call()has been set.ard_*()function was added and it depends on another package (such as,broom),is_pkg_installed("broom")has been set in the function call and the following added to the roxygen comments.devtools::test_coverage()Reviewer Checklist (if item does not apply, mark is as complete)
devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# cardx (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).