@@ -30,7 +30,7 @@ parsnip$modes <- c("regression", "classification", "unknown")
3030
3131# ------------------------------------------------------------------------------
3232
33- # ' @rdname check_mod_val
33+ # ' @rdname get_model_env
3434# ' @keywords internal
3535# ' @export
3636pred_types <-
@@ -100,7 +100,14 @@ pred_types <-
100100# ' current_code <- get_model_env()
101101# ' ls(envir = current_code)
102102# '
103+ # ' @keywords internal
103104# ' @export
105+ get_model_env <- function () {
106+ current <- utils :: getFromNamespace(" parsnip" , ns = " parsnip" )
107+ # current <- parsnip
108+ current
109+ }
110+
104111check_mod_val <- function (model , new = FALSE , existence = FALSE ) {
105112 if (rlang :: is_missing(model ) || length(model ) != 1 )
106113 stop(" Please supply a character string for a model name (e.g. `'linear_reg'`)" ,
@@ -126,58 +133,34 @@ check_mod_val <- function(model, new = FALSE, existence = FALSE) {
126133 invisible (NULL )
127134}
128135
129- # ' @rdname check_mod_val
130- # ' @keywords internal
131- # ' @export
132- get_model_env <- function () {
133- current <- utils :: getFromNamespace(" parsnip" , ns = " parsnip" )
134- # current <- parsnip
135- current
136- }
137-
138- # ' @rdname check_mod_val
139- # ' @keywords internal
140- # ' @export
141136check_mode_val <- function (mode ) {
142137 if (rlang :: is_missing(mode ) || length(mode ) != 1 )
143138 stop(" Please supply a character string for a mode (e.g. `'regression'`)" ,
144139 call. = FALSE )
145140 invisible (NULL )
146141}
147142
148- # ' @rdname check_mod_val
149- # ' @keywords internal
150- # ' @export
151143check_engine_val <- function (eng ) {
152144 if (rlang :: is_missing(eng ) || length(eng ) != 1 )
153145 stop(" Please supply a character string for an engine (e.g. `'lm'`)" ,
154146 call. = FALSE )
155147 invisible (NULL )
156148}
157149
158- # ' @rdname check_mod_val
159- # ' @keywords internal
160- # ' @export
161150check_arg_val <- function (arg ) {
162151 if (rlang :: is_missing(arg ) || length(arg ) != 1 )
163152 stop(" Please supply a character string for the argument" ,
164153 call. = FALSE )
165154 invisible (NULL )
166155}
167156
168- # ' @rdname check_mod_val
169- # ' @keywords internal
170- # ' @export
171157check_submodels_val <- function (has_submodel ) {
172158 if (! is.logical(has_submodel ) || length(has_submodel ) != 1 ) {
173159 stop(" The `submodels` argument should be a single logical." , call. = FALSE )
174160 }
175161 invisible (NULL )
176162}
177163
178- # ' @rdname check_mod_val
179- # ' @keywords internal
180- # ' @export
181164check_func_val <- function (func ) {
182165 msg <-
183166 paste(
@@ -212,9 +195,6 @@ check_func_val <- function(func) {
212195 invisible (NULL )
213196}
214197
215- # ' @rdname check_mod_val
216- # ' @keywords internal
217- # ' @export
218198check_fit_info <- function (fit_obj ) {
219199 if (is.null(fit_obj )) {
220200 stop(" The `fit` module cannot be NULL." , call. = FALSE )
@@ -246,9 +226,6 @@ check_fit_info <- function(fit_obj) {
246226 invisible (NULL )
247227}
248228
249- # ' @rdname check_mod_val
250- # ' @keywords internal
251- # ' @export
252229check_pred_info <- function (pred_obj , type ) {
253230 if (all(type != pred_types )) {
254231 stop(" The prediction type should be one of: " ,
@@ -281,9 +258,6 @@ check_pred_info <- function(pred_obj, type) {
281258 invisible (NULL )
282259}
283260
284- # ' @rdname check_mod_val
285- # ' @keywords internal
286- # ' @export
287261check_pkg_val <- function (pkg ) {
288262 if (rlang :: is_missing(pkg ) || length(pkg ) != 1 || ! is.character(pkg ))
289263 stop(" Please supply a single character vale for the package name" ,
@@ -293,7 +267,7 @@ check_pkg_val <- function(pkg) {
293267
294268# ------------------------------------------------------------------------------
295269
296- # ' @rdname check_mod_val
270+ # ' @rdname get_model_env
297271# ' @keywords internal
298272# ' @export
299273set_new_model <- function (model ) {
@@ -331,7 +305,7 @@ set_new_model <- function(model) {
331305
332306# ------------------------------------------------------------------------------
333307
334- # ' @rdname check_mod_val
308+ # ' @rdname get_model_env
335309# ' @keywords internal
336310# ' @export
337311set_model_mode <- function (model , mode ) {
@@ -351,7 +325,7 @@ set_model_mode <- function(model, mode) {
351325
352326# ------------------------------------------------------------------------------
353327
354- # ' @rdname check_mod_val
328+ # ' @rdname get_model_env
355329# ' @keywords internal
356330# ' @export
357331set_model_engine <- function (model , mode , eng ) {
@@ -376,7 +350,7 @@ set_model_engine <- function(model, mode, eng) {
376350
377351# ------------------------------------------------------------------------------
378352
379- # ' @rdname check_mod_val
353+ # ' @rdname get_model_env
380354# ' @keywords internal
381355# ' @export
382356set_model_arg <- function (model , eng , parsnip , original , func , has_submodel ) {
@@ -425,7 +399,7 @@ set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
425399
426400# ------------------------------------------------------------------------------
427401
428- # ' @rdname check_mod_val
402+ # ' @rdname get_model_env
429403# ' @keywords internal
430404# ' @export
431405set_dependency <- function (model , eng , pkg ) {
@@ -468,7 +442,7 @@ set_dependency <- function(model, eng, pkg) {
468442 invisible (NULL )
469443}
470444
471- # ' @rdname check_mod_val
445+ # ' @rdname get_model_env
472446# ' @keywords internal
473447# ' @export
474448get_dependency <- function (model ) {
@@ -483,7 +457,7 @@ get_dependency <- function(model) {
483457
484458# ------------------------------------------------------------------------------
485459
486- # ' @rdname check_mod_val
460+ # ' @rdname get_model_env
487461# ' @keywords internal
488462# ' @export
489463set_fit <- function (model , mode , eng , value ) {
@@ -534,7 +508,7 @@ set_fit <- function(model, mode, eng, value) {
534508 invisible (NULL )
535509}
536510
537- # ' @rdname check_mod_val
511+ # ' @rdname get_model_env
538512# ' @keywords internal
539513# ' @export
540514get_fit <- function (model ) {
@@ -548,7 +522,7 @@ get_fit <- function(model) {
548522
549523# ------------------------------------------------------------------------------
550524
551- # ' @rdname check_mod_val
525+ # ' @rdname get_model_env
552526# ' @keywords internal
553527# ' @export
554528set_pred <- function (model , mode , eng , type , value ) {
@@ -600,7 +574,7 @@ set_pred <- function(model, mode, eng, type, value) {
600574 invisible (NULL )
601575}
602576
603- # ' @rdname check_mod_val
577+ # ' @rdname get_model_env
604578# ' @keywords internal
605579# ' @export
606580get_pred_type <- function (model , type ) {
@@ -619,7 +593,7 @@ get_pred_type <- function(model, type) {
619593
620594# ------------------------------------------------------------------------------
621595
622- # ' @rdname check_mod_val
596+ # ' @rdname get_model_env
623597# ' @keywords internal
624598# ' @export
625599show_model_info <- function (model ) {
@@ -712,7 +686,7 @@ show_model_info <- function(model) {
712686 invisible (NULL )
713687}
714688
715- # ' @rdname check_mod_val
689+ # ' @rdname get_model_env
716690# ' @keywords internal
717691# ' @export
718692get_from_env <- function (items ) {
0 commit comments