diff --git a/R/glmnet-engines.R b/R/glmnet-engines.R index 0e6514c69..8ff5d9531 100644 --- a/R/glmnet-engines.R +++ b/R/glmnet-engines.R @@ -361,12 +361,13 @@ format_glmnet_multinom_class <- function(pred, penalty, lvl, n_obs) { pen <- rlang::eval_tidy(x$args$penalty) if (length(pen) != 1) { - rlang::abort(c( - "For the glmnet engine, `penalty` must be a single number (or a value of `tune()`).", - glue::glue("There are {length(pen)} values for `penalty`."), - "To try multiple values for total regularization, use the tune package.", - "To predict multiple penalties, use `multi_predict()`" - )) + cli::cli_abort(c( + "x" = "For the glmnet engine, {.var penalty} must be a single number + (or a value of {.fn tune}).", + "!" = "There are {length(pen)} value{?s} for {.var penalty}.", + "i" = "To try multiple values for total regularization, use the + {.pkg tune} package.", + "i" = "To predict multiple penalties, use {.fn multi_predict}.")) } } @@ -385,23 +386,19 @@ format_glmnet_multinom_class <- function(pred, penalty, lvl, n_obs) { # when using `predict()`, allow for a single lambda if (!multi) { if (length(penalty) != 1) { - rlang::abort( - glue::glue( - "`penalty` should be a single numeric value. `multi_predict()` ", - "can be used to get multiple predictions per row of data." - ) - ) + cli::cli_abort(c( + "{.var penalty} should be a single numeric value. {.fn multi_predict} + can be used to get multiple predictions per row of data." + )) } } if (length(object$fit$lambda) == 1 && penalty != object$fit$lambda) { - rlang::abort( - glue::glue( - "The glmnet model was fit with a single penalty value of ", - "{object$fit$lambda}. Predicting with a value of {penalty} ", - "will give incorrect results from `glmnet()`." - ) - ) + cli::cli_abort(c( + "The glmnet model was fit with a single penalty value of + {.var object$fit$lambda}. Predicting with a value of {.envar penalty} + will give incorrect results from `glmnet()`." + )) } penalty diff --git a/R/logistic_reg.R b/R/logistic_reg.R index 40ccf5dc5..dc8e985e1 100644 --- a/R/logistic_reg.R +++ b/R/logistic_reg.R @@ -98,7 +98,7 @@ translate.logistic_reg <- function(x, engine = x$engine, ...) { } else if (quo_get_expr(x$args$mixture) == 1) { arg_vals$type <- 6 ## lasso } else { - rlang::abort("For the LiblineaR engine, mixture must be 0 or 1.") + cli::cli_abort(c("x" = "For the LiblineaR engine, {.var mixture} must be 0 or 1.")) } } x$method$fit$args <- arg_vals @@ -153,7 +153,7 @@ check_args.logistic_reg <- function(object, call = rlang::caller_env()) { call = call ) } - + if ((!is.null(args$penalty)) && args$penalty == 0) { cli::cli_abort( "For the {.pkg LiblineaR} engine, {.arg penalty} must be {.code > 0}, \\ diff --git a/R/mars.R b/R/mars.R index f4ad10ae7..6b21f49fe 100644 --- a/R/mars.R +++ b/R/mars.R @@ -161,14 +161,14 @@ multi_predict._earth <- object$fit$call[[i]] <- eval_tidy(object$fit$call[[i]]) } - msg <- - paste("Please use `keepxy = TRUE` as an option to enable submodel", - "predictions with `earth`.") + msg <- c("x" = "Please use {.code keepxy = TRUE} as an + option to enable submodel predictions with + {.var earth}.") if (any(names(object$fit$call) == "keepxy")) { if (!isTRUE(object$fit$call$keepxy)) - rlang::abort(msg) + cli::cli_abort(msg) } else { - rlang::abort(msg) + cli::cli_abort(msg) } if (is.null(type)) { diff --git a/R/mlp.R b/R/mlp.R index fa3cf097c..f37d2eff8 100644 --- a/R/mlp.R +++ b/R/mlp.R @@ -148,7 +148,7 @@ check_args.mlp <- function(object, call = rlang::caller_env()) { class2ind <- function (x, drop2nd = FALSE) { if (!is.factor(x)) - rlang::abort("`x` should be a factor") + cli::cli_abort(c("x" = "{.var x} should be a factor.")) y <- model.matrix( ~ x - 1) colnames(y) <- gsub("^x", "", colnames(y)) attributes(y)$assign <- NULL @@ -195,8 +195,9 @@ keras_mlp <- rlang::arg_match(activation, act_funs,) if (penalty > 0 & dropout > 0) { - rlang::abort("Please use either dropoput or weight decay.", call. = FALSE) - } + cli::cli_abort(c("x" = "Please use either dropout or weight decay", + call = NULL)) + } if (!is.matrix(x)) { x <- as.matrix(x) }