Skip to content

Commit 06afe39

Browse files
committed
branch tests on ggplot2 version until we require 3.0.0
1 parent 3f8ea3b commit 06afe39

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

tests/testthat/test-mcmc-intervals.R

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,32 @@ test_that("mcmc_intervals/areas with rhat", {
8585
expect_error(expect_warning(mcmc_intervals(arr, rhat = rbad)))
8686

8787
expect_gg(g <- mcmc_intervals(arr, rhat = r))
88-
rhat_map <- g$layers[[3]][["mapping"]]
89-
expect_identical(as.character(rhat_map[["colour"]]), c("~", "rhat_rating"))
88+
if (utils::packageVersion("ggplot2") >= "3.0.0") {
89+
rhat_map <- g$layers[[3]][["mapping"]]
90+
expect_identical(as.character(rhat_map[["colour"]]), c("~", "rhat_rating"))
91+
}
9092

9193
# areas with rhat.
9294

9395
# layer 1 is maybe line vertical line. [skip]
9496

9597
# layer 2 is inner interval.
9698
expect_gg(g2 <- mcmc_areas(arr, rhat = r))
97-
rhat_map2 <- g2$layers[[2]][["mapping"]]
98-
expect_identical(as.character(rhat_map2$fill), c("~", "rhat_rating"))
99-
expect_identical(as.character(rhat_map2$colour), c("~", "rhat_rating"))
99+
if (utils::packageVersion("ggplot2") >= "3.0.0") {
100+
rhat_map2 <- g2$layers[[2]][["mapping"]]
101+
expect_identical(as.character(rhat_map2$fill), c("~", "rhat_rating"))
102+
expect_identical(as.character(rhat_map2$colour), c("~", "rhat_rating"))
103+
# layer 3 is point estimate. manually colored. [skip]
100104

101-
# layer 3 is point estimate. manually colored. [skip]
105+
# layer 4 is outer interval.
106+
rhat_map4 <- g2$layers[[4]][["mapping"]]
107+
expect_identical(as.character(rhat_map4$colour), c("~", "rhat_rating"))
102108

103-
# layer 4 is outer interval.
104-
rhat_map4 <- g2$layers[[4]][["mapping"]]
105-
expect_identical(as.character(rhat_map4$colour), c("~", "rhat_rating"))
109+
# layer 5 is bottom line.
106110

107-
# layer 5 is bottom line.
108-
rhat_map5 <- g2$layers[[5]][["mapping"]]
109-
expect_identical(as.character(rhat_map5$colour), c("~", "rhat_rating"))
111+
rhat_map5 <- g2$layers[[5]][["mapping"]]
112+
expect_identical(as.character(rhat_map5$colour), c("~", "rhat_rating"))
113+
}
110114
})
111115

112116
test_that("mcmc_areas_data computes density", {

tests/testthat/test-ppc-distributions.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", {
2929
expect_gg(ppc_freqpoly(y2, yrep2))
3030

3131
expect_gg(p <- ppc_hist(y, yrep[1:8, ], binwidth = 3))
32-
facet_var <- "rep_label"
33-
expect_equal(as.character(p$facet$params$facets[[1]])[2], facet_var)
32+
if (utils::packageVersion("ggplot2") >= "3.0.0") {
33+
facet_var <- "~rep_label"
34+
expect_equal(as.character(p$facet$params$facets[1]), facet_var)
35+
}
3436
})
3537

3638
test_that("ppc_freqpoly_grouped returns a ggplot object", {

0 commit comments

Comments
 (0)