Skip to content

Commit c4a208f

Browse files
committed
changes the "others" slot to "eng_args"
1 parent e9d6773 commit c4a208f

25 files changed

+67
-55
lines changed

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# parsnip 0.0.0.9005
2+
3+
* The engine, and any associated arguments, are not specified using `set_engine`. There is no `engine` argument
4+
5+
16
# parsnip 0.0.0.9004
27

38
* Arguments to modeling functions are now captured as quosures.

R/arguments.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ prune_arg_list <- function(x, whitelist = NULL, modified = character(0)) {
5050
x
5151
}
5252

53-
check_others <- function(args, obj, core_args) {
53+
check_eng_args <- function(args, obj, core_args) {
5454
# Make sure that we are not trying to modify an argument that
5555
# is explicitly protected in the method metadata or arg_key
5656
protected_args <- unique(c(obj$protect, core_args))
@@ -95,7 +95,7 @@ set_args <- function(object, ...) {
9595
if (any(main_args == i)) {
9696
object$args[[i]] <- the_dots[[i]]
9797
} else {
98-
object$others[[i]] <- the_dots[[i]]
98+
object$eng_args[[i]] <- the_dots[[i]]
9999
}
100100
}
101101
object
@@ -130,6 +130,6 @@ maybe_eval <- function(x) {
130130

131131
eval_args <- function(spec, ...) {
132132
spec$args <- purrr::map(spec$args, maybe_eval)
133-
spec$others <- purrr::map(spec$others, maybe_eval)
133+
spec$eng_args <- purrr::map(spec$eng_args, maybe_eval)
134134
spec
135135
}

R/boost_tree.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ boost_tree <-
127127
paste0("'", boost_tree_modes, "'", collapse = ", "),
128128
call. = FALSE)
129129

130-
out <- list(args = args, others = NULL,
130+
out <- list(args = args, eng_args = NULL,
131131
mode = mode, method = NULL, engine = NULL)
132132
class(out) <- make_classes("boost_tree")
133133
out

R/convert_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ convert_form_to_xy_fit <-function(
7676
if (indicators) {
7777
x <- model.matrix(mod_terms, mod_frame, contrasts)
7878
} else {
79-
# this still ignores -vars in formula ¯\_(ツ)_/¯
79+
# this still ignores -vars in formula
8080
x <- model.frame(mod_terms, data)
8181
y_cols <- attr(mod_terms, "response")
8282
if (length(y_cols) > 0)

R/descriptors.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ make_descr <- function(object) {
318318
expr_main <- map_lgl(object$args, has_exprs)
319319
else
320320
expr_main <- FALSE
321-
if (length(object$others) > 0)
322-
expr_others <- map_lgl(object$others, has_exprs)
321+
if (length(object$eng_args) > 0)
322+
expr_eng_args <- map_lgl(object$eng_args, has_exprs)
323323
else
324-
expr_others <- FALSE
325-
any(expr_main) | any(expr_others)
324+
expr_eng_args <- FALSE
325+
any(expr_main) | any(expr_eng_args)
326326
}
327327

328328
# Locate descriptors -----------------------------------------------------------
@@ -331,7 +331,7 @@ make_descr <- function(object) {
331331
requires_descrs <- function(object) {
332332
any(c(
333333
map_lgl(object$args, has_any_descrs),
334-
map_lgl(object$others, has_any_descrs)
334+
map_lgl(object$eng_args, has_any_descrs)
335335
))
336336
}
337337

R/engines.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ set_engine <- function(object, engine, ...) {
8181
object <- check_engine(object)
8282

8383

84-
object$others <- enquos(...)
84+
object$eng_args <- enquos(...)
8585
object
8686
}

R/linear_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ linear_reg <-
117117
# write a constructor function
118118
out <- list(
119119
args = args,
120-
others = NULL,
120+
eng_args = NULL,
121121
mode = mode,
122122
method = NULL,
123123
engine = NULL

R/logistic_reg.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ logistic_reg <-
116116
# write a constructor function
117117
out <- list(
118118
args = args,
119-
others = NULL,
119+
eng_args = NULL,
120120
mode = mode,
121121
method = NULL,
122122
engine = NULL

R/mars.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ mars <-
7575
paste0("'", mars_modes, "'", collapse = ", "),
7676
call. = FALSE)
7777

78-
out <- list(args = args, others = NULL,
78+
out <- list(args = args, eng_args = NULL,
7979
mode = mode, method = NULL, engine = NULL)
8080
class(out) <- make_classes("mars")
8181
out
@@ -141,8 +141,8 @@ translate.mars <- function(x, engine = x$engine, ...) {
141141
# If classification is being done, the `glm` options should be used. Check to
142142
# see if it is there and, if not, add the default value.
143143
if (x$mode == "classification") {
144-
if (!("glm" %in% names(x$others))) {
145-
x$others$glm <- quote(list(family = stats::binomial))
144+
if (!("glm" %in% names(x$eng_args))) {
145+
x$eng_args$glm <- quote(list(family = stats::binomial))
146146
}
147147
}
148148

@@ -208,8 +208,8 @@ multi_predict._earth <-
208208
msg <-
209209
paste("Please use `keepxy = TRUE` as an option to enable submodel",
210210
"predictions with `earth`.")
211-
if (any(names(object$spec$others) == "keepxy")) {
212-
if(!object$spec$others$keepxy)
211+
if (any(names(object$spec$eng_args) == "keepxy")) {
212+
if(!object$spec$eng_args$keepxy)
213213
stop (msg, call. = FALSE)
214214
} else
215215
stop (msg, call. = FALSE)

R/misc.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ make_classes <- function(prefix) {
1818
check_empty_ellipse <- function (...) {
1919
terms <- quos(...)
2020
if (!is_empty(terms))
21-
stop("Please pass other arguments to the model function via `others`", call. = FALSE)
21+
stop("Please pass other arguments to the model function via `set_engine`", call. = FALSE)
2222
terms
2323
}
2424

@@ -35,7 +35,6 @@ deparserizer <- function(x, limit = options()$width - 10) {
3535
}
3636

3737
print_arg_list <- function(x, ...) {
38-
others <- c("name", "call", "expression")
3938
atomic <- vapply(x, is.atomic, logical(1))
4039
x2 <- x
4140
x2[!atomic] <- lapply(x2[!atomic], deparserizer, ...)
@@ -59,10 +58,10 @@ model_printer <- function(x, ...) {
5958
non_null_args <- map(non_null_args, convert_arg)
6059
cat(print_arg_list(non_null_args), "\n", sep = "")
6160
}
62-
if (length(x$others) > 0) {
61+
if (length(x$eng_args) > 0) {
6362
cat("Engine-Specific Arguments:\n")
64-
x$others <- map(x$others, convert_arg)
65-
cat(print_arg_list(x$others), "\n", sep = "")
63+
x$eng_args <- map(x$eng_args, convert_arg)
64+
cat(print_arg_list(x$eng_args), "\n", sep = "")
6665
}
6766
if (!is.null(x$engine)) {
6867
cat("Computational engine:", x$engine, "\n\n")

0 commit comments

Comments
 (0)