Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update checks for bootstrap resamples #549

Merged
merged 4 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading