Skip to content

Commit b056963

Browse files
Change warning() to rlang::warn()
1 parent 32701cb commit b056963

12 files changed

+16
-18
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ S3method(print,rand_forest)
4747
S3method(print,surv_reg)
4848
S3method(print,svm_poly)
4949
S3method(print,svm_rbf)
50+
S3method(tidy,model_fit)
5051
S3method(translate,boost_tree)
5152
S3method(translate,decision_tree)
5253
S3method(translate,default)
@@ -142,7 +143,6 @@ export(show_model_info)
142143
export(surv_reg)
143144
export(svm_poly)
144145
export(svm_rbf)
145-
export(tidy.model_fit)
146146
export(translate)
147147
export(update_dot_check)
148148
export(update_main_parameters)

R/aaa_multi_predict.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' @export
2020
multi_predict <- function(object, ...) {
2121
if (inherits(object$fit, "try-error")) {
22-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
22+
rlang::warn("Model fit failed; cannot make predictions.")
2323
return(NULL)
2424
}
2525
UseMethod("multi_predict")

R/arguments.R

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ check_eng_args <- function(args, obj, core_args) {
2424
if (length(common_args) > 0) {
2525
args <- args[!(names(args) %in% common_args)]
2626
common_args <- paste0(common_args, collapse = ", ")
27-
warning("The following arguments cannot be manually modified ",
28-
"and were removed: ",
29-
common_args, call. = FALSE)
27+
rlang::warn(glue::glue("The following arguments cannot be manually modified",
28+
"and were removed: {common_args}."))
3029
}
3130
args
3231
}

R/engines.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ check_engine <- function(object) {
1414
avail_eng <- possible_engines(object)
1515
if (is.null(object$engine)) {
1616
object$engine <- avail_eng[1]
17-
warning("`engine` was NULL and updated to be '",
18-
object$engine, "'", call. = FALSE)
17+
rlang::warn(glue::glue("`engine` was NULL and updated to be `{object$engine}`"))
1918
}
2019
if (!(object$engine %in% avail_eng)) {
2120
stop(

R/fit.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fit.model_spec <-
103103
eng_vals <- possible_engines(object)
104104
object$engine <- eng_vals[1]
105105
if (control$verbosity > 0) {
106-
warning("Engine set to `", object$engine, "`", call. = FALSE)
106+
rlang::warn("Engine set to `{object$engine}`.")
107107
}
108108
}
109109

@@ -192,7 +192,7 @@ fit_xy.model_spec <-
192192
eng_vals <- possible_engines(object)
193193
object$engine <- eng_vals[1]
194194
if (control$verbosity > 0) {
195-
warning("Engine set to `", object$engine, "`", call. = FALSE)
195+
rlang::warn(glue::glue("Engine set to `{object$engine}`."))
196196
}
197197
}
198198

R/predict.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ predict.model_fit <- function(object, new_data, type = NULL, opts = list(), ...)
113113
stop("Did you mean to use `new_data` instead of `newdata`?", call. = FALSE)
114114

115115
if (inherits(object$fit, "try-error")) {
116-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
116+
rlang::warn("Model fit failed; cannot make predictions.")
117117
return(NULL)
118118
}
119119

@@ -129,7 +129,7 @@ predict.model_fit <- function(object, new_data, type = NULL, opts = list(), ...)
129129

130130
type <- check_pred_type(object, type)
131131
if (type != "raw" && length(opts) > 0)
132-
warning("`opts` is only used with `type = 'raw'` and was ignored.")
132+
rlang::warn("`opts` is only used with `type = 'raw'` and was ignored.")
133133
res <- switch(
134134
type,
135135
numeric = predict_numeric(object = object, new_data = new_data, ...),

R/predict_class.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ predict_class.model_fit <- function(object, new_data, ...) {
1717
stop("No class prediction module defined for this model.", call. = FALSE)
1818

1919
if (inherits(object$fit, "try-error")) {
20-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
20+
rlang::warn("Model fit failed; cannot make predictions.")
2121
return(NULL)
2222
}
2323

R/predict_classprob.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ predict_classprob.model_fit <- function(object, new_data, ...) {
1414
stop("No class probability module defined for this model.", call. = FALSE)
1515

1616
if (inherits(object$fit, "try-error")) {
17-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
17+
rlang::warn("Model fit failed; cannot make predictions.")
1818
return(NULL)
1919
}
2020

R/predict_interval.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ predict_confint.model_fit <- function(object, new_data, level = 0.95, std_error
1515
"engine.", call. = FALSE)
1616

1717
if (inherits(object$fit, "try-error")) {
18-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
18+
rlang::warn("Model fit failed; cannot make predictions.")
1919
return(NULL)
2020
}
2121

@@ -64,7 +64,7 @@ predict_predint.model_fit <- function(object, new_data, level = 0.95, std_error
6464
"engine.", call. = FALSE)
6565

6666
if (inherits(object$fit, "try-error")) {
67-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
67+
rlang::warn("Model fit failed; cannot make predictions.")
6868
return(NULL)
6969
}
7070

R/predict_numeric.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ predict_numeric.model_fit <- function(object, new_data, ...) {
1515
stop("No prediction module defined for this model.", call. = FALSE)
1616

1717
if (inherits(object$fit, "try-error")) {
18-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
18+
rlang::warn("Model fit failed; cannot make predictions.")
1919
return(NULL)
2020
}
2121

R/predict_quantile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ predict_quantile.model_fit <-
1414
"engine.", call. = FALSE)
1515

1616
if (inherits(object$fit, "try-error")) {
17-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
17+
rlang::warn("Model fit failed; cannot make predictions.")
1818
return(NULL)
1919
}
2020

R/predict_raw.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ predict_raw.model_fit <- function(object, new_data, opts = list(), ...) {
1818
stop("No raw prediction module defined for this model.", call. = FALSE)
1919

2020
if (inherits(object$fit, "try-error")) {
21-
warning("Model fit failed; cannot make predictions.", call. = FALSE)
21+
rlang::warn("Model fit failed; cannot make predictions.")
2222
return(NULL)
2323
}
2424

0 commit comments

Comments
 (0)