Skip to content

Commit abcd97d

Browse files
author
‘topepo’
committed
fix some issues
1 parent 5176e86 commit abcd97d

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

R/arguments.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ set_mode <- function(object, mode, ...) {
9292
}
9393

9494
#' @export
95-
set_mode.model_spec <- function(object, mode, quantile_level = NULL) {
95+
set_mode.model_spec <- function(object, mode, quantile_level = NULL, ...) {
9696
cls <- class(object)[1]
9797
if (rlang::is_missing(mode)) {
9898
spec_modes <- rlang::env_get(get_model_env(), paste0(cls, "_modes"))
@@ -115,7 +115,7 @@ set_mode.model_spec <- function(object, mode, quantile_level = NULL) {
115115
}
116116

117117
#' @export
118-
set_mode.default <- function(object, mode) {
118+
set_mode.default <- function(object, mode, ...) {
119119
error_set_object(object, func = "set_mode")
120120

121121
invisible(FALSE)

R/predict.R

+5-8
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,12 @@ check_pred_type <- function(object, type, ...) {
198198
regression = "numeric",
199199
classification = "class",
200200
"censored regression" = "time",
201-
rlang::abort("`type` should be 'regression', 'censored regression', or 'classification'."))
201+
"quantile regression" = "quantile",
202+
cli::cli_abort("{.arg type} should be one of {.val {all_modes}}."))
203+
}
204+
if (!(type %in% pred_types)) {
205+
cli::cli_abort("{.arg type} should be one of {.val {pred_types}}.")
202206
}
203-
if (!(type %in% pred_types))
204-
rlang::abort(
205-
glue::glue(
206-
"`type` should be one of: ",
207-
glue_collapse(pred_types, sep = ", ", last = " and ")
208-
)
209-
)
210207

211208
switch(
212209
type,

tests/testthat/_snaps/args_and_modes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
linear_reg() %>% set_mode()
6161
Condition
6262
Error in `set_mode()`:
63-
! Available modes for model type linear_reg are: "unknown" and "regression".
63+
! Available modes for model type linear_reg are: "unknown", "regression", and "quantile regression".
6464

6565
---
6666

@@ -77,7 +77,7 @@
7777
linear_reg() %>% set_engine()
7878
Condition
7979
Error in `set_engine()`:
80-
! Missing engine. Possible mode/engine combinations are: regression {lm, glm, glmnet, stan, spark, keras, brulee}.
80+
! Missing engine. Possible mode/engine combinations are: quantile regression {quantreg} and regression {lm, glm, glmnet, stan, spark, keras, brulee}.
8181

8282
---
8383

0 commit comments

Comments
 (0)