diff --git a/R/class-kap.R b/R/class-kap.R index 4566530d..2519da75 100644 --- a/R/class-kap.R +++ b/R/class-kap.R @@ -178,7 +178,7 @@ make_weighting_matrix <- function(weighting, n_levels, call = caller_env()) { validate_weighting <- function(x, call = caller_env()) { if (!is_string(x)) { - abort("`weighting` must be a string.", call = call) + cli::cli_abort("{.arg weighting} must be a string.", call = call) } ok <- is_no_weighting(x) || @@ -186,7 +186,11 @@ validate_weighting <- function(x, call = caller_env()) { is_quadratic_weighting(x) if (!ok) { - abort("`weighting` must be 'none', 'linear', or 'quadratic'.", call = call) + cli::cli_abort( + "{.arg weighting} must be {.val none}, {.val linear}, or \\ + {.val quadratic}, not {.val {x}}.", + call = call + ) } invisible(x) diff --git a/R/class-mcc.R b/R/class-mcc.R index 72808f5b..a3461f52 100644 --- a/R/class-mcc.R +++ b/R/class-mcc.R @@ -161,7 +161,10 @@ mcc_multiclass_impl <- function(C) { check_mcc_data <- function(data) { if (!is.double(data) && !is.matrix(data)) { - abort("`data` should be a double matrix at this point.", .internal = TRUE) + cli::cli_abort( + "{.arg data} should be a double matrix at this point.", + .internal = TRUE + ) } invisible() } diff --git a/R/conf_mat.R b/R/conf_mat.R index 5a384679..d6ff1b3b 100644 --- a/R/conf_mat.R +++ b/R/conf_mat.R @@ -223,7 +223,10 @@ conf_mat_impl <- function(truth, estimate, case_weights, call = caller_env()) { check_class_metric(truth, estimate, case_weights, estimator, call = call) if (length(levels(truth)) < 2) { - abort("`truth` must have at least 2 factor levels.", call = call) + cli::cli_abort( + "{.arg truth} must have at least 2 factor levels.", + call = call + ) } yardstick_table( @@ -245,7 +248,9 @@ conf_mat.table <- function(data, ...) { num_lev <- length(class_lev) if (num_lev < 2) { - abort("There must be at least 2 factors levels in the `data`") + cli::cli_abort( + "There must be at least 2 factors levels in the {.arg data}." + ) } structure( diff --git a/R/misc.R b/R/misc.R index 953391e2..13f74b3b 100644 --- a/R/misc.R +++ b/R/misc.R @@ -4,7 +4,7 @@ pos_val <- function(xtab, event_level) { if (!all(dim(xtab) == 2)) { - abort("Only relevant for 2x2 tables") + cli::cli_abort("Only relevant for 2x2 tables.") } if (is_event_first(event_level)) { @@ -16,7 +16,7 @@ pos_val <- function(xtab, event_level) { neg_val <- function(xtab, event_level) { if (!all(dim(xtab) == 2)) { - abort("Only relevant for 2x2 tables") + cli::cli_abort("Only relevant for 2x2 tables.") } if (is_event_first(event_level)) { @@ -67,19 +67,19 @@ as_factor_from_class_pred <- function(x) { } if (!is_installed("probably")) { - abort(paste0( - "A input was detected, but the probably package ", - "isn't installed. Install probably to be able to convert ", - "to ." - )) + cli::cli_abort( + "A {.cls class_pred} input was detected, but the {.pkg probably} \\ + package isn't installed. Install {.pkg probably} to be able to convert \\ + {.cls class_pred} to {.cls factor}." + ) } probably::as.factor(x) } abort_if_class_pred <- function(x, call = caller_env()) { if (is_class_pred(x)) { - abort( - "`truth` should not a `class_pred` object.", + cli::cli_abort( + "{.arg truth} should not a {.cls class_pred} object.", call = call ) } @@ -186,10 +186,18 @@ yardstick_cov <- function(truth, size <- vec_size(truth) if (size != vec_size(estimate)) { - abort("`truth` and `estimate` must be the same size.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({vec_size(truth)}) and \\ + {.arg estimate} ({vec_size(estimate)}) must be the same size.", + .internal = TRUE + ) } if (size != vec_size(case_weights)) { - abort("`truth` and `case_weights` must be the same size.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({vec_size(truth)}) and \\ + {.arg case_weights} ({vec_size(case_weights)}) must be the same size.", + .internal = TRUE + ) } if (size == 0L || size == 1L) { @@ -232,10 +240,18 @@ yardstick_cor <- function(truth, size <- vec_size(truth) if (size != vec_size(estimate)) { - abort("`truth` and `estimate` must be the same size.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({vec_size(truth)}) and \\ + {.arg estimate} ({vec_size(estimate)}) must be the same size.", + .internal = TRUE + ) } if (size != vec_size(case_weights)) { - abort("`truth` and `case_weights` must be the same size.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({vec_size(truth)}) and \\ + {.arg case_weights} ({vec_size(case_weights)}) must be the same size.", + .internal = TRUE + ) } if (size == 0L || size == 1L) { @@ -345,14 +361,17 @@ weighted_quantile <- function(x, weights, probabilities) { size <- vec_size(x) if (size != vec_size(weights)) { - abort("`x` and `weights` must have the same size.") + cli::cli_abort( + "{.arg x} ({vec_size(x)}) and {.arg weights} ({vec_size(weights)}) \\ + must have the same size." + ) } if (any(is.na(probabilities))) { - abort("`probabilities` can't be missing.") + cli::cli_abort("{.arg probabilities} can't have missing values.") } if (any(probabilities > 1 | probabilities < 0)) { - abort("`probabilities` must be within `[0, 1]`.") + cli::cli_abort("{.arg probabilities} must be within `[0, 1]`.") } if (size == 0L) { @@ -397,20 +416,33 @@ yardstick_table <- function(truth, estimate, ..., case_weights = NULL) { } if (!is.factor(truth)) { - abort("`truth` must be a factor.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} must be a factor, not {.obj_type_friendly {truth}}.", + .internal = TRUE + ) } if (!is.factor(estimate)) { - abort("`estimate` must be a factor.", .internal = TRUE) + cli::cli_abort( + "{.arg estimate} must be a factor, not {.obj_type_friendly {estimate}}.", + .internal = TRUE + ) } levels <- levels(truth) n_levels <- length(levels) if (!identical(levels, levels(estimate))) { - abort("`truth` and `estimate` must have the same levels in the same order.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} and {.arg estimate} must have the same levels in the same \\ + order.", + .internal = TRUE + ) } if (n_levels < 2) { - abort("`truth` must have at least 2 factor levels.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} must have at least 2 factor levels.", + .internal = TRUE + ) } # Supply `estimate` first to get it to correspond to the row names. @@ -447,14 +479,17 @@ yardstick_truth_table <- function(truth, ..., case_weights = NULL) { abort_if_class_pred(truth) if (!is.factor(truth)) { - abort("`truth` must be a factor.", .internal = TRUE) + cli::cli_abort("{.arg truth} must be a factor.", .internal = TRUE) } levels <- levels(truth) n_levels <- length(levels) if (n_levels < 2) { - abort("`truth` must have at least 2 factor levels.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} must have at least 2 factor levels.", + .internal = TRUE + ) } # Always return a double matrix for type stability diff --git a/R/num-huber_loss.R b/R/num-huber_loss.R index a31eeb11..d418c064 100644 --- a/R/num-huber_loss.R +++ b/R/num-huber_loss.R @@ -85,12 +85,7 @@ huber_loss_impl <- function(truth, # Weighted Huber Loss implementation confirmed against matlab: # https://www.mathworks.com/help/deeplearning/ref/dlarray.huber.html - if (!is_bare_numeric(delta, n = 1L)) { - abort("`delta` must be a single numeric value.", call = call) - } - if (!(delta >= 0)) { - abort("`delta` must be a positive value.", call = call) - } + check_number_decimal(delta, min = 0, call = call) a <- truth - estimate abs_a <- abs(a) diff --git a/R/num-mase.R b/R/num-mase.R index bde04db7..378b76ff 100644 --- a/R/num-mase.R +++ b/R/num-mase.R @@ -114,8 +114,8 @@ mase_impl <- function(truth, mae_train = NULL, case_weights = NULL, call = caller_env()) { - validate_m(m, call = call) - validate_mae_train(mae_train, call = call) + check_number_whole(m, min = 0, call = call) + check_number_decimal(mae_train, min = 0, allow_null = TRUE, call = call) if (is.null(mae_train)) { validate_truth_m(truth, m, call = call) @@ -139,46 +139,12 @@ mase_impl <- function(truth, out } -validate_m <- function(m, call = caller_env()) { - abort_msg <- "`m` must be a single positive integer value." - - if (!is_integerish(m, n = 1L)) { - abort(abort_msg, call = call) - } - - if (!(m > 0)) { - abort(abort_msg, call = call) - } - - invisible(m) -} - -validate_mae_train <- function(mae_train, call = caller_env()) { - if (is.null(mae_train)) { - return(invisible(mae_train)) - } - - is_single_numeric <- is_bare_numeric(mae_train, n = 1L) - abort_msg <- "`mae_train` must be a single positive numeric value." - - if (!is_single_numeric) { - abort(abort_msg, call = call) - } - - if (!(mae_train > 0)) { - abort(abort_msg, call = call) - } - - invisible(mae_train) -} - validate_truth_m <- function(truth, m, call = caller_env()) { if (length(truth) <= m) { - abort(paste0( - "`truth` must have a length greater than `m` ", - "to compute the out-of-sample naive mean absolute error." - ), call = call) + cli::cli_abort( + "{.arg truth} ({length(truth)}) must have a length greater than \\ + {.arg m} ({m}) to compute the out-of-sample naive mean absolute error.", + call = call + ) } - - invisible(truth) } diff --git a/R/num-pseudo_huber_loss.R b/R/num-pseudo_huber_loss.R index ac616a29..b6724d62 100644 --- a/R/num-pseudo_huber_loss.R +++ b/R/num-pseudo_huber_loss.R @@ -86,12 +86,7 @@ huber_loss_pseudo_impl <- function(truth, delta, case_weights, call = caller_env()) { - if (!is_bare_numeric(delta, n = 1L)) { - abort("`delta` must be a single numeric value.", call = call) - } - if (!(delta >= 0)) { - abort("`delta` must be a positive value.", call = call) - } + check_number_decimal(delta, min = 0, call = call) a <- truth - estimate loss <- delta^2 * (sqrt(1 + (a / delta)^2) - 1) diff --git a/R/prob-binary-thresholds.R b/R/prob-binary-thresholds.R index e38a15cb..9f89074c 100644 --- a/R/prob-binary-thresholds.R +++ b/R/prob-binary-thresholds.R @@ -16,19 +16,36 @@ binary_threshold_curve <- function(truth, case_weights <- vec_cast(case_weights, to = double()) if (!is.factor(truth)) { - abort("`truth` must be a factor.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} must be a factor, not {.obj_friendly_type {truth}}.", + .internal = TRUE + ) } if (length(levels(truth)) != 2L) { - abort("`truth` must have two levels.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} must have two levels, not {length(levels(truth))}.", + .internal = TRUE + ) } if (!is.numeric(estimate)) { - abort("`estimate` must be numeric.", .internal = TRUE) + cli::cli_abort( + "{.arg estimate} must be numeric, not {.obj_friendly_type {estimate}}.", + .internal = TRUE + ) } if (length(truth) != length(estimate)) { - abort("`truth` and `estimate` must be the same length.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({length(truth)}) and \\ + {.arg estimate} ({length(estimate)}) must be the same length.", + .internal = TRUE + ) } if (length(truth) != length(case_weights)) { - abort("`truth` and `case_weights` must be the same length.", .internal = TRUE) + cli::cli_abort( + "{.arg truth} ({length(truth)}) and \\ + {.arg case_weights} ({length(case_weights)}) must be the same length.", + .internal = TRUE + ) } truth <- unclass(truth) diff --git a/R/prob-classification_cost.R b/R/prob-classification_cost.R index 72b49188..7042e83b 100644 --- a/R/prob-classification_cost.R +++ b/R/prob-classification_cost.R @@ -221,48 +221,60 @@ validate_costs <- function(costs, levels) { return(costs) } - if (!is.data.frame(costs)) { - abort("`costs` must be `NULL` or a data.frame.") - } + check_data_frame(costs, allow_null = TRUE) columns <- names(costs) if (length(columns) != 3L) { - abort("`costs` must be a data.frame with 3 columns.") + cli::cli_abort( + "{.arg costs} must be a data.frame with 3 columns, not {length(columns)}." + ) } ok <- identical(sort(columns), sort(c("truth", "estimate", "cost"))) if (!ok) { - abort("`costs` must have columns: 'truth', 'estimate', and 'cost'.") + cli::cli_abort( + "{.arg costs} must have columns: \\ + {.val truth}, {.val estimate}, and {.val cost}. Not {columns}." + ) } if (is.factor(costs$truth)) { costs$truth <- as.character(costs$truth) } if (!is.character(costs$truth)) { - abort("`costs$truth` must be a character or factor column.") + cli::cli_abort( + "{.code costs$truth} must be a character or factor column, \\ + not {.obj_friendly_type {costs$truth}}." + ) } if (is.factor(costs$estimate)) { costs$estimate <- as.character(costs$estimate) } if (!is.character(costs$estimate)) { - abort("`costs$estimate` must be a character or factor column.") + cli::cli_abort( + "{.code costs$estimate} must be a character or factor column, \\ + not {.obj_friendly_type {costs$estimate}}." + ) } if (!is.numeric(costs$cost)) { - abort("`costs$cost` must be a numeric column.") + cli::cli_abort( + "{.code costs$cost} must be a numeric column, \\ + not {.obj_friendly_type {costs$cost}}." + ) } ok <- all(costs$truth %in% levels) if (is_false(ok)) { levels <- quote_and_collapse(levels) - abort(paste0("`costs$truth` can only contain ", levels, ".")) + cli::cli_abort("{.code costs$truth} can only contain {levels}.") } ok <- all(costs$estimate %in% levels) if (is_false(ok)) { levels <- quote_and_collapse(levels) - abort(paste0("`costs$estimate` can only contain ", levels, ".")) + cli::cli_abort("{.code costs$estimate} can only contain {levels}.") } pairs <- costs[c("truth", "estimate")] @@ -270,7 +282,10 @@ validate_costs <- function(costs, levels) { not_ok <- vec_duplicate_any(pairs) if (not_ok) { - abort("`costs` cannot have duplicate 'truth' / 'estimate' combinations.") + cli::cli_abort( + "{.field costs} cannot have duplicate \\ + {.field truth} / {.field estimate} combinations." + ) } out <- generate_all_level_combinations(levels) diff --git a/R/prob-roc_auc.R b/R/prob-roc_auc.R index 97f1b202..728dd64d 100644 --- a/R/prob-roc_auc.R +++ b/R/prob-roc_auc.R @@ -163,7 +163,10 @@ roc_auc_estimator_impl <- function(truth, roc_auc_binary(truth, estimate, event_level, case_weights) } else if (estimator == "hand_till") { if (!is.null(case_weights)) { - abort("`case_weights` should be `NULL` at this point for hand-till.", .internal = TRUE) + cli::cli_abort( + "{.arg case_weights} should be `NULL` at this point for hand-till.", + .internal = TRUE + ) } roc_auc_hand_till(truth, estimate) @@ -258,7 +261,10 @@ finalize_estimator_roc_auc <- function(x, estimator <- "macro" } else { # Manually chose hand-till and specified case weights. Not compatible! - abort("Can't specify both `estimator = 'hand_till'` and `case_weights`.") + cli::cli_abort( + "Can't specify both {.code estimator = 'hand_till'} and \\ + {.code case_weights}." + ) } } @@ -396,7 +402,7 @@ warn_roc_truth_no_control <- function(control) { ) } stop_roc_truth_no_control <- function(control) { - abort( + cli::cli_abort( msg_roc_truth_no_control(control), class = "yardstick_error_roc_truth_no_control" ) @@ -415,7 +421,7 @@ warn_roc_truth_no_event <- function(event) { ) } stop_roc_truth_no_event <- function(event) { - abort( + cli::cli_abort( msg_roc_truth_no_event(event), class = "yardstick_error_roc_truth_no_event" ) diff --git a/tests/testthat/_snaps/class-accuracy.md b/tests/testthat/_snaps/class-accuracy.md index 0ebfd5d5..61aceec8 100644 --- a/tests/testthat/_snaps/class-accuracy.md +++ b/tests/testthat/_snaps/class-accuracy.md @@ -4,5 +4,5 @@ accuracy_vec(cp_truth, cp_estimate) Condition Error in `accuracy_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-detection_prevalence.md b/tests/testthat/_snaps/class-detection_prevalence.md index 2f2145f0..629917e8 100644 --- a/tests/testthat/_snaps/class-detection_prevalence.md +++ b/tests/testthat/_snaps/class-detection_prevalence.md @@ -4,5 +4,5 @@ detection_prevalence_vec(cp_truth, cp_estimate) Condition Error in `detection_prevalence_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-f_meas.md b/tests/testthat/_snaps/class-f_meas.md index 08132b45..ae33112d 100644 --- a/tests/testthat/_snaps/class-f_meas.md +++ b/tests/testthat/_snaps/class-f_meas.md @@ -80,5 +80,5 @@ f_meas_vec(cp_truth, cp_estimate) Condition Error in `f_meas_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-j_index.md b/tests/testthat/_snaps/class-j_index.md index 8463d479..aa868a93 100644 --- a/tests/testthat/_snaps/class-j_index.md +++ b/tests/testthat/_snaps/class-j_index.md @@ -52,5 +52,5 @@ j_index_vec(cp_truth, cp_estimate) Condition Error in `j_index_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-kap.md b/tests/testthat/_snaps/class-kap.md index bd2338ef..e9934ee0 100644 --- a/tests/testthat/_snaps/class-kap.md +++ b/tests/testthat/_snaps/class-kap.md @@ -12,7 +12,7 @@ kap(three_class, truth = "obs", estimate = "pred", weighting = "not right") Condition Error in `kap()`: - ! `weighting` must be 'none', 'linear', or 'quadratic'. + ! `weighting` must be "none", "linear", or "quadratic", not "not right". # work with class_pred input @@ -20,5 +20,5 @@ kap_vec(cp_truth, cp_estimate) Condition Error in `kap_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-mcc.md b/tests/testthat/_snaps/class-mcc.md index e59805a5..1e046607 100644 --- a/tests/testthat/_snaps/class-mcc.md +++ b/tests/testthat/_snaps/class-mcc.md @@ -4,5 +4,5 @@ mcc_vec(cp_truth, cp_estimate) Condition Error in `mcc_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-npv.md b/tests/testthat/_snaps/class-npv.md index 0ebfd5d5..61aceec8 100644 --- a/tests/testthat/_snaps/class-npv.md +++ b/tests/testthat/_snaps/class-npv.md @@ -4,5 +4,5 @@ accuracy_vec(cp_truth, cp_estimate) Condition Error in `accuracy_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-ppv.md b/tests/testthat/_snaps/class-ppv.md index 29fa28d8..c0332ae5 100644 --- a/tests/testthat/_snaps/class-ppv.md +++ b/tests/testthat/_snaps/class-ppv.md @@ -14,5 +14,5 @@ ppv_vec(cp_truth, cp_estimate) Condition Error in `ppv_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-precision.md b/tests/testthat/_snaps/class-precision.md index 8d262769..4fa54bda 100644 --- a/tests/testthat/_snaps/class-precision.md +++ b/tests/testthat/_snaps/class-precision.md @@ -38,5 +38,5 @@ precision_vec(cp_truth, cp_estimate) Condition Error in `precision_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-recall.md b/tests/testthat/_snaps/class-recall.md index dd21bb27..6267250c 100644 --- a/tests/testthat/_snaps/class-recall.md +++ b/tests/testthat/_snaps/class-recall.md @@ -26,5 +26,5 @@ recall_vec(cp_truth, cp_estimate) Condition Error in `recall_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-sens.md b/tests/testthat/_snaps/class-sens.md index 987e1f31..71ea7667 100644 --- a/tests/testthat/_snaps/class-sens.md +++ b/tests/testthat/_snaps/class-sens.md @@ -26,5 +26,5 @@ sensitivity_vec(cp_truth, cp_estimate) Condition Error in `sensitivity_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/class-spec.md b/tests/testthat/_snaps/class-spec.md index ec09ccb7..cd67e613 100644 --- a/tests/testthat/_snaps/class-spec.md +++ b/tests/testthat/_snaps/class-spec.md @@ -25,5 +25,5 @@ specificity_vec(cp_truth, cp_estimate) Condition Error in `specificity_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/misc.md b/tests/testthat/_snaps/misc.md index 56d1f961..b1d4e720 100644 --- a/tests/testthat/_snaps/misc.md +++ b/tests/testthat/_snaps/misc.md @@ -4,7 +4,7 @@ yardstick_table(1, x) Condition Error in `yardstick_table()`: - ! `truth` must be a factor. + ! `truth` must be a factor, not a number. i This is an internal error that was detected in the yardstick package. Please report it at with a reprex () and the full backtrace. @@ -14,7 +14,7 @@ yardstick_table(x, 2) Condition Error in `yardstick_table()`: - ! `estimate` must be a factor. + ! `estimate` must be a factor, not a number. i This is an internal error that was detected in the yardstick package. Please report it at with a reprex () and the full backtrace. @@ -118,7 +118,7 @@ weighted_quantile(1, 1:2, 0.5) Condition Error in `weighted_quantile()`: - ! `x` and `weights` must have the same size. + ! `x` (1) and `weights` (2) must have the same size. # `probabilities` is validated @@ -150,5 +150,5 @@ weighted_quantile(1, 1, NA) Condition Error in `weighted_quantile()`: - ! `probabilities` can't be missing. + ! `probabilities` can't have missing values. diff --git a/tests/testthat/_snaps/num-huber_loss.md b/tests/testthat/_snaps/num-huber_loss.md index 91108aa1..eaa12251 100644 --- a/tests/testthat/_snaps/num-huber_loss.md +++ b/tests/testthat/_snaps/num-huber_loss.md @@ -4,7 +4,7 @@ huber_loss(ex_dat, truth = "obs", estimate = "pred_na", delta = -1) Condition Error in `huber_loss()`: - ! `delta` must be a positive value. + ! `delta` must be a number larger than or equal to 0, not the number -1. --- @@ -12,5 +12,5 @@ huber_loss(ex_dat, truth = "obs", estimate = "pred_na", delta = c(1, 2)) Condition Error in `huber_loss()`: - ! `delta` must be a single numeric value. + ! `delta` must be a number, not a double vector. diff --git a/tests/testthat/_snaps/num-mase.md b/tests/testthat/_snaps/num-mase.md index 8676bc32..470e39f2 100644 --- a/tests/testthat/_snaps/num-mase.md +++ b/tests/testthat/_snaps/num-mase.md @@ -4,7 +4,7 @@ mase_vec(truth, pred, m = "x") Condition Error in `mase_vec()`: - ! `m` must be a single positive integer value. + ! `m` must be a whole number, not the string "x". --- @@ -12,7 +12,7 @@ mase_vec(truth, pred, m = -1) Condition Error in `mase_vec()`: - ! `m` must be a single positive integer value. + ! `m` must be a whole number larger than or equal to 0, not the number -1. --- @@ -20,7 +20,7 @@ mase_vec(truth, pred, m = 1.5) Condition Error in `mase_vec()`: - ! `m` must be a single positive integer value. + ! `m` must be a whole number, not the number 1.5. --- @@ -28,7 +28,7 @@ mase_vec(truth, pred, mae_train = -1) Condition Error in `mase_vec()`: - ! `mae_train` must be a single positive numeric value. + ! `mae_train` must be a number larger than or equal to 0 or `NULL`, not the number -1. --- @@ -36,5 +36,5 @@ mase_vec(truth, pred, mae_train = "x") Condition Error in `mase_vec()`: - ! `mae_train` must be a single positive numeric value. + ! `mae_train` must be a number or `NULL`, not the string "x". diff --git a/tests/testthat/_snaps/num-pseudo_huber_loss.md b/tests/testthat/_snaps/num-pseudo_huber_loss.md index 87e8c957..3d0f14f4 100644 --- a/tests/testthat/_snaps/num-pseudo_huber_loss.md +++ b/tests/testthat/_snaps/num-pseudo_huber_loss.md @@ -4,7 +4,7 @@ huber_loss_pseudo(ex_dat, truth = "obs", estimate = "pred_na", delta = -1) Condition Error in `huber_loss_pseudo()`: - ! `delta` must be a positive value. + ! `delta` must be a number larger than or equal to 0, not the number -1. --- @@ -12,5 +12,5 @@ huber_loss_pseudo(ex_dat, truth = "obs", estimate = "pred_na", delta = c(1, 2)) Condition Error in `huber_loss_pseudo()`: - ! `delta` must be a single numeric value. + ! `delta` must be a number, not a double vector. diff --git a/tests/testthat/_snaps/prob-average_precision.md b/tests/testthat/_snaps/prob-average_precision.md index 80a863f5..cabc858b 100644 --- a/tests/testthat/_snaps/prob-average_precision.md +++ b/tests/testthat/_snaps/prob-average_precision.md @@ -28,5 +28,5 @@ average_precision_vec(cp_truth, estimate) Condition Error in `average_precision_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-brier_class.md b/tests/testthat/_snaps/prob-brier_class.md index bdc15b23..98124dd2 100644 --- a/tests/testthat/_snaps/prob-brier_class.md +++ b/tests/testthat/_snaps/prob-brier_class.md @@ -4,5 +4,5 @@ brier_class_vec(cp_truth, estimate) Condition Error in `brier_class_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-classification_cost.md b/tests/testthat/_snaps/prob-classification_cost.md index 4832b4ef..ba5df219 100644 --- a/tests/testthat/_snaps/prob-classification_cost.md +++ b/tests/testthat/_snaps/prob-classification_cost.md @@ -12,7 +12,7 @@ classification_cost(df, obs, A, costs = 1) Condition Error in `classification_cost()`: - ! `costs` must be `NULL` or a data.frame. + ! `costs` must be a data frame or `NULL`, not the number 1. --- @@ -20,7 +20,7 @@ classification_cost(df, obs, A, costs = data.frame()) Condition Error in `classification_cost()`: - ! `costs` must be a data.frame with 3 columns. + ! `costs` must be a data.frame with 3 columns, not 0. --- @@ -28,7 +28,7 @@ classification_cost(df, obs, A, costs = data.frame(x = 1, y = 2, z = 3)) Condition Error in `classification_cost()`: - ! `costs` must have columns: 'truth', 'estimate', and 'cost'. + ! `costs` must have columns: "truth", "estimate", and "cost". Not x, y, and z. # costs$estimate must contain the right levels @@ -52,7 +52,7 @@ classification_cost(df, obs, A, costs = costs) Condition Error in `classification_cost()`: - ! `costs$truth` must be a character or factor column. + ! `costs$truth` must be a character or factor column, not 1 and 2. --- @@ -60,7 +60,7 @@ classification_cost(df, obs, A, costs = costs) Condition Error in `classification_cost()`: - ! `costs$estimate` must be a character or factor column. + ! `costs$estimate` must be a character or factor column, not 1 and 2. --- @@ -68,7 +68,7 @@ classification_cost(df, obs, A, costs = costs) Condition Error in `classification_cost()`: - ! `costs$cost` must be a numeric column. + ! `costs$cost` must be a numeric column, not 1 and 2. # costs$truth and costs$estimate cannot contain duplicate pairs @@ -76,7 +76,7 @@ classification_cost(df, obs, A, costs = costs) Condition Error in `classification_cost()`: - ! `costs` cannot have duplicate 'truth' / 'estimate' combinations. + ! costs cannot have duplicate truth / estimate combinations. # errors with class_pred input @@ -84,5 +84,5 @@ classification_cost_vec(cp_truth, estimate) Condition Error in `classification_cost_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-gain_capture.md b/tests/testthat/_snaps/prob-gain_capture.md index 5c0a539f..78dc42ff 100644 --- a/tests/testthat/_snaps/prob-gain_capture.md +++ b/tests/testthat/_snaps/prob-gain_capture.md @@ -4,5 +4,5 @@ gain_capture_vec(cp_truth, estimate) Condition Error in `gain_capture_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-lift_curve.md b/tests/testthat/_snaps/prob-lift_curve.md index 37fea3c1..f03d72f5 100644 --- a/tests/testthat/_snaps/prob-lift_curve.md +++ b/tests/testthat/_snaps/prob-lift_curve.md @@ -12,5 +12,5 @@ lift_curve_vec(cp_truth, estimate) Condition Error in `gain_curve_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-mn_log_loss.md b/tests/testthat/_snaps/prob-mn_log_loss.md index 79c99c85..6f7a7a39 100644 --- a/tests/testthat/_snaps/prob-mn_log_loss.md +++ b/tests/testthat/_snaps/prob-mn_log_loss.md @@ -4,5 +4,5 @@ mn_log_loss_vec(cp_truth, estimate) Condition Error in `mn_log_loss_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-pr_auc.md b/tests/testthat/_snaps/prob-pr_auc.md index ad676c3a..f7f2a014 100644 --- a/tests/testthat/_snaps/prob-pr_auc.md +++ b/tests/testthat/_snaps/prob-pr_auc.md @@ -4,5 +4,5 @@ pr_auc_vec(cp_truth, estimate) Condition Error in `pr_auc_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-pr_curve.md b/tests/testthat/_snaps/prob-pr_curve.md index eb1eb8f7..0338948f 100644 --- a/tests/testthat/_snaps/prob-pr_curve.md +++ b/tests/testthat/_snaps/prob-pr_curve.md @@ -12,5 +12,5 @@ pr_curve_vec(cp_truth, estimate) Condition Error in `pr_curve_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-roc_auc.md b/tests/testthat/_snaps/prob-roc_auc.md index fa41d71d..d291c698 100644 --- a/tests/testthat/_snaps/prob-roc_auc.md +++ b/tests/testthat/_snaps/prob-roc_auc.md @@ -109,5 +109,5 @@ roc_auc_vec(cp_truth, estimate) Condition Error in `roc_auc_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-roc_aunp.md b/tests/testthat/_snaps/prob-roc_aunp.md index ff37629c..04153ead 100644 --- a/tests/testthat/_snaps/prob-roc_aunp.md +++ b/tests/testthat/_snaps/prob-roc_aunp.md @@ -31,5 +31,5 @@ roc_aunp_vec(cp_truth, estimate) Condition Error in `roc_aunp_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-roc_aunu.md b/tests/testthat/_snaps/prob-roc_aunu.md index 7f3f401a..ef22058f 100644 --- a/tests/testthat/_snaps/prob-roc_aunu.md +++ b/tests/testthat/_snaps/prob-roc_aunu.md @@ -31,5 +31,5 @@ roc_aunu_vec(cp_truth, estimate) Condition Error in `roc_aunu_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/prob-roc_curve.md b/tests/testthat/_snaps/prob-roc_curve.md index b3684b10..7e868a4a 100644 --- a/tests/testthat/_snaps/prob-roc_curve.md +++ b/tests/testthat/_snaps/prob-roc_curve.md @@ -38,5 +38,5 @@ roc_curve_vec(cp_truth, estimate) Condition Error in `roc_curve_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. diff --git a/tests/testthat/_snaps/probably.md b/tests/testthat/_snaps/probably.md index dcc7ba86..46e43eeb 100644 --- a/tests/testthat/_snaps/probably.md +++ b/tests/testthat/_snaps/probably.md @@ -4,7 +4,7 @@ accuracy_vec(cp_truth, cp_estimate) Condition Error in `accuracy_vec()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. # `class_pred` errors when passed to `conf_mat()` @@ -12,7 +12,7 @@ conf_mat(cp_hpc_cv, obs, pred) Condition Error in `conf_mat_impl()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. --- @@ -20,7 +20,7 @@ conf_mat(dplyr::group_by(cp_hpc_cv, Resample), obs, pred) Condition Error in `conf_mat_impl()`: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object. # `class_pred` errors when passed to `metrics()` @@ -30,5 +30,5 @@ Error in `metric_set()`: ! Failed to compute `accuracy()`. Caused by error: - ! `truth` should not a `class_pred` object. + ! `truth` should not a object.