Skip to content

Commit 2205eae

Browse files
committed
move check_control() to where it is used
1 parent d8f273c commit 2205eae

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

R/control_parsnip.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ control_parsnip <- function(verbosity = 1L, catch = FALSE) {
2828
res
2929
}
3030

31+
check_control <- function(x) {
32+
if (!is.list(x))
33+
rlang::abort("control should be a named list.")
34+
if (!isTRUE(all.equal(sort(names(x)), c("catch", "verbosity"))))
35+
rlang::abort("control should be a named list with elements 'verbosity' and 'catch'.")
36+
# based on ?is.integer
37+
int_check <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol
38+
if (!int_check(x$verbosity))
39+
rlang::abort("verbosity should be an integer.")
40+
if (!is.logical(x$catch))
41+
rlang::abort("catch should be a logical.")
42+
x
43+
}
44+
3145
#' @export
3246
print.control_parsnip <- function(x, ...) {
3347
cat("parsnip control object\n")

R/fit.R

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,6 @@ eval_mod <- function(e, capture = FALSE, catch = FALSE, envir = NULL, ...) {
346346

347347
# ------------------------------------------------------------------------------
348348

349-
check_control <- function(x) {
350-
if (!is.list(x))
351-
rlang::abort("control should be a named list.")
352-
if (!isTRUE(all.equal(sort(names(x)), c("catch", "verbosity"))))
353-
rlang::abort("control should be a named list with elements 'verbosity' and 'catch'.")
354-
# based on ?is.integer
355-
int_check <- function(x, tol = .Machine$double.eps^0.5) abs(x - round(x)) < tol
356-
if (!int_check(x$verbosity))
357-
rlang::abort("verbosity should be an integer.")
358-
if (!is.logical(x$catch))
359-
rlang::abort("catch should be a logical.")
360-
x
361-
}
362-
363349
inher <- function(x, cls, cl) {
364350
if (!is.null(x) && !inherits(x, cls)) {
365351
call <- match.call()

0 commit comments

Comments
 (0)