Skip to content

Commit 8973a2e

Browse files
committed
two setting funcitons
1 parent 92701aa commit 8973a2e

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

R/aaa_models.R

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ pred_types <-
8080
#' @param items A character string of objects in the model environment.
8181
#' @param pre,post Optional functions for pre- and post-processing of prediction
8282
#' results.
83-
#' @param ... Optional arguments that should be passed into the `args` slot for
84-
#' prediction objects
83+
#' @param ... For `pred_value_template()`: optional arguments that should be
84+
#' passed into the `args` slot for prediction objects. For `set_in_env()`,
85+
#' named values that will be assigned to the model environment.
8586
#' @keywords internal
8687
#' @details These functions are available for users to add their
8788
#' own models or engines (in package or otherwise) so that they can
@@ -696,8 +697,6 @@ show_model_info <- function(model) {
696697
} else {
697698
cat(" no registered prediction modules.\n\n")
698699
}
699-
700-
701700
invisible(NULL)
702701
}
703702

@@ -709,6 +708,24 @@ get_from_env <- function(items) {
709708
rlang::env_get(mod_env, items)
710709
}
711710

711+
#' @rdname get_model_env
712+
#' @keywords internal
713+
#' @export
714+
set_in_env <- function(...) {
715+
mod_env <- get_model_env()
716+
rlang::env_bind(mod_env, ...)
717+
}
718+
719+
#' @rdname get_model_env
720+
#' @keywords internal
721+
#' @export
722+
set_env_val <- function(name, value) {
723+
mod_env <- parsnip::get_model_env()
724+
x <- list(value)
725+
names(x) <- name
726+
rlang::env_bind(mod_env, !!!x)
727+
}
728+
712729
# ------------------------------------------------------------------------------
713730

714731
#' @rdname get_model_env

0 commit comments

Comments
 (0)