Validate user-provided pit at the entry point#504
Validate user-provided pit at the entry point#504utkarshpawade wants to merge 10 commits intostan-dev:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #504 +/- ##
==========================================
- Coverage 98.67% 98.66% -0.02%
==========================================
Files 35 35
Lines 5903 5899 -4
==========================================
- Hits 5825 5820 -5
- Misses 78 79 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi @utkarshpawade, thanks for the PR. I provided a small discussion about your observation in the corresponding Issue. Probably you could adjust the PR accordingly. |
R/ppc-loo.R
Outdated
|
|
||
| xs <- (grid_breaks[2:n_breaks] + grid_breaks[1:(n_breaks - 1)]) / 2 | ||
|
|
||
| if (all(is.na(bc_pvals))) { |
There was a problem hiding this comment.
Can you move this up a few lines to right after bc_pvals is created? Or is there a reason it comes after n_breaks and xs are computed?
NEWS.md
Outdated
| @@ -1,5 +1,6 @@ | |||
| # bayesplot (development version) | |||
|
|
|||
| * Validate user-provided `pit` values in `ppc_loo_pit_data()` using `validate_pit()` to reject invalid inputs (non-numeric, out of range, NAs) at the entry point instead of in internal helpers. | |||
There was a problem hiding this comment.
| * Validate user-provided `pit` values in `ppc_loo_pit_data()` using `validate_pit()` to reject invalid inputs (non-numeric, out of range, NAs) at the entry point instead of in internal helpers. | |
| * Validate user-provided `pit` values in `ppc_loo_pit_data()` and `ppc_loo_pit_qq()`, rejecting non-numeric inputs, missing values, and values outside `[0, 1]`. |
There was a problem hiding this comment.
Pull request overview
This PR addresses #503 by moving validation of user-supplied LOO-PIT (pit) inputs earlier in the ppc_loo_* pipeline to prevent downstream failures during boundary-corrected KDE processing.
Changes:
- Validate user-provided
pitat the start ofppc_loo_pit_data()andppc_loo_pit_qq()viavalidate_pit(). - Update unit tests to assert errors for invalid user-provided
pitvalues. - Modify
.kde_correction()by removing the prior infinite-value filtering and adding an abort when the convolution result is entirelyNA.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
R/ppc-loo.R |
Routes user-supplied pit through validate_pit() and adjusts .kde_correction() failure handling. |
tests/testthat/test-ppc-loo.R |
Replaces .kde_correction() warning test with entry-point validation error tests for ppc_loo_pit_data() / ppc_loo_pit_qq(). |
NEWS.md |
Documents the new pit validation behavior for ppc_loo_pit_data() and ppc_loo_pit_qq(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #503
Summary
Validates user provided
pitargument immediately when it is provided