From 47cacf7064450a7e545823a0ca6bc06415cfd7bc Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Wed, 29 Jan 2025 11:27:45 -0800 Subject: [PATCH] fix abort call and add test for wrong activation --- R/mlp.R | 3 ++- tests/testthat/test-mlp_keras.R | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/R/mlp.R b/R/mlp.R index ee40edbd9..d04bca2ef 100644 --- a/R/mlp.R +++ b/R/mlp.R @@ -196,7 +196,8 @@ keras_mlp <- good_activation <- activation %in% allowed_keras_activation if (!all(good_activation)) { cli::cli_abort( - "{.arg activation} should be one of: {allowed_activation}." + "{.arg activation} should be one of: {allowed_keras_activation}, not + {.val {activation}}." ) } diff --git a/tests/testthat/test-mlp_keras.R b/tests/testthat/test-mlp_keras.R index 640ac2098..8581a2530 100644 --- a/tests/testthat/test-mlp_keras.R +++ b/tests/testthat/test-mlp_keras.R @@ -275,4 +275,11 @@ test_that('all keras activation functions', { keras::backend()$clear_session() } + expect_snapshot( + error = TRUE, + mlp(mode = "classification", hidden_units = 2, penalty = 0.01, epochs = 2, + activation = "invalid") %>% + set_engine("keras", verbose = 0) %>% + parsnip::fit(Class ~ A + B, data = modeldata::two_class_dat) + ) })