@@ -67,10 +67,20 @@ test_that("ppc_loo_pit_qq returns ggplot object", {
67
67
skip_if_not_installed(" loo" )
68
68
expect_gg(p1 <- ppc_loo_pit_qq(y , yrep , lw ))
69
69
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" )
71
76
expect_equal(p1 $ data , p2 $ data )
72
77
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" )
74
84
})
75
85
76
86
test_that(" ppc_loo_pit_ecdf returns a ggplot object" , {
@@ -79,11 +89,21 @@ test_that("ppc_loo_pit_ecdf returns a ggplot object", {
79
89
expect_gg(p0 <- ppc_loo_pit_ecdf(y , yrep , lw ))
80
90
expect_gg(p1 <- ppc_loo_pit_ecdf(y , yrep , lw ))
81
91
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" )
84
99
expect_equal(p1 $ data , p2 $ data )
85
100
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" )
87
107
})
88
108
89
109
test_that(" ppc_loo_pit functions work when pit specified instead of y, yrep, and lw" , {
0 commit comments