Skip to content

Commit

Permalink
Merge pull request #549 from tidymodels/checks-bootstrap
Browse files Browse the repository at this point in the history
Update checks for bootstrap resamples
  • Loading branch information
hfrick authored Sep 25, 2024
2 parents bf70b7b + df60777 commit 7b92366
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
4 changes: 2 additions & 2 deletions R/boot.R
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ boot_splits <-

all_assessable <- purrr::map(split_objs, function(x) nrow(assessment(x)))
if (any(all_assessable == 0)) {
rlang::warn(
cli_warn(
"Some assessment sets contained zero rows.",
call = rlang::caller_env()
)
Expand Down Expand Up @@ -276,7 +276,7 @@ group_boot_splits <- function(data, group, times = 25, strata = NULL, pool = 0.1

all_assessable <- purrr::map(split_objs, function(x) nrow(assessment(x)))
if (any(all_assessable == 0)) {
rlang::warn(
cli_warn(
c(
"Some assessment sets contained zero rows.",
i = "Consider using a non-grouped resampling method."
Expand Down
10 changes: 1 addition & 9 deletions R/make_groups.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,7 @@ validate_group <- function(group, data, call = rlang::caller_env()) {
}
}

if (is.null(group) || !is.character(group) || length(group) != 1) {
cli_abort(
"{.arg group} should be a single character value for the column that will be used for splitting.",
call = call
)
}
if (!any(names(data) == group)) {
cli_abort("{.arg group} should be a column in {.arg data}.", call = call)
}
check_string(group, call = call)

group
}
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/mc.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
group_mc_cv(warpbreaks, group = c("tension", "wool"))
Condition
Error in `group_mc_cv()`:
! `group` should be a single character value for the column that will be used for splitting.
! `group` must be a single string, not a character vector.

---

Expand All @@ -68,7 +68,7 @@
group_mc_cv(warpbreaks)
Condition
Error in `group_mc_cv()`:
! `group` should be a single character value for the column that will be used for splitting.
! `group` must be a single string, not `NULL`.

---

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/_snaps/vfold.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
group_vfold_cv(warpbreaks, group = c("tension", "wool"))
Condition
Error in `group_vfold_cv()`:
! `group` should be a single character value for the column that will be used for splitting.
! `group` must be a single string, not a character vector.

---

Expand All @@ -159,7 +159,7 @@
group_vfold_cv(warpbreaks)
Condition
Error in `group_vfold_cv()`:
! `group` should be a single character value for the column that will be used for splitting.
! `group` must be a single string, not `NULL`.

---

Expand Down

0 comments on commit 7b92366

Please sign in to comment.