Skip to content

Commit

Permalink
Merge pull request #502 from tidymodels/cli-clustering
Browse files Browse the repository at this point in the history
Use cli error in `clustering.R` and `complement()` helper
  • Loading branch information
hfrick authored Jul 22, 2024
2 parents 041c555 + cfe719b commit 85dcee6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* The new `inner_split()` function and its methods for various resamples is for usage in tune to create a inner resample of the analysis set to fit the preprocessor and model on one part and the post-processor on the other part (#483, #488, #489).

* Started moving error messages to cli (#499, #502).

## Bug fixes

* `vfold_cv()` now utilizes the `breaks` argument correctly for repeated cross-validation (@ZWael, #471).
Expand Down
2 changes: 1 addition & 1 deletion R/clustering.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ clustering_cv <- function(data,

vars <- tidyselect::eval_select(rlang::enquo(vars), data = data)
if (rlang::is_empty(vars)) {
rlang::abort("`vars` are required and must be variables in `data`.")
cli_abort("{.arg vars} is required and must contain at least one variable in {.arg data}.")
}
vars <- data[vars]

Expand Down
3 changes: 2 additions & 1 deletion R/complement.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ get_stored_out_id <- function(x) {
}

if (all(is.na(out_id))) {
rlang::abort("Cannot derive the assessment set for this type of resampling.")
x_cls <- class(x)
cli_abort("Cannot derive the assessment set for this type of resampling with class{?es}: {.cls {x_cls}}.")
}

out_id
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/clustering.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bad args

`vars` are required and must be variables in `data`.
`vars` is required and must contain at least one variable in `data`.

---

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/rsplit.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@
get_stored_out_id(list(out_id = NA))
Condition
Error in `get_stored_out_id()`:
! Cannot derive the assessment set for this type of resampling.
! Cannot derive the assessment set for this type of resampling with class: <list>.

0 comments on commit 85dcee6

Please sign in to comment.