Skip to content
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
2 changes: 1 addition & 1 deletion R/bootci.R
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ t_single <- function(stats, std_err, is_orig, alpha = 0.05) {
"{.arg is_orig} should be a logical column the same length as {.arg stats} with no missing values."
)
}
if (length(stats) != length(std_err) && length(stats) != length(is_orig)) {
if (length(stats) != length(std_err) || length(stats) != length(is_orig)) {
function_args <- c('stats', 'std_err', 'is_orig')
cli_abort("{.arg {function_args}} should have the same length.")
}
Expand Down
2 changes: 1 addition & 1 deletion man/bootstraps.Rd

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

2 changes: 1 addition & 1 deletion man/clustering_cv.Rd

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

2 changes: 1 addition & 1 deletion man/group_bootstraps.Rd

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

2 changes: 1 addition & 1 deletion man/group_mc_cv.Rd

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

2 changes: 1 addition & 1 deletion man/group_vfold_cv.Rd

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

2 changes: 1 addition & 1 deletion man/initial_split.Rd

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

2 changes: 1 addition & 1 deletion man/initial_validation_split.Rd

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

2 changes: 1 addition & 1 deletion man/int_pctl.Rd

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

2 changes: 1 addition & 1 deletion man/mc_cv.Rd

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

2 changes: 1 addition & 1 deletion man/reg_intervals.Rd

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

2 changes: 1 addition & 1 deletion man/rolling_origin.Rd

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

2 changes: 1 addition & 1 deletion man/rsample-package.Rd

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

2 changes: 1 addition & 1 deletion man/slide-resampling.Rd

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

2 changes: 1 addition & 1 deletion man/tidy.rsplit.Rd

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

2 changes: 1 addition & 1 deletion man/validation_split.Rd

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

2 changes: 1 addition & 1 deletion man/vfold_cv.Rd

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

24 changes: 24 additions & 0 deletions tests/testthat/_snaps/bootci.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,30 @@
Error in `int_pctl()`:
! All statistics must be numeric.

# t_single() errors when stats, std_err, and is_orig lengths mismatch

Code
rsample:::t_single(stats, std_err[-1], is_orig)
Condition
Error in `rsample:::t_single()`:
! `stats`, `std_err`, and `is_orig` should have the same length.

---

Code
rsample:::t_single(stats, std_err, is_orig[-1])
Condition
Error in `rsample:::t_single()`:
! `stats`, `std_err`, and `is_orig` should have the same length.

---

Code
rsample:::t_single(stats, std_err[-1], is_orig[-1])
Condition
Error in `rsample:::t_single()`:
! `stats`, `std_err`, and `is_orig` should have the same length.

# checks for apparent bootstrap

Code
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-bootci.R
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,26 @@ test_that("bad input", {
})
})

test_that("t_single() errors when stats, std_err, and is_orig lengths mismatch", {
stats <- rnorm(10)
std_err <- rep(1, 10)
is_orig <- c(TRUE, rep(FALSE, 9))

expect_no_error(rsample:::t_single(stats, std_err, is_orig))

expect_snapshot(error = TRUE, {
rsample:::t_single(stats, std_err[-1], is_orig)
})

expect_snapshot(error = TRUE, {
rsample:::t_single(stats, std_err, is_orig[-1])
})

expect_snapshot(error = TRUE, {
rsample:::t_single(stats, std_err[-1], is_orig[-1])
})
})

test_that("checks for apparent bootstrap", {
rs_boot <- bootstraps(mtcars, times = 10, apparent = FALSE)
expect_snapshot(error = TRUE, {
Expand Down
Loading