Skip to content

Commit

Permalink
spurious(?) viewport-too-small error with new ggplot2 version 3.5.0
Browse files Browse the repository at this point in the history
Fixes #691
  • Loading branch information
strengejacke committed Mar 4, 2024
1 parent 5ca986a commit 01ea747
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# small wrapper around this commonly used try-catch
.safe <- function(code, on_error = NULL) {
tryCatch(code, error = function(e) on_error)
if (getOption("easystats_erros", FALSE) && is.null(on_error)) {
code
} else {
tryCatch(code, error = function(e) on_error)
}
}


Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
skip_if_not_installed("withr")
withr::with_options(
list(easystats_erros = TRUE),
test_that(".safe works with options", {
expect_error(performance:::.safe(mean(fd)), regex = "object 'fd' not found")
expect_identical(performance:::.safe(mean(fd), 1L), 1L)
})
)
test_that(".safe works", {
expect_null(performance:::.safe(mean(fd)))
})
2 changes: 2 additions & 0 deletions tests/testthat/test-r2_nagelkerke.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test_that("r2_nagelkerke", {
expect_equal(r2(model), list(R2_Tjur = c(`Tjur's R2` = 0.477692621360749)), tolerance = 1e-3, ignore_attr = TRUE)
})

skip_if_not_installed("withr")

test_that("r2_nagelkerke", {
skip_if_not_installed("MASS")
withr::with_options(
Expand Down

0 comments on commit 01ea747

Please sign in to comment.