diff --git a/NEWS.md b/NEWS.md index 87338a523..edf166176 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,5 @@ # mlr3pipelines 0.5.2-9000 - * Compatibility with new `bbotk` release. * Added marshaling support to `GraphLearner` * Support internal tuning and validation diff --git a/R/pipeline_branch.R b/R/pipeline_branch.R index 8ff61b34d..7637e1529 100644 --- a/R/pipeline_branch.R +++ b/R/pipeline_branch.R @@ -91,9 +91,10 @@ pipeline_branch = function(graphs, prefix_branchops = "", prefix_paths = FALSE) pmap(list( src_id = branch_id, dst_id = gin$op.id, src_channel = branch_chan, dst_channel = gin$channel.name), - graph$add_edge) + graph$add_edge) }) graph } mlr_graphs$add("branch", pipeline_branch) + diff --git a/tests/testthat/test_GraphLearner.R b/tests/testthat/test_GraphLearner.R index 0ce408641..d1e4401a9 100644 --- a/tests/testthat/test_GraphLearner.R +++ b/tests/testthat/test_GraphLearner.R @@ -2,7 +2,7 @@ context("GraphLearner") test_that("basic graphlearner tests", { skip_if_not_installed("rpart") - skip_on_cran() # takes too long + skip_on_cran() # takes too long task = mlr_tasks$get("iris") lrn = mlr_learners$get("classif.rpart") @@ -40,8 +40,8 @@ test_that("basic graphlearner tests", { expect_true(run_experiment(task, glrn)$ok) glrn2$train(task) glrn2_clone$state = glrn2$state - # glrn2_clone$state$log = glrn2_clone$state$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed - # glrn2_clone$state$model$classif.rpart$log = glrn2_clone$state$model$classif.rpart$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed +# glrn2_clone$state$log = glrn2_clone$state$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed +# glrn2_clone$state$model$classif.rpart$log = glrn2_clone$state$model$classif.rpart$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed expect_deep_clone(glrn2_clone, glrn2$clone(deep = TRUE)) expect_prediction_classif({ graphpred2 = glrn2$predict(task) @@ -109,7 +109,7 @@ test_that("GraphLearner clone_graph FALSE", { # check that the GraphLearner predicts what we expect expect_true(isTRUE(all.equal(gl$predict(tsk("iris")), expected_prediction))) - expect_false(gr1$is_trained) # predicting with GraphLearner resets Graph state + expect_false(gr1$is_trained) # predicting with GraphLearner resets Graph state expect_identical(gl$graph, gr1) @@ -177,7 +177,7 @@ test_that("graphlearner parameters behave as they should", { test_that("graphlearner type inference", { skip_if_not_installed("rpart") - skip_on_cran() # takes too long + skip_on_cran() # takes too long # default: classif lrn = GraphLearner$new(mlr_pipeops$get("nop")) expect_equal(lrn$task_type, "classif") @@ -246,15 +246,15 @@ test_that("graphlearner type inference", { test_that("graphlearner type inference - branched", { skip_if_not_installed("rpart") - skip_on_cran() # takes too long + skip_on_cran() # takes too long # default: classif lrn = GraphLearner$new(gunion(list( - mlr_pipeops$get(id = "l1", "learner", lrn("classif.rpart")), - po("nop") %>>% mlr_pipeops$get(id = "l2", "learner", lrn("classif.rpart")) + mlr_pipeops$get(id = "l1", "learner", lrn("classif.rpart")), + po("nop") %>>% mlr_pipeops$get(id = "l2", "learner", lrn("classif.rpart")) - )) %>>% + )) %>>% po("classifavg") %>>% po(id = "n2", "nop")) expect_equal(lrn$task_type, "classif") @@ -281,9 +281,9 @@ test_that("graphlearner type inference - branched", { # inference when multiple input, but one is a Task lrn = GraphLearner$new(gunion(list( - mlr_pipeops$get(id = "l1", "learner", lrn("regr.rpart")), - po("nop") %>>% mlr_pipeops$get(id = "l2", "learner", lrn("regr.rpart")) - )) %>>% + mlr_pipeops$get(id = "l1", "learner", lrn("regr.rpart")), + po("nop") %>>% mlr_pipeops$get(id = "l2", "learner", lrn("regr.rpart")) + )) %>>% po("regravg") %>>% po(id = "n2", "nop")) expect_equal(lrn$task_type, "regr") @@ -311,7 +311,7 @@ test_that("graphlearner type inference - branched", { test_that("graphlearner predict type inference", { skip_if_not_installed("rpart") - skip_on_cran() # takes too long + skip_on_cran() # takes too long # Getter: # Classification @@ -403,9 +403,7 @@ test_that("graphlearner predict type inference", { expect_equal(lrn$graph$pipeops[[lrr$id]]$predict_type, "prob") # Errors: - expect_error({ - lrrp = po(lrn("classif.featureless", predict_type = "se")) - }) + expect_error({lrrp = po(lrn("classif.featureless", predict_type = "se"))}) }) @@ -441,6 +439,7 @@ test_that("GraphLearner model", { expect_equal(lr$graph_model$pipeops$classif.rpart$learner_model$importance(), imp) + }) test_that("predict() function for Graph", { @@ -469,6 +468,7 @@ test_that("predict() function for Graph", { p1$response ) + }) test_that("base_learner() works", { @@ -558,20 +558,20 @@ test_that("GraphLearner hashes", { expect_string(all.equal(po("copy", 2)$hash, po("copy", 3)$hash), "mismatch") - lr1 = lrn("classif.rpart") - lr2 = lrn("classif.rpart", fallback = lrn("classif.rpart")) + lr1 <- lrn("classif.rpart") + lr2 <- lrn("classif.rpart", fallback = lrn("classif.rpart")) expect_string(all.equal(lr1$hash, lr2$hash), "mismatch") expect_string(all.equal(lr1$phash, lr2$phash), "mismatch") - lr1 = as_learner(as_pipeop(lr1)) - lr2 = as_learner(as_pipeop(lr2)) + lr1 <- as_learner(as_pipeop(lr1)) + lr2 <- as_learner(as_pipeop(lr2)) expect_string(all.equal(lr1$hash, lr2$hash), "mismatch") expect_string(all.equal(lr1$phash, lr2$phash), "mismatch") - lr1 = as_learner(as_pipeop(lr1)) - lr2 = as_learner(as_pipeop(lr2)) + lr1 <- as_learner(as_pipeop(lr1)) + lr2 <- as_learner(as_pipeop(lr2)) expect_string(all.equal(lr1$hash, lr2$hash), "mismatch") expect_string(all.equal(lr1$phash, lr2$phash), "mismatch")