Skip to content

Commit

Permalink
undo bogus changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Jun 30, 2024
1 parent fb62bbc commit ac09cae
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
1 change: 0 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# mlr3pipelines 0.5.2-9000


* Compatibility with new `bbotk` release.
* Added marshaling support to `GraphLearner`
* Support internal tuning and validation
Expand Down
3 changes: 2 additions & 1 deletion R/pipeline_branch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

44 changes: 22 additions & 22 deletions tests/testthat/test_GraphLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"))})
})


Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -469,6 +468,7 @@ test_that("predict() function for Graph", {
p1$response
)


})

test_that("base_learner() works", {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit ac09cae

Please sign in to comment.