Skip to content

Commit

Permalink
Remove unnecessary tryCatch() statements targeting `insight::downlo…
Browse files Browse the repository at this point in the history
…ad_model()` (#746)
  • Loading branch information
strengejacke authored Jul 11, 2024
1 parent 06ed6f1 commit db8ab03
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.12.0.8
Authors@R:
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
role = c("aut", "cre"),
Expand Down Expand Up @@ -39,18 +39,18 @@ Authors@R:
email = "[email protected]",
comment = c(ORCID = "0000-0003-4315-6788", Twitter = "@rempsyc")),
person(given = "Vincent",
family = "Arel-Bundock",
email = "[email protected]",
family = "Arel-Bundock",
email = "[email protected]",
role = "ctb",
comment = c(ORCID = "0000-0003-2042-7063")),
person(given = "Martin",
family = "Jullum",
role = "rev"),
person(given = "gjo11",
role = "rev"),
person("Etienne",
"Bacher", ,
"[email protected]",
person("Etienne",
"Bacher", ,
"[email protected]",
role = "ctb",
comment = c(ORCID = "0000-0002-9271-5075")))
Maintainer: Daniel Lüdecke <[email protected]>
Expand Down Expand Up @@ -93,15 +93,15 @@ Suggests:
DHARMa,
estimatr,
fixest,
flextable,
flextable,
forecast,
ftExtra,
gamm4,
ggplot2,
glmmTMB,
graphics,
Hmisc,
httr,
httr2,
ICS,
ICSOutlier,
ISLR,
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-icc.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test_that("icc", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
m2 <- insight::download_model("stanreg_lmerMod_1")
expect_equal(
icc(m2),
Expand All @@ -57,7 +57,7 @@ test_that("icc", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
m3 <- insight::download_model("brms_mixed_1")
set.seed(123)
expect_equal(
Expand All @@ -71,7 +71,7 @@ test_that("icc", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
m3 <- insight::download_model("brms_mixed_1")
set.seed(123)
expect_equal(
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-model_performance.bayesian.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ test_that("model_performance.stanreg", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
set.seed(333)
model <- tryCatch(insight::download_model("stanreg_lm_1"), error = function(e) NULL)
model <- insight::download_model("stanreg_lm_1")
skip_if(is.null(model))
perf <- model_performance(model)

expect_equal(perf$R2, 0.7398733, tolerance = 1e-3)
expect_equal(perf$R2_adjusted, 0.7162912, tolerance = 1e-3)
expect_equal(perf$ELPD, -83.49838, tolerance = 1e-3)

model <- tryCatch(insight::download_model("stanreg_lm_2"), error = function(e) NULL)
model <- insight::download_model("stanreg_lm_2")
skip_if(is.null(model))
perf <- model_performance(model)

expect_equal(perf$R2, 0.8168386, tolerance = 1e-3)
expect_equal(perf$R2_adjusted, 0.7979026, tolerance = 1e-3)
expect_equal(perf$ELPD, -78.38735, tolerance = 1e-3)

model <- tryCatch(insight::download_model("stanreg_lmerMod_1"), error = function(e) NULL)
model <- insight::download_model("stanreg_lmerMod_1")
skip_if(is.null(model))
perf <- model_performance(model)

Expand All @@ -34,10 +34,10 @@ test_that("model_performance.brmsfit", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")
set.seed(333)

model <- tryCatch(insight::download_model("brms_1"), error = function(e) NULL)
model <- insight::download_model("brms_1")
skip_if(is.null(model))
expect_message({
perf <- model_performance(model)
Expand All @@ -50,7 +50,7 @@ test_that("model_performance.brmsfit", {
"RMSE", "Sigma"
))

model <- tryCatch(insight::download_model("brms_mixed_4"), error = function(e) NULL)
model <- insight::download_model("brms_mixed_4")
skip_if(is.null(model))
expect_message({
perf <- model_performance(model)
Expand All @@ -63,7 +63,7 @@ test_that("model_performance.brmsfit", {
"R2_adjusted", "R2_adjusted_marginal", "ICC", "RMSE", "Sigma"
))

model <- tryCatch(insight::download_model("brms_ordinal_1"), error = function(e) NULL)
model <- insight::download_model("brms_ordinal_1")
skip_if(is.null(model))
perf <- suppressWarnings(model_performance(model))
expect_equal(perf$R2, 0.8760015, tolerance = 1e-3)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-model_performance.merMod.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_that("model_performance.merMod", {
skip_on_cran()
skip_if_not_installed("curl")
skip_if_offline()
skip_if_not_installed("httr")
skip_if_not_installed("httr2")

model <- insight::download_model("lmerMod_1")
expect_equal(model_performance(model, estimator = "ML")$AIC, AIC(logLik(model, REML = FALSE)), tolerance = 0.01)
Expand Down

0 comments on commit db8ab03

Please sign in to comment.