Skip to content

Commit 78ec60b

Browse files
committed
Attempting to debug errors specific to GitHub Actions in the test for cv_random_schema()
1 parent 4dc7769 commit 78ec60b

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

DESCRIPTION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Suggests:
2727
ggplot2,
2828
MASS,
2929
testthat (>= 3.0.0),
30-
survival
30+
survival,
31+
withr
3132
VignetteBuilder: knitr
3233
Config/testthat/edition: 3
3334
URL: https://ctesta01.github.io/nadir/, https://github.com/ctesta01/nadir/

tests/testthat/test-super_learner_helpers.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ test_that("super_learner_helpers work as intended", {
2323
})
2424

2525
test_that("cv_random_schema produces good splits", {
26+
withr::local_seed(20260105)
2627
# produce synthetic data
2728
df <- data.frame(id = 1:100,
2829
x = sample.int(n = 100, size = 100, replace = FALSE))
@@ -63,12 +64,15 @@ test_that("cv_random_schema produces good splits", {
6364

6465
# the validation data splits should not be far from nrow(df) / n_folds in size
6566
expect_true(
66-
all(validation_data_sizes >= nrow(df) / n_folds - 3) &
67-
all(validation_data_sizes <= nrow(df) / n_folds + 3)
68-
)
67+
all(validation_data_sizes >= nrow(df) / n_folds - 3),
68+
info = paste("validation sizes:", paste(validation_data_sizes, collapse = ", ")))
69+
expect_true(all(validation_data_sizes <= nrow(df) / n_folds + 3),
70+
info = paste("validation sizes:", paste(validation_data_sizes, collapse = ", ")))
6971
# the training data splits should not be far from nrow(df) * (n_folds - 1) / n_folds in size
7072
expect_true(
71-
all(training_data_sizes >= nrow(df) * (n_folds - 1)/ n_folds - 3) &
72-
all(training_data_sizes <= nrow(df) * (n_folds - 1)/ n_folds + 3)
73+
all(training_data_sizes >= nrow(df) * (n_folds - 1)/ n_folds - 3),
74+
info = paste("training sizes:", paste(training_data_sizes, collapse = ", ")))
75+
expect_true(all(training_data_sizes <= nrow(df) * (n_folds - 1)/ n_folds + 3),
76+
info = paste("training sizes:", paste(training_data_sizes, collapse = ", "))
7377
)
7478
})

0 commit comments

Comments
 (0)