Error in `checkDisjunct(x, y, fmatch)`: Assertion on 'y' failed. Must be of class 'atomic', not 'NULL'.

# each space unit contains one observation per day
data[, c("x", "y") := list(runif(nrow(data)), runif(nrow(data)))]
data[, (cols) := lapply(.SD, as.factor), .SDcols = cols]
task = as_task_classif_st(data, id = "test", target = "class", coordinate_names = c("x", "y"))
resampling = rsmp("repeated_sptcv_cstf", stratify = FALSE, folds = 3, repeats = 5)
pwalk(list(rep(seq_len(5), each = 3), rep(seq_len(3), 5)), function(rep, fold) {
expect_factor(unique(data[instance[[rep]]$train[[fold]], polygon]), len = 2)
expect_factor(unique(data[instance[[rep]]$test[[fold]], polygon]), len = 1)
expect_double(unique(data[instance[[rep]]$train[[fold]], day]), len = 2)
expect_double(unique(data[instance[[rep]]$test[[fold]], day]), len = 1)
test_that("group by space and time works", {
test_that("stratify on target and group by space works", {
resampling = rsmp("repeated_sptcv_cstf", stratify = TRUE, folds = 3, repeats = 5)
expect_factor(unique(data[instance[[rep]]$train[[fold]], polygon]), len = 6)
expect_factor(unique(data[instance[[rep]]$test[[fold]], polygon]), len = 3)
expect_factor(data[instance[[rep]]$train[[fold]], class], levels = c("A", "B", "C"), empty.levels.ok = FALSE)
expect_factor(data[instance[[rep]]$test[[fold]], class], levels = c("A", "B", "C"), empty.levels.ok = FALSE)
test_that("group by space works with multiple observations within space unit", {
# each space unit contains three observation per day
test_that("group by time works with multiple observations within space unit", {
test_that("group by space and time works with multiple observations within space unit", {
test_that("stratify on target and group by space works with multiple observations within space unit", {
test_that("group by space works with one polygon more than folds", {
expect_factor(unique(data[instance[[rep]]$train[[1]], polygon]), len = 2)
expect_factor(unique(data[instance[[rep]]$test[[1]], polygon]), len = 2)
pwalk(list(rep(seq_len(5), each = 2), rep(2:3, 5)), function(rep, fold) {
expect_factor(unique(data[instance[[rep]]$train[[fold]], polygon]), len = 3)
test_that("group by space errors with one spatial unit less than folds", {
expect_error(resampling$instantiate(task), "The number of folds is higher than the number of spatial units.")
test_that("group by time errors with one temporal unit less than folds", {
expect_error(resampling$instantiate(task), "The number of folds is higher than the number of temporal units.")
expect_error(resampling$instantiate(task), "has no column role")