@@ -2,7 +2,7 @@ context("GraphLearner")
22
33test_that(" basic graphlearner tests" , {
44 skip_if_not_installed(" rpart" )
5- skip_on_cran() # takes too long
5+ skip_on_cran() # takes too long
66 task = mlr_tasks $ get(" iris" )
77
88 lrn = mlr_learners $ get(" classif.rpart" )
@@ -40,8 +40,8 @@ test_that("basic graphlearner tests", {
4040 expect_true(run_experiment(task , glrn )$ ok )
4141 glrn2 $ train(task )
4242 glrn2_clone $ state = glrn2 $ state
43- # glrn2_clone$state$log = glrn2_clone$state$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed
44- # 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
43+ # glrn2_clone$state$log = glrn2_clone$state$log$clone(deep = TRUE) # FIXME: this can go when mlr-org/mlr3#343 is fixed
44+ # 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
4545 expect_deep_clone(glrn2_clone , glrn2 $ clone(deep = TRUE ))
4646 expect_prediction_classif({
4747 graphpred2 = glrn2 $ predict(task )
@@ -109,7 +109,7 @@ test_that("GraphLearner clone_graph FALSE", {
109109 # check that the GraphLearner predicts what we expect
110110 expect_true(isTRUE(all.equal(gl $ predict(tsk(" iris" )), expected_prediction )))
111111
112- expect_false(gr1 $ is_trained ) # predicting with GraphLearner resets Graph state
112+ expect_false(gr1 $ is_trained ) # predicting with GraphLearner resets Graph state
113113
114114 expect_identical(gl $ graph , gr1 )
115115
@@ -177,7 +177,7 @@ test_that("graphlearner parameters behave as they should", {
177177
178178test_that(" graphlearner type inference" , {
179179 skip_if_not_installed(" rpart" )
180- skip_on_cran() # takes too long
180+ skip_on_cran() # takes too long
181181 # default: classif
182182 lrn = GraphLearner $ new(mlr_pipeops $ get(" nop" ))
183183 expect_equal(lrn $ task_type , " classif" )
@@ -246,15 +246,15 @@ test_that("graphlearner type inference", {
246246
247247test_that(" graphlearner type inference - branched" , {
248248 skip_if_not_installed(" rpart" )
249- skip_on_cran() # takes too long
249+ skip_on_cran() # takes too long
250250
251251 # default: classif
252252
253253 lrn = GraphLearner $ new(gunion(list (
254- mlr_pipeops $ get(id = " l1" , " learner" , lrn(" classif.rpart" )),
255- po(" nop" ) %>> % mlr_pipeops $ get(id = " l2" , " learner" , lrn(" classif.rpart" ))
254+ mlr_pipeops $ get(id = " l1" , " learner" , lrn(" classif.rpart" )),
255+ po(" nop" ) %>> % mlr_pipeops $ get(id = " l2" , " learner" , lrn(" classif.rpart" ))
256256
257- )) %>> %
257+ )) %>> %
258258 po(" classifavg" ) %>> %
259259 po(id = " n2" , " nop" ))
260260 expect_equal(lrn $ task_type , " classif" )
@@ -281,9 +281,9 @@ test_that("graphlearner type inference - branched", {
281281
282282 # inference when multiple input, but one is a Task
283283 lrn = GraphLearner $ new(gunion(list (
284- mlr_pipeops $ get(id = " l1" , " learner" , lrn(" regr.rpart" )),
285- po(" nop" ) %>> % mlr_pipeops $ get(id = " l2" , " learner" , lrn(" regr.rpart" ))
286- )) %>> %
284+ mlr_pipeops $ get(id = " l1" , " learner" , lrn(" regr.rpart" )),
285+ po(" nop" ) %>> % mlr_pipeops $ get(id = " l2" , " learner" , lrn(" regr.rpart" ))
286+ )) %>> %
287287 po(" regravg" ) %>> %
288288 po(id = " n2" , " nop" ))
289289 expect_equal(lrn $ task_type , " regr" )
@@ -311,7 +311,7 @@ test_that("graphlearner type inference - branched", {
311311
312312test_that(" graphlearner predict type inference" , {
313313 skip_if_not_installed(" rpart" )
314- skip_on_cran() # takes too long
314+ skip_on_cran() # takes too long
315315 # Getter:
316316
317317 # Classification
@@ -403,9 +403,7 @@ test_that("graphlearner predict type inference", {
403403 expect_equal(lrn $ graph $ pipeops [[lrr $ id ]]$ predict_type , " prob" )
404404
405405 # Errors:
406- expect_error({
407- lrrp = po(lrn(" classif.featureless" , predict_type = " se" ))
408- })
406+ expect_error({lrrp = po(lrn(" classif.featureless" , predict_type = " se" ))})
409407})
410408
411409
@@ -441,6 +439,7 @@ test_that("GraphLearner model", {
441439
442440 expect_equal(lr $ graph_model $ pipeops $ classif.rpart $ learner_model $ importance(), imp )
443441
442+
444443})
445444
446445test_that(" predict() function for Graph" , {
@@ -469,6 +468,7 @@ test_that("predict() function for Graph", {
469468 p1 $ response
470469 )
471470
471+
472472})
473473
474474test_that(" base_learner() works" , {
@@ -558,20 +558,20 @@ test_that("GraphLearner hashes", {
558558 expect_string(all.equal(po(" copy" , 2 )$ hash , po(" copy" , 3 )$ hash ), " mismatch" )
559559
560560
561- lr1 = lrn(" classif.rpart" )
562- lr2 = lrn(" classif.rpart" , fallback = lrn(" classif.rpart" ))
561+ lr1 <- lrn(" classif.rpart" )
562+ lr2 <- lrn(" classif.rpart" , fallback = lrn(" classif.rpart" ))
563563
564564 expect_string(all.equal(lr1 $ hash , lr2 $ hash ), " mismatch" )
565565 expect_string(all.equal(lr1 $ phash , lr2 $ phash ), " mismatch" )
566566
567- lr1 = as_learner(as_pipeop(lr1 ))
568- lr2 = as_learner(as_pipeop(lr2 ))
567+ lr1 <- as_learner(as_pipeop(lr1 ))
568+ lr2 <- as_learner(as_pipeop(lr2 ))
569569
570570 expect_string(all.equal(lr1 $ hash , lr2 $ hash ), " mismatch" )
571571 expect_string(all.equal(lr1 $ phash , lr2 $ phash ), " mismatch" )
572572
573- lr1 = as_learner(as_pipeop(lr1 ))
574- lr2 = as_learner(as_pipeop(lr2 ))
573+ lr1 <- as_learner(as_pipeop(lr1 ))
574+ lr2 <- as_learner(as_pipeop(lr2 ))
575575
576576 expect_string(all.equal(lr1 $ hash , lr2 $ hash ), " mismatch" )
577577 expect_string(all.equal(lr1 $ phash , lr2 $ phash ), " mismatch" )
0 commit comments