@@ -112,6 +112,14 @@ get_model_env <- function() {
112112 current
113113}
114114
115+
116+ check_eng_val <- function (eng ) {
117+ if (rlang :: is_missing(eng ) || length(eng ) != 1 )
118+ stop(" Please supply a character string for an engine name (e.g. `'lm'`)" ,
119+ call. = FALSE )
120+ invisible (NULL )
121+ }
122+
115123check_mod_val <- function (model , new = FALSE , existence = FALSE ) {
116124 if (rlang :: is_missing(model ) || length(model ) != 1 )
117125 stop(" Please supply a character string for a model name (e.g. `'linear_reg'`)" ,
@@ -337,6 +345,7 @@ set_model_mode <- function(model, mode) {
337345set_model_engine <- function (model , mode , eng ) {
338346 check_mod_val(model , existence = TRUE )
339347 check_mode_val(mode )
348+ check_eng_val(eng )
340349 check_mode_val(eng )
341350
342351 current <- get_model_env()
@@ -361,6 +370,7 @@ set_model_engine <- function(model, mode, eng) {
361370# ' @export
362371set_model_arg <- function (model , eng , parsnip , original , func , has_submodel ) {
363372 check_mod_val(model , existence = TRUE )
373+ check_eng_val(eng )
364374 check_arg_val(parsnip )
365375 check_arg_val(original )
366376 check_func_val(func )
@@ -406,6 +416,7 @@ set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
406416# ' @export
407417set_dependency <- function (model , eng , pkg ) {
408418 check_mod_val(model , existence = TRUE )
419+ check_eng_val(eng )
409420 check_pkg_val(pkg )
410421
411422 current <- get_model_env()
@@ -464,6 +475,7 @@ get_dependency <- function(model) {
464475# ' @export
465476set_fit <- function (model , mode , eng , value ) {
466477 check_mod_val(model , existence = TRUE )
478+ check_eng_val(eng )
467479 check_mode_val(mode )
468480 check_engine_val(eng )
469481 check_fit_info(value )
@@ -529,6 +541,7 @@ get_fit <- function(model) {
529541# ' @export
530542set_pred <- function (model , mode , eng , type , value ) {
531543 check_mod_val(model , existence = TRUE )
544+ check_eng_val(eng )
532545 check_mode_val(mode )
533546 check_engine_val(eng )
534547 check_pred_info(value , type )
0 commit comments