From d127c85b8928f90dcd331bc6dbd7241630546748 Mon Sep 17 00:00:00 2001 From: "Gavin L. Simpson" Date: Mon, 11 Feb 2019 15:49:27 -0600 Subject: [PATCH 1/2] revise the error message for #25 --- R/evaluate_smooth.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/evaluate_smooth.R b/R/evaluate_smooth.R index eb0a90c7c..b100ffdc6 100644 --- a/R/evaluate_smooth.R +++ b/R/evaluate_smooth.R @@ -67,7 +67,7 @@ } smooth_ids <- which_smooth(object, smooth) # which smooths match 'smooth' if (identical(length(smooth_ids), 0L)) { - stop("Request smooth not found in the model <", smooth, ">", call. = FALSE) + stop("Requested smooth '", smooth, "' not found", call. = FALSE) } smooth_labels <- select_smooth(object, smooth) From ac050194d03ae656fb9fb8685b2deaaaaa39ba88 Mon Sep 17 00:00:00 2001 From: "Gavin L. Simpson" Date: Mon, 11 Feb 2019 15:49:45 -0600 Subject: [PATCH 2/2] write a test for #25 --- tests/testthat/test-evaluate-smooth-methods.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testthat/test-evaluate-smooth-methods.R b/tests/testthat/test-evaluate-smooth-methods.R index ad4c07e66..c56563a77 100644 --- a/tests/testthat/test-evaluate-smooth-methods.R +++ b/tests/testthat/test-evaluate-smooth-methods.R @@ -26,6 +26,12 @@ test_that("evaluate_smooth throws a message with more than one term", { "Supplied more than 1 'smooth'; using only the first") }) +test_that("evaluate_smooth throws error if smooth not found", { + expect_error(evaluate_smooth(m1, smooth = "s(z)"), + "Requested smooth 's(z)' not found", + fixed = TRUE) +}) + test_that("evaluate_smooth works for a GAMM", { sm <- evaluate_smooth(m2, "s(x2)") expect_is(sm, "evaluated_1d_smooth")