From 702e21f36a7f3d1434927e36abd8c4cea526881f Mon Sep 17 00:00:00 2001 From: Sebastian Fischer Date: Wed, 24 Apr 2024 16:08:03 +0200 Subject: [PATCH] marshaled returns false if no model is stored (#1019) --- R/marshal.R | 2 +- inst/testthat/helper_expectations.R | 2 +- tests/testthat/test_marshal.R | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/marshal.R b/R/marshal.R index e83f16b0a..bea5fd8af 100644 --- a/R/marshal.R +++ b/R/marshal.R @@ -81,7 +81,7 @@ learner_marshal = function(.learner, ...) { learner_marshaled = function(.learner) { # no need to check for 'marshal' property as this method should only be available for such learners if (is.null(.learner$model)) { - stopf("Cannot check marshaled status, Learner '%s' has not been trained yet", .learner$id) + return(FALSE) } is_marshaled_model(model = .learner$model) } diff --git a/inst/testthat/helper_expectations.R b/inst/testthat/helper_expectations.R index 57b603253..6e273126f 100644 --- a/inst/testthat/helper_expectations.R +++ b/inst/testthat/helper_expectations.R @@ -413,7 +413,7 @@ expect_marshalable_learner = function(learner, task) { # (un)marshal only possible after training testthat::expect_error(learner$marshal(), "has not been trained") testthat::expect_error(learner$unmarshal(), "has not been trained") - testthat::expect_error(learner$marshaled, "has not been trained") + testthat::expect_equal(learner$marshaled, FALSE) learner$train(task) model = learner$model diff --git a/tests/testthat/test_marshal.R b/tests/testthat/test_marshal.R index 5a6f865e5..b0943f5a5 100644 --- a/tests/testthat/test_marshal.R +++ b/tests/testthat/test_marshal.R @@ -3,7 +3,7 @@ test_that("learner methods", { task = tsk("iris") expect_error(learner_marshal(learner), "not been trained") expect_error(learner_unmarshal(learner), "not been trained") - expect_error(learner_marshaled(learner), "not been trained") + expect_false(learner_marshaled(learner)) learner$train(task) expect_false(learner_marshaled(learner))