From 0facc13cfcc4726e5f248d73e04dff6cefe5d6eb Mon Sep 17 00:00:00 2001 From: Max Kuhn Date: Mon, 1 Feb 2021 08:52:51 -0500 Subject: [PATCH] rsplit obj_sum changes for r-lib/pillar#240 as well as #214 --- NEWS.md | 1 + R/rsplit.R | 2 +- tests/testthat/print_test_output/obj_sum | 8 ++++++++ tests/testthat/test_rsplit.R | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/testthat/print_test_output/obj_sum diff --git a/NEWS.md b/NEWS.md index 3ec2ae03..6025640c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,7 @@ * A few internal functions were exported so that `rsample`-adjacent packages can use the same underlying code. +* The `obj_sum()` method for `rsplit` objects was updated. # rsample 0.0.8 diff --git a/R/rsplit.R b/R/rsplit.R index 094a6199..7f12a1ac 100644 --- a/R/rsplit.R +++ b/R/rsplit.R @@ -139,7 +139,7 @@ obj_sum.rsplit <- function(x, ...) { else paste(length(x$out_id)) - paste0("rsplit [", + paste0("split [", length(x$in_id), "/", out_char, "]") } diff --git a/tests/testthat/print_test_output/obj_sum b/tests/testthat/print_test_output/obj_sum new file mode 100644 index 00000000..9137ef8e --- /dev/null +++ b/tests/testthat/print_test_output/obj_sum @@ -0,0 +1,8 @@ +> set.seed(233) +> print(validation_split(mtcars)) +# Validation Set Split (0.75/0.25) +# A tibble: 1 x 2 + splits id + +1 validation + diff --git a/tests/testthat/test_rsplit.R b/tests/testthat/test_rsplit.R index 8df16d58..1f220902 100644 --- a/tests/testthat/test_rsplit.R +++ b/tests/testthat/test_rsplit.R @@ -51,6 +51,10 @@ test_that('print methods', { set.seed(233) print(validation_split(mtcars)$splits[[1]]) }) + verify_output(test_path("print_test_output", "obj_sum"), { + set.seed(233) + print(validation_split(mtcars)) + }) })