diff --git a/R/ResamplingSpCVBlock.R b/R/ResamplingSpCVBlock.R index a6d47b77f..3e0d609dc 100644 --- a/R/ResamplingSpCVBlock.R +++ b/R/ResamplingSpCVBlock.R @@ -12,7 +12,7 @@ #' task = tsk("ecuador") #' #' # Instantiate Resampling -#' rcv = rsmp("spcv_block", range = 1000) +#' rcv = rsmp("spcv_block", range = 1000L) #' rcv$instantiate(task) #' #' # Individual sets: diff --git a/R/autoplot.R b/R/autoplot.R index f7f1e1b34..23d946a6e 100644 --- a/R/autoplot.R +++ b/R/autoplot.R @@ -47,7 +47,7 @@ #' library(mlr3) #' library(mlr3spatiotempcv) #' task = tsk("ecuador") -#' resampling = rsmp("spcv_block", range = 1000) +#' resampling = rsmp("spcv_block", range = 1000L) #' resampling$instantiate(task) #' #' ## Visualize all partitions diff --git a/man/ResamplingSpCVBlock.Rd b/man/ResamplingSpCVBlock.Rd index 133c6c746..83442d985 100644 --- a/man/ResamplingSpCVBlock.Rd +++ b/man/ResamplingSpCVBlock.Rd @@ -23,7 +23,7 @@ if (mlr3misc::require_namespaces(c("sf", "blockCV"), quietly = TRUE)) { task = tsk("ecuador") # Instantiate Resampling - rcv = rsmp("spcv_block", range = 1000) + rcv = rsmp("spcv_block", range = 1000L) rcv$instantiate(task) # Individual sets: diff --git a/man/autoplot.ResamplingSpCVBlock.Rd b/man/autoplot.ResamplingSpCVBlock.Rd index a36905b2c..d2690e0cb 100644 --- a/man/autoplot.ResamplingSpCVBlock.Rd +++ b/man/autoplot.ResamplingSpCVBlock.Rd @@ -88,7 +88,7 @@ if (mlr3misc::require_namespaces(c("sf", "blockCV"), quietly = TRUE)) { library(mlr3) library(mlr3spatiotempcv) task = tsk("ecuador") - resampling = rsmp("spcv_block", range = 1000) + resampling = rsmp("spcv_block", range = 1000L) resampling$instantiate(task) ## Visualize all partitions diff --git a/tests/testthat/test-1-autoplot.R b/tests/testthat/test-1-autoplot.R index 147251e29..e829dd259 100644 --- a/tests/testthat/test-1-autoplot.R +++ b/tests/testthat/test-1-autoplot.R @@ -142,7 +142,7 @@ test_that("plot() works for 'repeated_spcv_block'", { set.seed(42) plots = prepare_autoplot("repeated_spcv_block", - folds = 4, range = c(2, 4), repeats = 2) + folds = 4, range = c(2L, 4L), repeats = 2) # autoplot() is used instead of plot() to prevent side-effect plotting p1 = autoplot(plots$rsp, plots$task, crs = 4326) diff --git a/tests/testthat/test-ResamplingRepeatedSpCVBlock.R b/tests/testthat/test-ResamplingRepeatedSpCVBlock.R index 703ac7cbe..b3ee73bf1 100644 --- a/tests/testthat/test-ResamplingRepeatedSpCVBlock.R +++ b/tests/testthat/test-ResamplingRepeatedSpCVBlock.R @@ -1,6 +1,6 @@ test_that("folds can be printed", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2, 4)) + rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2L, 4L)) rsp$instantiate(task) expect_equal(rsp$folds(1:6), c(1, 2, 1, 2, 1, 2)) @@ -8,7 +8,7 @@ test_that("folds can be printed", { test_that("reps can be printed", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2, 4)) + rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2L, 4L)) rsp$instantiate(task) expect_equal(rsp$repeats(1:9), c(1, 1, 1, 2, 2, 2, 3, 3, 3)) @@ -16,7 +16,7 @@ test_that("reps can be printed", { test_that("resampling iterations equals folds * repeats", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2, 4)) + rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2L, 4L)) rsp$instantiate(task) expect_equal(rsp$iters, 6) @@ -32,7 +32,7 @@ test_that("error when neither cols & rows | range is specified", { test_that("error when length(range) != length(repeats)", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", repeats = 2, range = 5) + rsp = rsmp("repeated_spcv_block", repeats = 2, range = 5L) expect_error( rsp$instantiate(task), ".*to be the same length as 'range'." @@ -41,13 +41,13 @@ test_that("error when length(range) != length(repeats)", { test_that("no error when length(range) == repeats", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2, 4)) + rsp = rsmp("repeated_spcv_block", folds = 3, repeats = 2, range = c(2L, 4L)) expect_silent(rsp$instantiate(task)) }) test_that("error when number of desired folds is larger than number possible blocks", { task = test_make_twoclass_task() - rsp = rsmp("repeated_spcv_block", folds = 10, repeats = 2, range = c(2, 4)) + rsp = rsmp("repeated_spcv_block", folds = 10, repeats = 2, range = c(2L, 4L)) expect_error(rsp$instantiate(task)) }) diff --git a/tests/testthat/test-ResamplingSpCVBlock.R b/tests/testthat/test-ResamplingSpCVBlock.R index 99e30ea3a..bd624d62b 100644 --- a/tests/testthat/test-ResamplingSpCVBlock.R +++ b/tests/testthat/test-ResamplingSpCVBlock.R @@ -1,6 +1,6 @@ test_that("resampling iterations equals folds", { task = test_make_twoclass_task() - rsp = rsmp("spcv_block", folds = 2, range = 2) + rsp = rsmp("spcv_block", folds = 2, range = 2L) rsp$instantiate(task) expect_equal(rsp$iters, 2) @@ -8,7 +8,7 @@ test_that("resampling iterations equals folds", { test_that("error when number of desired folds is larger than number possible blocks", { task = test_make_twoclass_task() - rsp = rsmp("spcv_block", folds = 10, range = 4) + rsp = rsmp("spcv_block", folds = 10, range = 4L) expect_error(rsp$instantiate(task)) }) @@ -33,7 +33,7 @@ test_that("error when only one of rows or cols is set", { }) test_that("Error when length(range) >= 2", { - expect_error(rsmp("spcv_block", range = c(500, 1000))) + expect_error(rsmp("spcv_block", range = c(500L, 1000L))) }) @@ -44,7 +44,7 @@ test_that("mlr3spatiotempcv indices are the same as blockCV indices: selection = task = test_make_blockCV_test_task() rsmp <- rsmp("spcv_block", - range = 50000, + range = 50000L, selection = "checkerboard") rsmp$instantiate(task) @@ -53,7 +53,7 @@ test_that("mlr3spatiotempcv indices are the same as blockCV indices: selection = capture.output(testBlock <- suppressMessages( suppressWarnings(blockCV::spatialBlock( speciesData = testSF, - theRange = 50000, + theRange = 50000L, selection = "checkerboard", showBlocks = FALSE) ))) @@ -98,7 +98,7 @@ test_that("mlr3spatiotempcv indices are the same as blockCV indices: rasterLayer r[] <- 10 rsmp <- rsmp("spcv_block", - range = 50000, + range = 50000L, selection = "checkerboard", rasterLayer = r) rsmp$instantiate(task) @@ -108,7 +108,7 @@ test_that("mlr3spatiotempcv indices are the same as blockCV indices: rasterLayer capture.output(testBlock <- suppressMessages( blockCV::spatialBlock( speciesData = testSF, - theRange = 50000, + theRange = 50000L, selection = "checkerboard", rasterLayer = r, showBlocks = FALSE,