Skip to content

Allow NAs in prepare_mcmc_array#539

Open
utkarshpawade wants to merge 1 commit intostan-dev:masterfrom
utkarshpawade:fix/allow-nas-prepare-mcmc-array-250
Open

Allow NAs in prepare_mcmc_array#539
utkarshpawade wants to merge 1 commit intostan-dev:masterfrom
utkarshpawade:fix/allow-nas-prepare-mcmc-array-250

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

Fixes #250
prepare_mcmc_array() previously aborted on any NA in the input, blocking plotting workflows where parameters are stored as ragged arrays padded with NA (common with cmdstanr draws). The hard error is demoted to a warning so plots like mcmc_trace, mcmc_dens, etc. work directly on such inputs. Stricter NA checks elsewhere (helpers-ppc.R validators, drop_NAs_and_warn in diagnostics) are left intact, those guard summary computations where silently dropping NAs would mislead.

Changes

  • R/helpers-mcmc.R: abort()warn() on anyNA(x).
  • tests/testthat/test-helpers-mcmc.R: updated test to assert the warning and successful return.

Copilot AI review requested due to automatic review settings April 13, 2026 10:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in prepare_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-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.15%. Comparing base (44c3e5c) to head (1f3d4ce).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@utkarshpawade utkarshpawade force-pushed the fix/allow-nas-prepare-mcmc-array-250 branch from 6323413 to 1f3d4ce Compare April 13, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Requiring no NAs in prepare_mcmc_array

3 participants