Skip to content

Commit

Permalink
tests: remove loading of mlr3pipelines (#471)
Browse files Browse the repository at this point in the history
* ...

* ...
  • Loading branch information
be-marc authored Nov 25, 2024
1 parent b21a0ad commit 541c478
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 15 deletions.
8 changes: 4 additions & 4 deletions inst/testthat/helper_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,13 @@ LearnerRegrDepParams = R6Class("LearnerRegrDepParams", inherit = LearnerRegr,
)

MAKE_GL = function() {
g = Graph$new()
op_ds = PipeOpSubsample$new()
op_lrn = PipeOpLearner$new(lrn("classif.rpart"))
g = mlr3pipelines::Graph$new()
op_ds = mlr3pipelines::PipeOpSubsample$new()
op_lrn = mlr3pipelines::PipeOpLearner$new(lrn("classif.rpart"))
g$add_pipeop(op_ds)
g$add_pipeop(op_lrn)
g$add_edge("subsample", "classif.rpart")
GraphLearner$new(g)
mlr3pipelines::GraphLearner$new(g)
}

flush_redis = function() {
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/helper.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
library(mlr3)
library(checkmate)
library(mlr3misc)
library(mlr3pipelines)
library(paradox)
library(R6)

Expand Down
6 changes: 2 additions & 4 deletions tests/testthat/test_AutoTuner.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ test_that("AT training does not change learner in instance args", {
test_that("AutoTuner works with graphlearner", {
skip_if_not_installed("mlr3pipelines")
skip_if(packageVersion("mlr3pipelines") < "0.5.3")
requireNamespace("mlr3pipelines")

gl = MAKE_GL()
task = tsk("iris")
Expand Down Expand Up @@ -134,7 +133,6 @@ test_that("AutoTuner works with graphlearner", {

test_that("Nested resampling works with graphlearner", {
skip_if_not_installed("mlr3pipelines", "0.5.3")
requireNamespace("mlr3pipelines")

gl = MAKE_GL()
task = tsk("iris")
Expand Down Expand Up @@ -275,7 +273,7 @@ test_that("search space from TuneToken works", {

test_that("AutoTuner get_base_learner method works", {
skip_if_not_installed("mlr3pipelines", "0.5.3")
requireNamespace("mlr3pipelines")
`%>>%` = mlr3pipelines::`%>>%`

# simple learner
learner = lrn("classif.rpart", cp = to_tune(1e-04, 1e-1, logscale = TRUE))
Expand All @@ -293,7 +291,7 @@ test_that("AutoTuner get_base_learner method works", {
expect_equal(at$base_learner(recursive = 0)$id, "classif.rpart")

# graph learner
learner = as_learner(pipeline_robustify() %>>% lrn("classif.rpart"))
learner = as_learner(mlr3pipelines::pipeline_robustify() %>>% lrn("classif.rpart"))
learner$param_set$values$classif.rpart.cp = to_tune(1e-04, 1e-1, logscale = TRUE)
learner$id = "graphlearner.classif.rpart"

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_Tuner.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ test_that("print method workds", {

test_that("Tuner works with graphlearner", {
skip_if_not_installed("mlr3pipelines")
requireNamespace("mlr3pipelines")

gl = MAKE_GL()
task = tsk("iris")
Expand Down Expand Up @@ -410,6 +409,7 @@ test_that("tag internal tune token manually in primary search space", {

test_that("Can only pass internal tune tokens one way", {
skip_if_not_installed("mlr3pipelines")

l1 = lrn("classif.debug", early_stopping = TRUE)
l1$id = "l1"
l2 = l1$clone()
Expand All @@ -418,7 +418,7 @@ test_that("Can only pass internal tune tokens one way", {
l1$param_set$set_values(
iter = to_tune(upper = 100, internal = TRUE)
)
l = ppl("branch", list(l1 = l1, l2 = l2))
l = mlr3pipelines::ppl("branch", list(l1 = l1, l2 = l2))
l = as_learner(l)
set_validate(l, 0.2, ids = c("l1", "l2"))

Expand Down
5 changes: 1 addition & 4 deletions tests/testthat/test_TuningInstanceBatchSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ test_that("tuning with custom resampling", {

test_that("non-scalar hyperpars (#201)", {
skip_if_not_installed("mlr3pipelines")

requireNamespace("mlr3pipelines")
`%>>%` = getFromNamespace("%>>%", asNamespace("mlr3pipelines"))

`%>>%` = mlr3pipelines::`%>>%`

learner = mlr3pipelines::po("select") %>>% lrn("classif.rpart")

Expand Down

0 comments on commit 541c478

Please sign in to comment.