From f5d4f8b3ba8a19349d8110e5c187ab9c89f12000 Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Sun, 18 Aug 2024 14:29:23 +0200 Subject: [PATCH 1/2] fix: divide will be deprecated in next mlr3 release --- inst/testthat/helper_functions.R | 3 ++- tests/testthat/test_pipeop_impute.R | 4 +++- tests/testthat/test_pipeop_learner.R | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inst/testthat/helper_functions.R b/inst/testthat/helper_functions.R index 7285e74c6..b7a33e5c3 100644 --- a/inst/testthat/helper_functions.R +++ b/inst/testthat/helper_functions.R @@ -445,7 +445,8 @@ expect_datapreproc_pipeop_class = function(poclass, constargs = list(), task, expect_true(task$nrow >= 5) # overlap between use and test rows - tasktrain$divide(ids = tasktrain$row_roles$use[seq(n_use - 2, n_use)], remove = FALSE) + taskvalid = tasktrain$clone(deep = TRUE)$filter(tasktrain$row_roles$use[seq(n_use - 2, n_use)]) + tasktrain$row_roles$use = tasktrain$row_roles$use[seq(1, n_use - 2)] taskpredict = tasktrain$clone(deep = TRUE) diff --git a/tests/testthat/test_pipeop_impute.R b/tests/testthat/test_pipeop_impute.R index 75536e3c3..3eeaf35d6 100644 --- a/tests/testthat/test_pipeop_impute.R +++ b/tests/testthat/test_pipeop_impute.R @@ -407,7 +407,9 @@ test_that("More tests for Integers", { test_that("impute, test rows and affect_columns", { po_impute = po("imputeconstant", affect_columns = selector_name("insulin"), constant = 2) task = tsk("pima") - task$divide(ids = 1:30) + ids = 1:30 + task$internal_valid_task = task$clone(deep = TRUE)$filter(ids) + task$row_roles$use = setdiff(task$row_roles$use, 1:30) outtrain = po_impute$train(list(task))[[1L]] outpredict = po_impute$predict(list(task$internal_valid_task))[[1L]] expect_true(isTRUE(all.equal(outtrain$internal_valid_task$data(), outpredict$data()))) diff --git a/tests/testthat/test_pipeop_learner.R b/tests/testthat/test_pipeop_learner.R index 41fb3c4b4..8191e5d5d 100644 --- a/tests/testthat/test_pipeop_learner.R +++ b/tests/testthat/test_pipeop_learner.R @@ -201,7 +201,10 @@ test_that("validation", { }) test_that("internal_tuned_values, internal_valid_scores", { - task = tsk("iris")$divide(0.2) + task = tsk("iris") + ids = partition(task) + task$internal_valid_task = task$clone(deep = TRUE)$filter(ids$test) + task$row_roles$use = ids$train obj = as_pipeop(lrn("classif.debug", validate = "predefined", early_stopping = TRUE, iter = 100)) obj$train(list(task)) expect_int(obj$internal_tuned_values$iter) From 57cd496d336bebde4c694d1c82d8ab0c5e6684a2 Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Sun, 18 Aug 2024 15:23:05 +0200 Subject: [PATCH 2/2] ... --- inst/testthat/helper_functions.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/testthat/helper_functions.R b/inst/testthat/helper_functions.R index b7a33e5c3..f05d640fe 100644 --- a/inst/testthat/helper_functions.R +++ b/inst/testthat/helper_functions.R @@ -445,7 +445,7 @@ expect_datapreproc_pipeop_class = function(poclass, constargs = list(), task, expect_true(task$nrow >= 5) # overlap between use and test rows - taskvalid = tasktrain$clone(deep = TRUE)$filter(tasktrain$row_roles$use[seq(n_use - 2, n_use)]) + tasktrain$internal_valid_task = tasktrain$clone(deep = TRUE)$filter(tasktrain$row_roles$use[seq(n_use - 2, n_use)]) tasktrain$row_roles$use = tasktrain$row_roles$use[seq(1, n_use - 2)]