From 3f50fbea1a8f3d0ab428c8801ddb84deb6a2dad7 Mon Sep 17 00:00:00 2001 From: Sean Anderson Date: Tue, 26 Mar 2024 14:51:40 -0700 Subject: [PATCH] Reduce messages with visreg, move up in tests --- R/residuals.R | 18 ++++++++++-------- .../{test-7-visreg.R => test-1-visreg.R} | 0 2 files changed, 10 insertions(+), 8 deletions(-) rename tests/testthat/{test-7-visreg.R => test-1-visreg.R} (100%) diff --git a/R/residuals.R b/R/residuals.R index 61424679c..5c638fdda 100644 --- a/R/residuals.R +++ b/R/residuals.R @@ -301,15 +301,17 @@ residuals.sdmTMB <- function(object, ...) { type_was_missing <- missing(type) type <- match.arg(type[[1]], choices = c("mle-mvn", "mle-laplace", "mle-eb", "mle-mcmc", "response", "pearson")) - if (type_was_missing || type == "mle-laplace") { - msg <- paste0("Note what used to be the default sdmTMB residuals ", - "(before version 0.4.3.9005) are now `type = 'mle-eb'`. We recommend using ", - "the current default `'mle-mvn'`, which takes one sample from the approximate ", - "posterior of the random effects or `dharma_residuals()` using a similar ", - "approach.") - cli_inform(msg) - if (type == "mle-laplace") type <- "mle-eb" + if (!"visreg_model" %in% names(object)) { + if (type_was_missing || type == "mle-laplace") { + msg <- paste0("Note what used to be the default sdmTMB residuals ", + "(before version 0.4.3.9005) are now `type = 'mle-eb'`. We recommend using ", + "the current default `'mle-mvn'`, which takes one sample from the approximate ", + "posterior of the random effects or `dharma_residuals()` using a similar ", + "approach.") + cli_inform(msg) + } } + if (type == "mle-laplace") type <- "mle-eb" model_missing <- FALSE if (identical(model, c(1, 2))) model_missing <- TRUE model <- as.integer(model[[1]]) diff --git a/tests/testthat/test-7-visreg.R b/tests/testthat/test-1-visreg.R similarity index 100% rename from tests/testthat/test-7-visreg.R rename to tests/testthat/test-1-visreg.R