@@ -67,10 +67,20 @@ test_that("ppc_loo_pit_qq returns ggplot object", {
6767 skip_if_not_installed(" loo" )
6868 expect_gg(p1 <- ppc_loo_pit_qq(y , yrep , lw ))
6969 expect_gg(p2 <- ppc_loo_pit_qq(y , yrep , psis_object = psis1 ))
70- expect_equal(p1 $ labels $ x , " Uniform" )
70+ if (" get_labs" %in% getNamespaceExports(" ggplot2" )) {
71+ ll1 <- ggplot2 :: get_labs(p1 )
72+ } else {
73+ ll1 <- p1 $ labels
74+ }
75+ expect_equal(ll1 $ x , " Uniform" )
7176 expect_equal(p1 $ data , p2 $ data )
7277 expect_gg(p3 <- ppc_loo_pit_qq(y , yrep , lw , compare = " normal" ))
73- expect_equal(p3 $ labels $ x , " Normal" )
78+ if (" get_labs" %in% getNamespaceExports(" ggplot2" )) {
79+ ll3 <- ggplot2 :: get_labs(p3 )
80+ } else {
81+ ll3 <- p3 $ labels
82+ }
83+ expect_equal(ll3 $ x , " Normal" )
7484})
7585
7686test_that(" ppc_loo_pit_ecdf returns a ggplot object" , {
@@ -79,11 +89,21 @@ test_that("ppc_loo_pit_ecdf returns a ggplot object", {
7989 expect_gg(p0 <- ppc_loo_pit_ecdf(y , yrep , lw ))
8090 expect_gg(p1 <- ppc_loo_pit_ecdf(y , yrep , lw ))
8191 expect_gg(p2 <- ppc_loo_pit_ecdf(y , yrep , psis_object = psis1 ))
82- expect_equal(p1 $ labels $ x , " LOO PIT" )
83- expect_equal(p1 $ labels $ y , " ECDF" )
92+ if (" get_labs" %in% getNamespaceExports(" ggplot2" )) {
93+ ll1 <- ggplot2 :: get_labs(p1 )
94+ } else {
95+ ll1 <- p1 $ labels
96+ }
97+ expect_equal(ll1 $ x , " LOO PIT" )
98+ expect_equal(ll1 $ y , " ECDF" )
8499 expect_equal(p1 $ data , p2 $ data )
85100 expect_gg(p3 <- ppc_loo_pit_ecdf(y , yrep , lw , plot_diff = TRUE ))
86- expect_equal(p3 $ labels $ y , " ECDF difference" )
101+ if (" get_labs" %in% getNamespaceExports(" ggplot2" )) {
102+ ll3 <- ggplot2 :: get_labs(p3 )
103+ } else {
104+ ll3 <- p3 $ labels
105+ }
106+ expect_equal(ll3 $ y , " ECDF difference" )
87107})
88108
89109test_that(" ppc_loo_pit functions work when pit specified instead of y, yrep, and lw" , {
0 commit comments