Skip to content

Commit

Permalink
Make sure R CMD CHECK passes
Browse files Browse the repository at this point in the history
  • Loading branch information
ashbythorpe committed Sep 30, 2023
1 parent ccda3e5 commit 7a5d70c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 31 deletions.
8 changes: 2 additions & 6 deletions R/nested_resamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@
#' `resamples`.
#'
#' @examplesIf rlang::is_installed("workflows")
#'
#'
#' library(tidyr)
#' library(recipes)
#' library(workflows)
#' library(rsample)
#' library(dplyr)
#'
#'
#' nested_data <- example_nested_data %>%
#' nest(data = -id)
#'
Expand All @@ -130,10 +130,6 @@
#' ~ initial_split(.)
#' )
#'
#' nested_resamples(example_nested_data, ~ {
#' rsample::validation_split(.)
#' }, nesting_method = recipe)
#'
#' nested_resamples(example_nested_data, bootstraps,
#' times = 25, nesting_method = wf
#' )
Expand Down
2 changes: 0 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
This update fixes the check results on CRAN.

## R CMD check results

0 errors | 0 warnings | 0 notes
Expand Down
4 changes: 0 additions & 4 deletions man/nested_resamples.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/autoplot/combined-autoplot-results.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 9 additions & 19 deletions tests/testthat/test-nested_resamples.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
test_that("nested_resamples works", {
skip_if_not_installed("withr")
skip_if_not_installed("workflows")

withr::local_seed(42)

expect_error(nested_resamples(NULL), class = "bad_type")

expect_error(nested_resamples(tibble::tibble(x = 1), rsample::vfold_cv(),
Expand All @@ -27,51 +27,41 @@ test_that("nested_resamples works", {
}

sample_data <- data.frame(x = 1:10)

nested_data <- tidyr::nest(example_nested_data, data = -id)

expect_error(nested_resamples(example_nested_data, rsample::vfold_cv()))

nested_resamples(nested_data, rsample::vfold_cv()) %>%
expect_s3_class(class(rsample::vfold_cv(sample_data, 2)))

nested_resamples(
dplyr::group_by(example_nested_data, id),
~ rsample::initial_split(.)
) %>%
expect_s3_class(class(rsample::initial_split(sample_data)))

nested_resamples(example_nested_data, ~ {
rsample::validation_split(.)
}, nesting_method = recipe) %>%
expect_s3_class(class(rsample::validation_split(sample_data)))


nested_resamples(example_nested_data, rsample::bootstraps,
times = 25,
nesting_method = wf
) %>%
expect_s3_class(class(rsample::bootstraps(sample_data, 1)))

nested_resamples(example_nested_data, "validation_split",
nesting_method = recipe
) %>%
expect_s3_class(class(rsample::validation_split(sample_data)))

nested_resamples(dplyr::group_by(example_nested_data, id), diff_lens,
size_action = "recycle-random"
size_action = "recycle-random"
) %>%
expect_s3_class(class(rsample::vfold_cv(sample_data, 2)))

nested_resamples(dplyr::group_by(example_nested_data, id), "diff_lens",
size_action = "combine-random"
size_action = "combine-random"
) %>%
expect_s3_class(class(rsample::vfold_cv(sample_data, 2)))

small_data <- tibble::tibble(
id = c(rep(1, 10), rep(2, 10), rep(3, 10)),
x = 1:30
)

nested_resamples(
tidyr::nest(small_data, data = -"id"),
rsample::nested_cv(
Expand Down

0 comments on commit 7a5d70c

Please sign in to comment.