@@ -59,17 +59,50 @@ test_that("ppc_loo_pit_overlay works with boundary_correction=FALSE", {
5959 expect_gg(p1 )
6060})
6161
62- test_that(" .kde_correction warns when PIT values are non-finite" , {
63- set.seed(123 )
64- pit_vals <- c(stats :: runif(500 ), Inf )
65- expect_warning(
66- out <- .kde_correction(pit_vals , bw = " nrd0" , grid_len = 128 ),
67- " Non-finite PIT values are invalid"
62+ test_that(" ppc_loo_pit_data validates user-provided pit values" , {
63+ expect_error(
64+ ppc_loo_pit_data(pit = c(0.5 , Inf )),
65+ " between 0 and 1"
66+ )
67+ expect_error(
68+ ppc_loo_pit_data(pit = c(- 1 , 0.5 )),
69+ " between 0 and 1"
70+ )
71+ expect_error(
72+ ppc_loo_pit_data(pit = c(0.5 , NA )),
73+ " NAs not allowed"
74+ )
75+ expect_error(
76+ ppc_loo_pit_data(pit = " not numeric" ),
77+ " is.numeric"
78+ )
79+ expect_error(
80+ ppc_loo_pit_data(pit = c(Inf , - Inf , Inf )),
81+ " between 0 and 1"
82+ )
83+ expect_error(
84+ ppc_loo_pit_data(pit = 0.5 , boundary_correction = TRUE ),
85+ " At least 2 PIT values"
86+ )
87+ })
88+
89+ test_that(" ppc_loo_pit_qq validates user-provided pit values" , {
90+ expect_error(
91+ ppc_loo_pit_qq(pit = c(0.5 , Inf )),
92+ " between 0 and 1"
93+ )
94+ expect_error(
95+ ppc_loo_pit_qq(pit = c(- 1 , 0.5 )),
96+ " between 0 and 1"
97+ )
98+ expect_error(
99+ ppc_loo_pit_qq(pit = c(0.5 , NA )),
100+ " NAs not allowed"
101+ )
102+ expect_error(
103+ ppc_loo_pit_qq(pit = " not numeric" ),
104+ " is.numeric"
68105 )
69- expect_type(out , " list" )
70- expect_true(all(c(" xs" , " bc_pvals" ) %in% names(out )))
71- expect_equal(length(out $ xs ), 128 )
72- expect_equal(length(out $ bc_pvals ), 128 )
73106})
74107
75108test_that(" ppc_loo_pit_qq returns ggplot object" , {
0 commit comments