Skip to content

Commit b94da2f

Browse files
committed
skip_if_not_installed in tests for hexbin and ggfortify
1 parent 4e8bb63 commit b94da2f

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

R/ppc-censoring.R

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ ppc_km_overlay <- function(
7676
check_ignored_arguments(..., ok_args = "add_group")
7777
add_group <- list(...)$add_group
7878

79-
if(!requireNamespace("survival", quietly = TRUE)){
80-
abort("Package 'survival' required.")
81-
}
82-
if(!requireNamespace("ggfortify", quietly = TRUE)){
83-
abort("Package 'ggfortify' required.")
84-
}
79+
suggested_package("survival")
80+
suggested_package("ggfortify")
8581

8682
stopifnot(is.numeric(status_y))
8783
stopifnot(all(status_y %in% c(0, 1)))

tests/testthat/test-mcmc-scatter-and-parcoord.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ test_that("mcmc_pairs returns a bayesplot_grid object", {
6969
expect_bayesplot_grid(g)
7070
expect_equal(print(g), plot(g))
7171
expect_bayesplot_grid(mcmc_pairs(arr, pars = "sigma", regex_pars = "beta"))
72-
expect_bayesplot_grid(mcmc_pairs(arr, regex_pars = "x:[1-3]",
73-
transformations = "exp",
74-
diag_fun = "dens", off_diag_fun = "hex",
75-
diag_args = list(trim = FALSE),
76-
off_diag_args = list(binwidth = c(0.5, 0.5))))
7772
expect_bayesplot_grid(mcmc_pairs(drawsarr, pars = "mu", regex_pars = "theta"))
7873

7974
expect_bayesplot_grid(suppressWarnings(mcmc_pairs(arr1chain, regex_pars = "beta")))
@@ -83,6 +78,15 @@ test_that("mcmc_pairs returns a bayesplot_grid object", {
8378
expect_bayesplot_grid(mcmc_pairs(dframe_multiple_chains, regex_pars = "beta"))
8479
})
8580

81+
test_that("mcmc_pairs using hexbin works", {
82+
skip_if_not_installed("hexbin")
83+
expect_bayesplot_grid(mcmc_pairs(arr, regex_pars = "x:[1-3]",
84+
transformations = "exp",
85+
diag_fun = "dens", off_diag_fun = "hex",
86+
diag_args = list(trim = FALSE),
87+
off_diag_args = list(binwidth = c(0.5, 0.5))))
88+
})
89+
8690
test_that("no mcmc_pairs non-NUTS 'condition's fail", {
8791
expect_bayesplot_grid(
8892
mcmc_pairs(arr, pars = "sigma", regex_pars = "beta",
@@ -116,7 +120,7 @@ test_that("mcmc_pairs works with NUTS info", {
116120
p <- mcmc_pairs(
117121
post,
118122
pars = c("wt", "am"),
119-
off_diag_fun = "hex",
123+
off_diag_fun = "scatter",
120124
condition = pairs_condition(nuts = "lp__"),
121125
lp = lp,
122126
np = np,

tests/testthat/test-ppc-censoring.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ context("PPC: censoring")
44
source(test_path("data-for-ppc-tests.R"))
55

66
test_that("ppc_km_overlay returns a ggplot object", {
7+
skip_if_not_installed("ggfortify")
78
expect_gg(ppc_km_overlay(y, yrep, status_y = status_y, size = 0.5, alpha = 0.2))
89
expect_gg(ppc_km_overlay(y2, yrep2, status_y = status_y2))
910
})
1011

1112
test_that("ppc_km_overlay_grouped returns a ggplot object", {
13+
skip_if_not_installed("ggfortify")
1214
expect_gg(ppc_km_overlay_grouped(y, yrep, group,
1315
status_y = status_y))
1416
expect_gg(ppc_km_overlay_grouped(y, yrep, as.numeric(group),
@@ -29,6 +31,7 @@ test_that("ppc_km_overlay_grouped returns a ggplot object", {
2931
test_that("ppc_km_overlay renders correctly", {
3032
testthat::skip_on_cran()
3133
testthat::skip_if_not_installed("vdiffr")
34+
skip_if_not_installed("ggfortify")
3235

3336
p_base <- ppc_km_overlay(vdiff_y2, vdiff_yrep2, status_y = vdiff_status_y2)
3437
vdiffr::expect_doppelganger("ppc_km_overlay (default)", p_base)

0 commit comments

Comments
 (0)