Accept posterior::draws objects in PPC/PPD functions#543
Merged
jgabry merged 4 commits intostan-dev:masterfrom Apr 15, 2026
Merged
Accept posterior::draws objects in PPC/PPD functions#543jgabry merged 4 commits intostan-dev:masterfrom
jgabry merged 4 commits intostan-dev:masterfrom
Conversation
validate_predictions() now coerces posterior::draws objects (draws_matrix, draws_array, draws_df, draws_rvars) to a plain matrix before validation, matching the pattern already used by prepare_mcmc_array() on the MCMC side. This lets users pass draws objects directly to ppc_* and ppd_* functions without manually calling as.matrix() first.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #543 +/- ##
=======================================
Coverage 99.15% 99.15%
=======================================
Files 35 35
Lines 5920 5923 +3
=======================================
+ Hits 5870 5873 +3
Misses 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Thanks! Yes we should allow posterior::draws objects. I'll try to review this later, I'm a bit short on time right this moment. |
jgabry
requested changes
Apr 15, 2026
Member
There was a problem hiding this comment.
I ended up having a moment to look at this now. Thanks for this. Just one change to make: I think the documentation for the yrep argument should be updated in man-roxygen/args-y-yrep.R.
I made some updates to the tests to make them more directly test what we care about. Otherwise this looks good aside from updating the doc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #542
Summary
validate_predictions()now checks forposterior::drawsobjects and coerces them to a plain matrix before the existing validation logic runsprepare_mcmc_array()already does on the MCMC side, so PPC/PPD functions now accept the same input formats as MCMC functionsppc_*andppd_*functions benefit since they all go throughvalidate_predictions()Changes
R/helpers-ppc.R: added aposterior::is_draws()check at the top ofvalidate_predictions(), coercing viaas_draws_matrix()+unclass()tests/testthat/test-helpers-ppc.R: added tests fordraws_matrix,draws_array,draws_df, anddraws_rvarsinputs, plus end-to-end tests withppc_dens_overlay,ppc_hist, andppc_statTest plan
drawsformats