From 2e931ef0f3e4672ea204b374c33baec8c452b0cc Mon Sep 17 00:00:00 2001 From: Ben Bolker Date: Sun, 17 Mar 2024 12:18:33 -0400 Subject: [PATCH 1/2] loosen residual test tolerance slightly --- tests/testthat/test-5-residuals.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-5-residuals.R b/tests/testthat/test-5-residuals.R index 26056f899..68ac82b6a 100644 --- a/tests/testthat/test-5-residuals.R +++ b/tests/testthat/test-5-residuals.R @@ -251,7 +251,7 @@ test_that("Pearson residuals work", { m1 <- glmmTMB::glmmTMB(prop ~ 1, data = dat, family = gaussian()) r <- residuals(m, type = "pearson") r1 <- residuals(m1, type = "pearson") - expect_equal(as.numeric(r), as.numeric(r1)) + expect_equal(as.numeric(r), as.numeric(r1), tolerance = 1e-6) # gamma set.seed(1) From e039d385948913b1208a5499f55b123ae8136091 Mon Sep 17 00:00:00 2001 From: Eric Ward <5046884+ericward-noaa@users.noreply.github.com> Date: Tue, 19 Mar 2024 10:49:50 -0700 Subject: [PATCH 2/2] Abs (gradients) I think we want the absolute value of gradients to be triggering the warnings -- right now only large positive ones are --- R/check.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/check.R b/R/check.R index 0317e8ec2..0ac773bc1 100644 --- a/R/check.R +++ b/R/check.R @@ -89,7 +89,7 @@ sanity <- function(object, big_sd_log10 = 2, gradient_thresh = 0.001, silent = F g <- object$gradients np <- names(object$model$par) for (i in seq_along(g)) { - if (g[i] > gradient_thresh) { + if (abs(g[i]) > gradient_thresh) { if (!silent) { cli::cli_alert_danger(c( "`", np[i], @@ -104,7 +104,7 @@ sanity <- function(object, big_sd_log10 = 2, gradient_thresh = 0.001, silent = F } } - if (all(g <= gradient_thresh)) { + if (all(abs(g) <= gradient_thresh)) { msg <- "No gradients with respect to fixed effects are >= " if (!silent) cli::cli_alert_success(paste0(msg, gradient_thresh)) gradients_ok <- TRUE