Skip to content

Commit

Permalink
tests: make the strata check optional for resampling helper (#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-muecke authored Jan 24, 2025
1 parent 58b3859 commit b2de8f4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions inst/testthat/helper_expectations.R
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ expect_marshalable_learner = function(learner, task) {
testthat::expect_equal(class(learner$model), class_prev)
}

expect_resampling = function(r, task = NULL) {
expect_resampling = function(r, task = NULL, strata = TRUE) {
checkmate::expect_r6(r, "Resampling")
testthat::expect_output(print(r), "Resampling")
expect_id(r$id)
Expand Down Expand Up @@ -487,7 +487,7 @@ expect_resampling = function(r, task = NULL) {
}
if (!is.null(task)) {
checkmate::expect_subset(train, ids)
checkmate::expect_subset(train, ids)
checkmate::expect_subset(test, ids)
}
}
}
Expand All @@ -502,11 +502,13 @@ expect_resampling = function(r, task = NULL) {
checkmate::expect_subset(r$test_set(1), task$row_ids)

# again with strata
task = task$clone()
task$col_roles$stratum = task$target_names
r$instantiate(task)
checkmate::expect_subset(r$train_set(1), task$row_ids)
checkmate::expect_subset(r$test_set(1), task$row_ids)
if (strata) {
task = task$clone()
task$col_roles$stratum = task$target_names
r$instantiate(task)
checkmate::expect_subset(r$train_set(1), task$row_ids)
checkmate::expect_subset(r$test_set(1), task$row_ids)
}
}
}

Expand Down

0 comments on commit b2de8f4

Please sign in to comment.