You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' Check if an argument is a bounded numeric vector of length 3#'#' Must follow form `c(value, min, max)` and `test_fun` must be a function that#' supports checks on vectorized input#' @noRd#'check_range_slider<-function(value,
lower=-Inf,
upper=Inf,
finite=TRUE,
test_fun=checkmate::test_numeric) {
checkmate::assert_flag(finite)
checkmate::assert_function(test_fun)
checkmate::assert_number(lower)
checkmate::assert_number(upper)
is_numeric<- test_fun(
value,
len=3,
any.missing=FALSE
)
# Finite is not available in integer testsif ("finite"%in% names(formals(test_fun))) {
test_fun(value, finite=finite)
}
is_bounded<-is_numeric&& test_fun(
value[[1]],
len=1,
lower= max(lower, value[[2]]),
upper= min(upper, value[[3]])
)
if (isFALSE(is_numeric) || isFALSE(is_bounded)) {
return(
paste(
"Must be a numeric vector of length 3 with `c(value, min, max)`",
"where the `value` must be between `min` and `max`"
)
)
}
TRUE
}
The text was updated successfully, but these errors were encountered:
Add an internal function to
{tmg}
that performs checks for numeric vectors that have the structure:c(value, min, max
).Some examples are
plot_height
,alpha
, ...The goal is to replace repetitive logic (represented in real examples from
{tmg}
below)With:
check_range_slider
sourceThe text was updated successfully, but these errors were encountered: