Skip to content

Commit

Permalink
fix, lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 20, 2024
1 parent 216f0e0 commit 63af222
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
25 changes: 13 additions & 12 deletions tests/testthat/test-GLMMadaptive.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
skip_if_offline()
skip_if_not_installed("GLMMadaptive")
skip_if_not_installed("lme4")
skip_if_not_installed("httr")

m <- download_model("GLMMadaptive_zi_2")
m2 <- download_model("GLMMadaptive_zi_1")
Expand Down Expand Up @@ -28,7 +29,7 @@ test_that("model_info", {
test_that("get_deviance + logLik", {
expect_equal(get_deviance(m3), 183.96674, tolerance = 1e-3)
expect_equal(get_loglikelihood(m3), logLik(m3), tolerance = 1e-3, ignore_attr = TRUE)
expect_equal(get_df(m3, type = "model"), 5)
expect_identical(get_df(m3, type = "model"), 5)
})

test_that("get_df", {
Expand All @@ -50,10 +51,10 @@ test_that("get_df", {
})

test_that("n_parameters", {
expect_equal(n_parameters(m), 6)
expect_equal(n_parameters(m2), 6)
expect_equal(n_parameters(m, effects = "random"), 2)
expect_equal(n_parameters(m2, effects = "random"), 1)
expect_identical(n_parameters(m), 6L)
expect_identical(n_parameters(m2), 6L)
expect_identical(n_parameters(m, effects = "random"), 2L)
expect_identical(n_parameters(m2, effects = "random"), 1L)
})

test_that("find_predictors", {
Expand Down Expand Up @@ -273,7 +274,7 @@ test_that("get_data", {
})

test_that("find_parameter", {
expect_equal(
expect_identical(
find_parameters(m),
list(
conditional = c("(Intercept)", "child", "camper1"),
Expand All @@ -282,23 +283,23 @@ test_that("find_parameter", {
zero_inflated_random = "zi_(Intercept)"
)
)
expect_equal(
expect_identical(
find_parameters(m2),
list(
conditional = c("(Intercept)", "child", "camper1"),
random = "(Intercept)",
zero_inflated = c("(Intercept)", "child", "livebait1")
)
)
expect_equal(
expect_identical(
find_parameters(m3),
list(
conditional = c("(Intercept)", "period2", "period3", "period4"),
random = "(Intercept)"
)
)

expect_equal(nrow(get_parameters(m)), 6)
expect_identical(nrow(get_parameters(m)), 6L)
expect_equal(
get_parameters(m, effects = "random"),
list(
Expand All @@ -307,14 +308,14 @@ test_that("find_parameter", {
),
tolerance = 1e-5
)
expect_equal(nrow(get_parameters(m2)), 6)
expect_identical(nrow(get_parameters(m2)), 6L)
expect_equal(get_parameters(m2, effects = "random"),
list(random = c(
-1.3262364, -0.2048055, 1.3852572, 0.5282277
)),
tolerance = 1e-5
)
expect_equal(
expect_identical(
get_parameters(m3)$Component,
c(
"conditional",
Expand All @@ -337,7 +338,7 @@ test_that("is_multivariate", {
})

test_that("find_algorithm", {
expect_equal(
expect_identical(
find_algorithm(m),
list(algorithm = "quasi-Newton", optimizer = "optim")
)
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-brms.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ skip_on_cran()
skip_if_offline()
skip_on_os("mac")
skip_if_not_installed("brms")
skip_if_not_installed("httr")

# Model fitting -----------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-brms_aterms.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ skip_on_cran()
skip_if_offline()
skip_on_os("mac")
skip_if_not_installed("brms")
skip_if_not_installed("httr")

# Model fitting -----------------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-clean_names.R
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test_that("clean_names, model", {

skip_on_cran()
skip_if_offline()
skip_if_not_installed("httr")

test_that("clean_names, multimembership", {
m1 <- suppressWarnings(insight::download_model("brms_mm_1"))
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-format_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ skip_if_offline()
skip_on_os(c("mac", "linux", "solaris"))
skip_if_not_installed("bayestestR")
skip_if_not_installed("rstanarm")
skip_if_not_installed("httr")

# test for bayesian models -----------------
m1 <- insight::download_model("stanreg_glm_1")
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-get_loglikelihood.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ test_that("get_loglikelihood - (g)lmer", {
ll2 <- stats::logLik(x, REML = FALSE)
expect_equal(as.numeric(ll), as.numeric(ll2), tolerance = 1e-4, ignore_attr = TRUE)

skip_if_not_installed("httr")

model <- download_model("lmerMod_1")
skip_if(is.null(model))
expect_equal(
Expand Down

0 comments on commit 63af222

Please sign in to comment.