Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# bayesplot (development version)

* `prepare_mcmc_array()` now warns instead of erroring on `NA`s in the input.
* `ppc_ecdf_overlay()`, `ppc_ecdf_overlay_grouped()`, and `ppd_ecdf_overlay()` now always use `geom_step()`. The `discrete` argument is deprecated.
Comment thread
utkarshpawade marked this conversation as resolved.
* Fixed missing `drop = FALSE` in `nuts_params.CmdStanMCMC()`.
* Replace `apply()` with `storage.mode()` for integer-to-numeric matrix conversion in `validate_predictions()`.
Expand Down
4 changes: 3 additions & 1 deletion R/helpers-mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ prepare_mcmc_array <- function(x,
abort("Arrays should have 2 or 3 dimensions. See help('MCMC-overview').")
}
if (anyNA(x)) {
abort("NAs not allowed in 'x'.")
warn(
"NAs were found in 'x'. `prepare_mcmc_array()` does not remove them; some plots may render with missing values dropped, while summary functions (e.g. intervals, densities, diagnostics) may produce misleading results or error. Consider removing NAs before plotting or summarizing."
)
Comment thread
jgabry marked this conversation as resolved.
}

if (rlang::is_quosures(pars)) {
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-helpers-mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,12 @@ test_that("transformations recycled properly if not a named list", {


# prepare_mcmc_array ------------------------------------------------------
test_that("prepare_mcmc_array errors if NAs", {
arr[1,1,1] <- NA
expect_error(prepare_mcmc_array(arr), "NAs not allowed")
test_that("prepare_mcmc_array warns but does not error if NAs", {
arr_na <- arr
arr_na[1,1,1] <- NA
expect_warning(out <- prepare_mcmc_array(arr_na), "NAs were found")
expect_s3_class(out, "mcmc_array")
Comment thread
utkarshpawade marked this conversation as resolved.
expect_true(anyNA(out))
})
test_that("prepare_mcmc_array processes non-array input types correctly", {
# errors are mostly covered by tests of the many internal functions above
Expand Down
Loading