Skip to content

Commit

Permalink
Merge pull request #807 from mlr-org/remove-divide
Browse files Browse the repository at this point in the history
fix: divide will be deprecated in next mlr3 release
  • Loading branch information
mb706 authored Aug 19, 2024
2 parents 05ea2af + 57cd496 commit 76a086a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion inst/testthat/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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)]

taskpredict = tasktrain$clone(deep = TRUE)
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test_pipeop_impute.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
Expand Down
5 changes: 4 additions & 1 deletion tests/testthat/test_pipeop_learner.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 76a086a

Please sign in to comment.