Skip to content

Commit

Permalink
Merge pull request #528 from PriKalra/add-changes-and-run-snapshot-te…
Browse files Browse the repository at this point in the history
…st-labels#507

changes for labels.R with cli_abort
  • Loading branch information
hfrick authored Sep 9, 2024
2 parents d325001 + 5e01698 commit 9fe256c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 1 addition & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* 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). With contributions from @PriKalra (#526) and @JamesHWade (#518).
* Started moving error messages to cli (#499, #502). With contributions from @PriKalra (#523, #526, #528) and @JamesHWade (#518).

* Fixed example for `nested_cv()` (@seb09, #520).

Expand All @@ -18,8 +18,6 @@

* `vfold_cv()` and `clustering_cv()` now error on implicit leave-one-out cross-validation (@seb09, #527).

* Error improvements via cli by @PriKalra (#523).

## Bug fixes

* `vfold_cv()` now utilizes the `breaks` argument correctly for repeated cross-validation (@ZWael, #471).
Expand Down
12 changes: 6 additions & 6 deletions R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' labels(vfold_cv(mtcars))
labels.rset <- function(object, make_factor = FALSE, ...) {
if (inherits(object, "nested_cv")) {
rlang::abort("`labels` not implemented for nested resampling")
cli_abort("{.arg labels} not implemented for nested resampling")
}
if (make_factor) {
as.factor(object$id)
Expand All @@ -26,7 +26,7 @@ labels.rset <- function(object, make_factor = FALSE, ...) {
#' @export
labels.vfold_cv <- function(object, make_factor = FALSE, ...) {
if (inherits(object, "nested_cv")) {
rlang::abort("`labels` not implemented for nested resampling")
cli_abort("{.arg labels} not implemented for nested resampling")
}
is_repeated <- attr(object, "repeats") > 1
if (is_repeated) {
Expand Down Expand Up @@ -91,18 +91,18 @@ labels.rsplit <- function(object, ...) {
#' @export
add_resample_id <- function(.data, split, dots = FALSE) {
if (!inherits(dots, "logical") || length(dots) > 1) {
rlang::abort("`dots` should be a single logical.")
cli_abort("{.arg dots} should be a single logical.")
}
if (!inherits(.data, "data.frame")) {
rlang::abort("`.data` should be a data frame.")
cli_abort("{.arg .data} should be a data frame.")
}
if (!inherits(split, "rsplit")) {
rlang::abort("`split` should be a single 'rset' object.")
cli_abort("{.arg split} should be a single {.cls rset} object.")
}
labs <- labels(split)

if (!tibble::is_tibble(labs) && nrow(labs) == 1) {
rlang::abort("`split` should be a single 'rset' object.")
cli_abort("{.arg split} should be a single {.cls rset} object.")
}

if (dots) {
Expand Down

0 comments on commit 9fe256c

Please sign in to comment.