Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Avoid issue #239 #303

Merged
merged 2 commits into from
Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,30 @@ if (run_cvvs) {
# diagnostics. Additionally to suppressWarnings(), suppressMessages() could be
# used here (because of the refits in K-fold CV):
cvvss <- suppressWarnings(lapply(args_cvvs, function(args_cvvs_i) {
do.call(cv_varsel, c(
cvvs_expr <- expression(do.call(cv_varsel, c(
list(object = refmods[[args_cvvs_i$tstsetup_ref]]),
excl_nonargs(args_cvvs_i)
))
)))
if (args_cvvs_i$mod_nm == "gamm" &&
!identical(args_cvvs_i$cv_method, "kfold")) {
# Due to issue #239, we have to wrap the call to cv_varsel() in try():
return(try(eval(cvvs_expr), silent = TRUE))
} else {
return(eval(cvvs_expr))
}
}))
success_cvvs <- !sapply(cvvss, inherits, "try-error")
err_ok <- sapply(cvvss[!success_cvvs], function(cvvs_err) {
attr(cvvs_err, "condition")$message ==
"Not enough (non-NA) data to do anything meaningful"
})
expect_true(
all(err_ok),
info = paste("Unexpected error for",
paste(names(cvvss[!success_cvvs])[!err_ok], collapse = ", "))
)
cvvss <- cvvss[success_cvvs]
args_cvvs <- args_cvvs[success_cvvs]
}

## Projection -------------------------------------------------------------
Expand Down