From b10db700146b5f6603871eb1e27211732d693a83 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Mon, 23 Sep 2024 18:53:05 +0100 Subject: [PATCH 1/4] switch to cli --- R/boot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boot.R b/R/boot.R index 13cff66b..2fe31ce9 100644 --- a/R/boot.R +++ b/R/boot.R @@ -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() ) From 78689c64b049a2daa27f140e9b34b3227297156e Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Mon, 23 Sep 2024 18:53:38 +0100 Subject: [PATCH 2/4] covered by tidyselect --- R/make_groups.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/R/make_groups.R b/R/make_groups.R index 6f7d7050..0ac41636 100644 --- a/R/make_groups.R +++ b/R/make_groups.R @@ -350,9 +350,6 @@ validate_group <- function(group, data, call = rlang::caller_env()) { call = call ) } - if (!any(names(data) == group)) { - cli_abort("{.arg group} should be a column in {.arg data}.", call = call) - } group } From fe45b7fa9af39a56abfe83f4851822e9ac0437ef Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Wed, 25 Sep 2024 10:30:05 +0100 Subject: [PATCH 3/4] switch to standard check function --- R/make_groups.R | 7 +------ tests/testthat/_snaps/mc.md | 4 ++-- tests/testthat/_snaps/vfold.md | 4 ++-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/R/make_groups.R b/R/make_groups.R index 0ac41636..12635172 100644 --- a/R/make_groups.R +++ b/R/make_groups.R @@ -344,12 +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 - ) - } + check_string(group, call = call) group } diff --git a/tests/testthat/_snaps/mc.md b/tests/testthat/_snaps/mc.md index f7ab64cf..1fbc3899 100644 --- a/tests/testthat/_snaps/mc.md +++ b/tests/testthat/_snaps/mc.md @@ -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. --- @@ -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`. --- diff --git a/tests/testthat/_snaps/vfold.md b/tests/testthat/_snaps/vfold.md index 63664707..07bf38b2 100644 --- a/tests/testthat/_snaps/vfold.md +++ b/tests/testthat/_snaps/vfold.md @@ -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. --- @@ -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`. --- From df6077792b470185798bf88d3f883dd4e97b497a Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Wed, 25 Sep 2024 10:47:10 +0100 Subject: [PATCH 4/4] switch to cli --- R/boot.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/boot.R b/R/boot.R index 2fe31ce9..317cd501 100644 --- a/R/boot.R +++ b/R/boot.R @@ -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."