Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: remove loading of mlr3pipelines #471

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
`%>>%` = getFromNamespace("%>>%", asNamespace("mlr3pipelines"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this make it look like %>>% is private, but it's exported:

https://github.com/mlr-org/mlr3pipelines/blob/9d4cced9b7b887db6c80c4fafd861398f727cf29/NAMESPACE#L84

(asNamespace() gives all objects in the package, including those not exported in NAMESPACE)

I would just use:

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

(same for elsewhere that I see)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's better. Thanks


# 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
3 changes: 0 additions & 3 deletions tests/testthat/test_TuningInstanceBatchSingleCrit.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,8 @@ test_that("tuning with custom resampling", {

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

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


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

search_space = ps(
Expand Down
Loading