@@ -112,6 +112,14 @@ get_model_env <- function() {
112
112
current
113
113
}
114
114
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
+
115
123
check_mod_val <- function (model , new = FALSE , existence = FALSE ) {
116
124
if (rlang :: is_missing(model ) || length(model ) != 1 )
117
125
stop(" Please supply a character string for a model name (e.g. `'linear_reg'`)" ,
@@ -337,6 +345,7 @@ set_model_mode <- function(model, mode) {
337
345
set_model_engine <- function (model , mode , eng ) {
338
346
check_mod_val(model , existence = TRUE )
339
347
check_mode_val(mode )
348
+ check_eng_val(eng )
340
349
check_mode_val(eng )
341
350
342
351
current <- get_model_env()
@@ -361,6 +370,7 @@ set_model_engine <- function(model, mode, eng) {
361
370
# ' @export
362
371
set_model_arg <- function (model , eng , parsnip , original , func , has_submodel ) {
363
372
check_mod_val(model , existence = TRUE )
373
+ check_eng_val(eng )
364
374
check_arg_val(parsnip )
365
375
check_arg_val(original )
366
376
check_func_val(func )
@@ -406,6 +416,7 @@ set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
406
416
# ' @export
407
417
set_dependency <- function (model , eng , pkg ) {
408
418
check_mod_val(model , existence = TRUE )
419
+ check_eng_val(eng )
409
420
check_pkg_val(pkg )
410
421
411
422
current <- get_model_env()
@@ -464,6 +475,7 @@ get_dependency <- function(model) {
464
475
# ' @export
465
476
set_fit <- function (model , mode , eng , value ) {
466
477
check_mod_val(model , existence = TRUE )
478
+ check_eng_val(eng )
467
479
check_mode_val(mode )
468
480
check_engine_val(eng )
469
481
check_fit_info(value )
@@ -529,6 +541,7 @@ get_fit <- function(model) {
529
541
# ' @export
530
542
set_pred <- function (model , mode , eng , type , value ) {
531
543
check_mod_val(model , existence = TRUE )
544
+ check_eng_val(eng )
532
545
check_mode_val(mode )
533
546
check_engine_val(eng )
534
547
check_pred_info(value , type )
0 commit comments