Skip to content

Commit 37bd81c

Browse files
Added tests to ECDF plot functions
1 parent ade99d9 commit 37bd81c

12 files changed

+987
-2
lines changed

R/helpers-ppc.R

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ get_interpolation_values <- function(N, K, L, prob) {
436436
get(dim),
437437
".\n",
438438
"Values of '", dim, "' available for interpolation: ",
439-
unique(bayesplot:::gamma_adj[, dim]),
439+
paste(unique(bayesplot:::gamma_adj[, dim]), collapse = ", "),
440440
".",
441441
sep = ""
442442
))
@@ -445,14 +445,48 @@ get_interpolation_values <- function(N, K, L, prob) {
445445
vals <- bayesplot:::gamma_adj[
446446
bayesplot:::gamma_adj$L == L & bayesplot:::gamma_adj$prob == prob,
447447
]
448+
if (N > max(vals$N)) {
449+
stop(paste(
450+
"No precomputed values to interpolate from for sample length of ",
451+
N,
452+
".\n",
453+
"Please use a subsample of length ",
454+
max(vals$N),
455+
" or smaller, or consider setting 'interpolate_adj' = FALSE.",
456+
sep = ""
457+
))
458+
}
459+
if (N < min(vals$N)) {
460+
stop(paste(
461+
"No precomputed values to interpolate from for sample length of ",
462+
N,
463+
".\n",
464+
"Please use a subsample of length ",
465+
min(vals$N),
466+
" or larger, or consider setting 'interpolate_adj' = FALSE.",
467+
sep = ""
468+
))
469+
}
448470
if (K > max(vals[vals$N <= N, ]$K)) {
449471
stop(paste(
450472
"No precomputed values available for interpolation for 'K' = ",
451473
K,
452474
".\n",
453475
"Try either setting a value of 'K' <= ",
454476
max(vals[vals$N <= N, ]$K),
455-
"or 'interpolate_adj' = FALSE."
477+
"or 'interpolate_adj' = FALSE.",
478+
sep = ""
479+
))
480+
}
481+
if (K < min(vals[vals$N <= N, ]$K)) {
482+
stop(paste(
483+
"No precomputed values available for interpolation for 'K' = ",
484+
K,
485+
".\n",
486+
"Try either setting a value of 'K' >= ",
487+
min(vals[vals$N <= N, ]$K),
488+
"or 'interpolate_adj' = FALSE.",
489+
sep = ""
456490
))
457491
}
458492
vals

tests/testthat/_snaps/mcmc-traces/mcmc-rank-ecdf-default.svg

Lines changed: 130 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-traces/mcmc-rank-ecdf-no-diff.svg

Lines changed: 130 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-traces/mcmc-rank-ecdf-one-param-no-diff.svg

Lines changed: 72 additions & 0 deletions
Loading

tests/testthat/_snaps/mcmc-traces/mcmc-rank-ecdf-one-parameter.svg

Lines changed: 72 additions & 0 deletions
Loading
Lines changed: 53 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)