Allow NAs in prepare_mcmc_array#539
Open
utkarshpawade wants to merge 1 commit intostan-dev:masterfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates prepare_mcmc_array() to tolerate NA values (common in ragged/padded draws) so MCMC plotting workflows can proceed, while still surfacing the presence of missing values to users.
Changes:
- Demote the
anyNA(x)hard error inprepare_mcmc_array()to a warning. - Update the corresponding unit test to expect a warning and successful return.
- Add a NEWS entry documenting the behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
R/helpers-mcmc.R |
Changes prepare_mcmc_array() NA handling from aborting to warning. |
tests/testthat/test-helpers-mcmc.R |
Adjusts tests to assert warning + returned mcmc_array containing NAs. |
NEWS.md |
Documents the new warning behavior for prepare_mcmc_array(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #539 +/- ##
=======================================
Coverage 99.15% 99.15%
=======================================
Files 35 35
Lines 5920 5922 +2
=======================================
+ Hits 5870 5872 +2
Misses 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6323413 to
1f3d4ce
Compare
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.
Fixes #250
prepare_mcmc_array()previously aborted on anyNAin the input, blocking plotting workflows where parameters are stored as ragged arrays padded withNA(common with cmdstanr draws). The hard error is demoted to a warning so plots likemcmc_trace,mcmc_dens, etc. work directly on such inputs. StricterNAchecks elsewhere (helpers-ppc.Rvalidators,drop_NAs_and_warnin diagnostics) are left intact, those guard summary computations where silently droppingNAs would mislead.Changes
R/helpers-mcmc.R:abort()→warn()onanyNA(x).tests/testthat/test-helpers-mcmc.R: updated test to assert the warning and successful return.