Skip to content

Commit

Permalink
Merge pull request #303 from fweber144/issue239_tests
Browse files Browse the repository at this point in the history
Tests: Avoid issue #239
  • Loading branch information
fweber144 authored Apr 20, 2022
2 parents 7018ab0 + 4c2fb3c commit 6067e53
Showing 1 changed file with 21 additions and 2 deletions.
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

0 comments on commit 6067e53

Please sign in to comment.