File: helpers-testthat.R

package info (click to toggle)
r-cran-bayesplot 1.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,288 kB
  • sloc: sh: 13; makefile: 2
file content (19 lines) | stat: -rw-r--r-- 669 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
expect_gg <- function(x) {
  testthat::expect_s3_class(x, "ggplot")
  invisible(ggplot_build(x))
}
expect_gtable <- function(x) testthat::expect_s3_class(x, "gtable")
expect_mcmc_array <- function(x) testthat::expect_true(is_mcmc_array(x))
expect_bayesplot_grid <- function(x) testthat::expect_true(is_bayesplot_grid(x))


#' Insert fake divergences for testing purposes
#'
#' @noRd
#' @param np Data frame returned by `nuts_params()`
#' @return `np` with every other iter marked as a divergence
ensure_divergences <- function(np) {
  divs <- rep_len(c(0,1), length.out = sum(np$Parameter=="divergent__"))
  np$Value[np$Parameter=="divergent__"] <- divs
  return(np)
}