-
Notifications
You must be signed in to change notification settings - Fork 105
Closed
Description
Below is find_varying(). There is a point where it calls map_lgl over a potential list, but if this list is empty, it will return logical(0). This just happens to work because we then call any(logical(0)) which returns FALSE (which is what we want), but I'd rather it actually return the right thing. I think we can just say the following in the marked spot below
if (length(x) > 0) {
map_lgl(x, find_varying)
}
FALSEfunction (x)
{
if (is_quosure(x))
x <- quo_get_expr(x)
if (is_varying(x)) {
return(TRUE)
}
else if (is.atomic(x) | is.name(x)) {
FALSE
}
else if (is.call(x) || is.pairlist(x)) {
for (i in seq_along(x)) {
if (is_varying(x[[i]]))
return(TRUE)
}
FALSE
}
else if (is.vector(x) | is.list(x)) {
map_lgl(x, find_varying) # <- RIGHT HERE
}
else {
stop("Don't know how to handle type ", typeof(x), call. = FALSE)
}
}if you want to see it happening, you can use this code
library(parsnip)
library(recipes)
x <- recipe(Species ~ ., data = iris) %>%
step_bs(Sepal.Length, degree = varying())
# debugonce(varying_args)
varying_args(x$steps[[1]])after running debugonce() and then calling the varying_args() call, step through until you get to the res <- map(x, find_varying) line, where res will hold logical(0) for options
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels