From 078303318cbf791dad8497070813090bbce9ecf6 Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Wed, 8 Apr 2026 17:47:04 +0530 Subject: [PATCH 1/5] use geom_step() as default in ppc_ecdf_overlay() and deprecate discrete argument --- NEWS.md | 1 + R/ppc-distributions.R | 40 ++++++++++++----- R/ppd-distributions.R | 12 ++++- .../ppc-ecdf-overlay-default.svg | 22 +++++----- .../ppc-ecdf-overlay-grouped-default.svg | 44 +++++++++---------- ...> ppc-ecdf-overlay-grouped-size-alpha.svg} | 2 +- ...ha.svg => ppc-ecdf-overlay-size-alpha.svg} | 2 +- tests/testthat/test-ppc-distributions.R | 22 ++++++++-- 8 files changed, 92 insertions(+), 53 deletions(-) rename tests/testthat/_snaps/ppc-distributions/{ppc-ecdf-overlay-grouped-discrete-size-alpha.svg => ppc-ecdf-overlay-grouped-size-alpha.svg} (99%) rename tests/testthat/_snaps/ppc-distributions/{ppc-ecdf-overlay-discrete-size-alpha.svg => ppc-ecdf-overlay-size-alpha.svg} (98%) diff --git a/NEWS.md b/NEWS.md index c8f7d131f..7de4db835 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # bayesplot (development version) +* `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated . * Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`. * Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`. * Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`. diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index d32a2e1a7..0161b8b3a 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -43,8 +43,8 @@ #' `ppc_ecdf_overlay_grouped()`, `ppc_dens_overlay_grouped()`}{ #' Kernel density or empirical CDF estimates of each dataset (row) in #' `yrep` are overlaid, with the distribution of `y` itself on top -#' (and in a darker shade). When using `ppc_ecdf_overlay()` with discrete -#' data, set the `discrete` argument to `TRUE` for better results. +#' (and in a darker shade). `ppc_ecdf_overlay()` uses step functions, +#' consistent with the mathematical definition of the ECDF. #' For an example of `ppc_dens_overlay()` also see Gabry et al. (2019). #' } #' \item{`ppc_violin_grouped()`}{ @@ -85,7 +85,7 @@ #' #' ppc_dens_overlay(y, yrep[1:25, ]) #' \donttest{ -#' # ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data) +#' # ppc_ecdf_overlay (always uses step functions) #' ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) #' #' # PIT-ECDF and PIT-ECDF difference plot of the PIT values of y compared to @@ -258,20 +258,29 @@ ppc_dens_overlay_grouped <- function(y, #' @export #' @rdname PPC-distributions -#' @param discrete For `ppc_ecdf_overlay()`, should the data be treated as -#' discrete? The default is `FALSE`, in which case `geom="line"` is -#' passed to [ggplot2::stat_ecdf()]. If `discrete` is set to -#' `TRUE` then `geom="step"` is used. +#' @param discrete +#' `r lifecycle::badge("deprecated")` The `discrete` argument is +#' deprecated. The ECDF is a step function by definition, so `geom_step()` +#' is now always used. #' @param pad A logical scalar passed to [ggplot2::stat_ecdf()]. #' ppc_ecdf_overlay <- function(y, yrep, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7) { check_ignored_arguments(...) + + if (is_present(discrete)) { + deprecate_warn( + "1.12.0", + "ppc_ecdf_overlay(discrete)", + details = "The ECDF is now always plotted as a step function." + ) + } + data <- ppc_data(y, yrep) ggplot(data) + @@ -291,7 +300,7 @@ ppc_ecdf_overlay <- function(y, stat_ecdf( data = function(x) dplyr::filter(x, !.data$is_y), mapping = aes(group = .data$rep_id, color = "yrep"), - geom = if (discrete) "step" else "line", + geom = "step", linewidth = size, alpha = alpha, pad = pad @@ -299,7 +308,7 @@ ppc_ecdf_overlay <- function(y, stat_ecdf( data = function(x) dplyr::filter(x, .data$is_y), mapping = aes(color = "y"), - geom = if (discrete) "step" else "line", + geom = "step", linewidth = 1, pad = pad ) + @@ -316,17 +325,24 @@ ppc_ecdf_overlay_grouped <- function(y, yrep, group, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7) { check_ignored_arguments(...) + if (is_present(discrete)) { + deprecate_warn( + "1.12.0", + "ppc_ecdf_overlay_grouped(discrete)", + details = "The ECDF is now always plotted as a step function." + ) + } + p_overlay <- ppc_ecdf_overlay( y = y, yrep = yrep, ..., - discrete = discrete, pad = pad, size = size, alpha = alpha diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index 70c4e5a68..07e85b2f1 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -83,12 +83,20 @@ ppd_dens_overlay <- ppd_ecdf_overlay <- function(ypred, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7) { check_ignored_arguments(...) + if (is_present(discrete)) { + deprecate_warn( + "1.12.0", + "ppd_ecdf_overlay(discrete)", + details = "The ECDF is now always plotted as a step function." + ) + } + data <- ppd_data(ypred) ggplot(data, mapping = aes(x = .data$value)) + hline_at( @@ -99,7 +107,7 @@ ppd_ecdf_overlay <- ) + stat_ecdf( mapping = aes(group = .data$rep_id, color = "ypred"), - geom = if (discrete) "step" else "line", + geom = "step", linewidth = size, alpha = alpha, pad = pad diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg index 56e21f82c..4b7eac4c2 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-default.svg @@ -28,17 +28,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg index 029410fbd..fdd8a4393 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-default.svg @@ -28,17 +28,17 @@ - - - - - - - - - - - + + + + + + + + + + + @@ -53,17 +53,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg similarity index 99% rename from tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg index cb9301ac4..f42c93307 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-discrete-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-grouped-size-alpha.svg @@ -128,6 +128,6 @@ r e p -ppc_ecdf_overlay_grouped (discrete, size, alpha) +ppc_ecdf_overlay_grouped (size, alpha) diff --git a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg similarity index 98% rename from tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg rename to tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg index e35e25a85..e10910898 100644 --- a/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-discrete-size-alpha.svg +++ b/tests/testthat/_snaps/ppc-distributions/ppc-ecdf-overlay-size-alpha.svg @@ -68,6 +68,6 @@ r e p -ppc_ecdf_overlay (discrete, size, alpha) +ppc_ecdf_overlay (size, alpha) diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index 34e1c82f4..23e5769ff 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -360,13 +360,12 @@ test_that("ppc_ecdf_overlay renders correctly", { p_custom <- ppc_ecdf_overlay( vdiff_y2, vdiff_yrep2, - discrete = TRUE, size = 2, alpha = .2 ) vdiffr::expect_doppelganger( - "ppc_ecdf_overlay (discrete, size, alpha)", + "ppc_ecdf_overlay (size, alpha)", p_custom ) }) @@ -383,17 +382,32 @@ test_that("ppc_ecdf_overlay_grouped renders correctly", { vdiff_y2, vdiff_yrep2, vdiff_group2, - discrete = TRUE, size = 2, alpha = .2 ) vdiffr::expect_doppelganger( - "ppc_ecdf_overlay_grouped (discrete, size, alpha)", + "ppc_ecdf_overlay_grouped (size, alpha)", p_custom ) }) +test_that("ppc_ecdf_overlay discrete argument is deprecated", { + lifecycle::expect_deprecated( + ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2, discrete = TRUE) + ) + lifecycle::expect_deprecated( + ppc_ecdf_overlay_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2, discrete = TRUE) + ) + lifecycle::expect_deprecated( + ppd_ecdf_overlay(vdiff_yrep2, discrete = TRUE) + ) + + # no warning when discrete is not supplied + expect_no_warning(ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2)) + expect_no_warning(ppd_ecdf_overlay(vdiff_yrep2)) +}) + test_that("ppc_dens renders correctly", { testthat::skip_on_cran() testthat::skip_if_not_installed("vdiffr") From 456349e6d5086cc3c4c3d7c4cab36faaacc5febd Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Wed, 8 Apr 2026 18:05:00 +0530 Subject: [PATCH 2/5] fix deprecation version to 1.16.0 --- NEWS.md | 2 +- R/ppc-distributions.R | 4 ++-- R/ppd-distributions.R | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7de4db835..34022c666 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ # bayesplot (development version) -* `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated . +* `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated. * Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`. * Fixed `is_chain_list()` to correctly reject empty lists instead of silently returning `TRUE`. * Added unit tests for `mcmc_areas_ridges_data()`, `mcmc_parcoord_data()`, and `mcmc_trace_data()`. diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 0161b8b3a..5a4d07e25 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -275,7 +275,7 @@ ppc_ecdf_overlay <- function(y, if (is_present(discrete)) { deprecate_warn( - "1.12.0", + "1.16.0", "ppc_ecdf_overlay(discrete)", details = "The ECDF is now always plotted as a step function." ) @@ -333,7 +333,7 @@ ppc_ecdf_overlay_grouped <- function(y, if (is_present(discrete)) { deprecate_warn( - "1.12.0", + "1.16.0", "ppc_ecdf_overlay_grouped(discrete)", details = "The ECDF is now always plotted as a step function." ) diff --git a/R/ppd-distributions.R b/R/ppd-distributions.R index 07e85b2f1..fca2d5ee2 100644 --- a/R/ppd-distributions.R +++ b/R/ppd-distributions.R @@ -91,7 +91,7 @@ ppd_ecdf_overlay <- if (is_present(discrete)) { deprecate_warn( - "1.12.0", + "1.16.0", "ppd_ecdf_overlay(discrete)", details = "The ECDF is now always plotted as a step function." ) From 1df4ea3f9d66433b7da322774d4dd73324f4e699 Mon Sep 17 00:00:00 2001 From: Utkarsh Date: Wed, 8 Apr 2026 19:06:40 +0530 Subject: [PATCH 3/5] regenerate roxygen docs for deprecated discrete argument --- man/PPC-distributions.Rd | 17 ++++++++--------- man/PPD-distributions.Rd | 9 ++++----- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/man/PPC-distributions.Rd b/man/PPC-distributions.Rd index b0099f2d1..f2109bd83 100644 --- a/man/PPC-distributions.Rd +++ b/man/PPC-distributions.Rd @@ -53,7 +53,7 @@ ppc_ecdf_overlay( y, yrep, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7 @@ -64,7 +64,7 @@ ppc_ecdf_overlay_grouped( yrep, group, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7 @@ -174,10 +174,9 @@ the predictive distributions.} default kernel density estimation parameters or truncate the density support. \code{n_dens} defaults to \code{1024}.} -\item{discrete}{For \code{ppc_ecdf_overlay()}, should the data be treated as -discrete? The default is \code{FALSE}, in which case \code{geom="line"} is -passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}. If \code{discrete} is set to -\code{TRUE} then \code{geom="step"} is used.} +\item{discrete}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} The \code{discrete} argument is +deprecated. The ECDF is a step function by definition, so \code{geom_step()} +is now always used.} \item{pad}{A logical scalar passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}.} @@ -285,8 +284,8 @@ variable for \code{y} and each dataset (row) in \code{yrep}. For this plot \code{ppc_ecdf_overlay_grouped()}, \code{ppc_dens_overlay_grouped()}}{ Kernel density or empirical CDF estimates of each dataset (row) in \code{yrep} are overlaid, with the distribution of \code{y} itself on top -(and in a darker shade). When using \code{ppc_ecdf_overlay()} with discrete -data, set the \code{discrete} argument to \code{TRUE} for better results. +(and in a darker shade). \code{ppc_ecdf_overlay()} uses step functions, +consistent with the mathematical definition of the ECDF. For an example of \code{ppc_dens_overlay()} also see Gabry et al. (2019). } \item{\code{ppc_violin_grouped()}}{ @@ -323,7 +322,7 @@ dim(yrep) ppc_dens_overlay(y, yrep[1:25, ]) \donttest{ -# ppc_ecdf_overlay with continuous data (set discrete=TRUE if discrete data) +# ppc_ecdf_overlay (always uses step functions) ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) # PIT-ECDF and PIT-ECDF difference plot of the PIT values of y compared to diff --git a/man/PPD-distributions.Rd b/man/PPD-distributions.Rd index a53c62e40..236cf5350 100644 --- a/man/PPD-distributions.Rd +++ b/man/PPD-distributions.Rd @@ -31,7 +31,7 @@ ppd_dens_overlay( ppd_ecdf_overlay( ypred, ..., - discrete = FALSE, + discrete = deprecated(), pad = TRUE, size = 0.25, alpha = 0.7 @@ -89,10 +89,9 @@ the predictive distributions.} default kernel density estimation parameters or truncate the density support. \code{n_dens} defaults to \code{1024}.} -\item{discrete}{For \code{ppc_ecdf_overlay()}, should the data be treated as -discrete? The default is \code{FALSE}, in which case \code{geom="line"} is -passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}. If \code{discrete} is set to -\code{TRUE} then \code{geom="step"} is used.} +\item{discrete}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} The \code{discrete} argument is +deprecated. The ECDF is a step function by definition, so \code{geom_step()} +is now always used.} \item{pad}{A logical scalar passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}.} From 963b02643acb27f0b3a4a8eda3d0fa7789daedaa Mon Sep 17 00:00:00 2001 From: jgabry Date: Wed, 8 Apr 2026 16:04:14 -0600 Subject: [PATCH 4/5] clean up doc and tests --- R/ppc-distributions.R | 18 +++++++------- man/PPC-distributions.Rd | 15 ++++++------ man/PPD-distributions.Rd | 4 ++-- tests/testthat/test-ppc-distributions.R | 32 ++++++++++++------------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/R/ppc-distributions.R b/R/ppc-distributions.R index 5a4d07e25..7ab9ffb81 100644 --- a/R/ppc-distributions.R +++ b/R/ppc-distributions.R @@ -41,11 +41,10 @@ #' } #' \item{`ppc_ecdf_overlay()`, `ppc_dens_overlay()`, #' `ppc_ecdf_overlay_grouped()`, `ppc_dens_overlay_grouped()`}{ -#' Kernel density or empirical CDF estimates of each dataset (row) in -#' `yrep` are overlaid, with the distribution of `y` itself on top -#' (and in a darker shade). `ppc_ecdf_overlay()` uses step functions, -#' consistent with the mathematical definition of the ECDF. -#' For an example of `ppc_dens_overlay()` also see Gabry et al. (2019). +#' Kernel density or empirical CDF estimates of each dataset (row) in `yrep` +#' are overlaid, with the distribution of `y` itself on top (and in a darker +#' shade). For an example of `ppc_dens_overlay()` also see Gabry et al. +#' (2019). #' } #' \item{`ppc_violin_grouped()`}{ #' The density estimate of `yrep` within each level of a grouping @@ -85,7 +84,7 @@ #' #' ppc_dens_overlay(y, yrep[1:25, ]) #' \donttest{ -#' # ppc_ecdf_overlay (always uses step functions) +#' # ppc_ecdf_overlay #' ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) #' #' # PIT-ECDF and PIT-ECDF difference plot of the PIT values of y compared to @@ -258,10 +257,9 @@ ppc_dens_overlay_grouped <- function(y, #' @export #' @rdname PPC-distributions -#' @param discrete -#' `r lifecycle::badge("deprecated")` The `discrete` argument is -#' deprecated. The ECDF is a step function by definition, so `geom_step()` -#' is now always used. +#' @param discrete `r lifecycle::badge("deprecated")` The `discrete` argument is +#' deprecated. The ECDF is a step function by definition, so `geom_step()` is +#' now always used. #' @param pad A logical scalar passed to [ggplot2::stat_ecdf()]. #' ppc_ecdf_overlay <- function(y, diff --git a/man/PPC-distributions.Rd b/man/PPC-distributions.Rd index f2109bd83..b02cc26cf 100644 --- a/man/PPC-distributions.Rd +++ b/man/PPC-distributions.Rd @@ -175,8 +175,8 @@ default kernel density estimation parameters or truncate the density support. \code{n_dens} defaults to \code{1024}.} \item{discrete}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} The \code{discrete} argument is -deprecated. The ECDF is a step function by definition, so \code{geom_step()} -is now always used.} +deprecated. The ECDF is a step function by definition, so \code{geom_step()} is +now always used.} \item{pad}{A logical scalar passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}.} @@ -282,11 +282,10 @@ variable for \code{y} and each dataset (row) in \code{yrep}. For this plot } \item{\code{ppc_ecdf_overlay()}, \code{ppc_dens_overlay()}, \code{ppc_ecdf_overlay_grouped()}, \code{ppc_dens_overlay_grouped()}}{ -Kernel density or empirical CDF estimates of each dataset (row) in -\code{yrep} are overlaid, with the distribution of \code{y} itself on top -(and in a darker shade). \code{ppc_ecdf_overlay()} uses step functions, -consistent with the mathematical definition of the ECDF. -For an example of \code{ppc_dens_overlay()} also see Gabry et al. (2019). +Kernel density or empirical CDF estimates of each dataset (row) in \code{yrep} +are overlaid, with the distribution of \code{y} itself on top (and in a darker +shade). For an example of \code{ppc_dens_overlay()} also see Gabry et al. +(2019). } \item{\code{ppc_violin_grouped()}}{ The density estimate of \code{yrep} within each level of a grouping @@ -322,7 +321,7 @@ dim(yrep) ppc_dens_overlay(y, yrep[1:25, ]) \donttest{ -# ppc_ecdf_overlay (always uses step functions) +# ppc_ecdf_overlay ppc_ecdf_overlay(y, yrep[sample(nrow(yrep), 25), ]) # PIT-ECDF and PIT-ECDF difference plot of the PIT values of y compared to diff --git a/man/PPD-distributions.Rd b/man/PPD-distributions.Rd index 236cf5350..7517ec254 100644 --- a/man/PPD-distributions.Rd +++ b/man/PPD-distributions.Rd @@ -90,8 +90,8 @@ default kernel density estimation parameters or truncate the density support. \code{n_dens} defaults to \code{1024}.} \item{discrete}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} The \code{discrete} argument is -deprecated. The ECDF is a step function by definition, so \code{geom_step()} -is now always used.} +deprecated. The ECDF is a step function by definition, so \code{geom_step()} is +now always used.} \item{pad}{A logical scalar passed to \code{\link[ggplot2:stat_ecdf]{ggplot2::stat_ecdf()}}.} diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index 23e5769ff..6a3635778 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -50,6 +50,22 @@ test_that("ppc_ecdf_overlay returns a ggplot object", { expect_gg(ppd_ecdf_overlay(yrep2)) }) +test_that("ppc_ecdf_overlay discrete argument is deprecated", { + lifecycle::expect_deprecated( + ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2, discrete = TRUE) + ) + lifecycle::expect_deprecated( + ppc_ecdf_overlay_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2, discrete = TRUE) + ) + lifecycle::expect_deprecated( + ppd_ecdf_overlay(vdiff_yrep2, discrete = TRUE) + ) + + # no warning when discrete is not supplied + expect_no_warning(ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2)) + expect_no_warning(ppd_ecdf_overlay(vdiff_yrep2)) +}) + test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", { expect_gg(ppc_hist(y, yrep[1,, drop = FALSE], binwidth = 0.1)) expect_gg(ppc_hist(y, yrep[1:8, ], binwidth = 0.1)) @@ -392,22 +408,6 @@ test_that("ppc_ecdf_overlay_grouped renders correctly", { ) }) -test_that("ppc_ecdf_overlay discrete argument is deprecated", { - lifecycle::expect_deprecated( - ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2, discrete = TRUE) - ) - lifecycle::expect_deprecated( - ppc_ecdf_overlay_grouped(vdiff_y2, vdiff_yrep2, vdiff_group2, discrete = TRUE) - ) - lifecycle::expect_deprecated( - ppd_ecdf_overlay(vdiff_yrep2, discrete = TRUE) - ) - - # no warning when discrete is not supplied - expect_no_warning(ppc_ecdf_overlay(vdiff_y2, vdiff_yrep2)) - expect_no_warning(ppd_ecdf_overlay(vdiff_yrep2)) -}) - test_that("ppc_dens renders correctly", { testthat::skip_on_cran() testthat::skip_if_not_installed("vdiffr") From c76560e003b8b95cef82f4d18daecace710ca86e Mon Sep 17 00:00:00 2001 From: jgabry Date: Wed, 8 Apr 2026 16:08:53 -0600 Subject: [PATCH 5/5] Add visual test for ppd_ecdf_overlay --- .../ppd-ecdf-overlay-default.svg | 63 +++++++++++++++++++ tests/testthat/test-ppc-distributions.R | 9 +++ 2 files changed, 72 insertions(+) create mode 100644 tests/testthat/_snaps/ppc-distributions/ppd-ecdf-overlay-default.svg diff --git a/tests/testthat/_snaps/ppc-distributions/ppd-ecdf-overlay-default.svg b/tests/testthat/_snaps/ppc-distributions/ppd-ecdf-overlay-default.svg new file mode 100644 index 000000000..4dff5a697 --- /dev/null +++ b/tests/testthat/_snaps/ppc-distributions/ppd-ecdf-overlay-default.svg @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.0 +0.5 +1.0 + + + + + + + + + +0 +1 +2 +3 +4 +ppd_ecdf_overlay (default) + + diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index 6a3635778..0bab48206 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -408,6 +408,15 @@ test_that("ppc_ecdf_overlay_grouped renders correctly", { ) }) +test_that("ppd_ecdf_overlay renders correctly", { + testthat::skip_on_cran() + testthat::skip_if_not_installed("vdiffr") + skip_on_r_oldrel() + + p_base <- ppd_ecdf_overlay(vdiff_yrep2) + vdiffr::expect_doppelganger("ppd_ecdf_overlay (default)", p_base) +}) + test_that("ppc_dens renders correctly", { testthat::skip_on_cran() testthat::skip_if_not_installed("vdiffr")