Skip to content

Commit 07dd115

Browse files
committed
Add test coverage for non-finite PIT warning
1 parent f02de9e commit 07dd115

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/testthat/test-ppc-loo.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ 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"
68+
)
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)
73+
})
74+
6275
test_that("ppc_loo_pit_qq returns ggplot object", {
6376
skip_if_not_installed("rstanarm")
6477
skip_if_not_installed("loo")

0 commit comments

Comments
 (0)