Skip to content

Validate user-provided pit at the entry point#504

Open
utkarshpawade wants to merge 10 commits intostan-dev:masterfrom
utkarshpawade:fix/kde-correction-empty-vector
Open

Validate user-provided pit at the entry point#504
utkarshpawade wants to merge 10 commits intostan-dev:masterfrom
utkarshpawade:fix/kde-correction-empty-vector

Conversation

@utkarshpawade
Copy link
Copy Markdown
Contributor

@utkarshpawade utkarshpawade commented Mar 23, 2026

Fixes #503

Summary

Validates user provided pit argument immediately when it is provided

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.66%. Comparing base (471afa8) to head (90c1121).

Files with missing lines Patch % Lines
R/ppc-loo.R 75.00% 1 Missing ⚠️
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.
📢 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.

@florence-bockting
Copy link
Copy Markdown

florence-bockting commented Mar 25, 2026

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.

@jgabry jgabry changed the title Fix .kde_correction() crash on empty vector after removing infinite PIT values Validate user-provided pit at the entry point Mar 26, 2026
R/ppc-loo.R Outdated

xs <- (grid_breaks[2:n_breaks] + grid_breaks[1:(n_breaks - 1)]) / 2

if (all(is.na(bc_pvals))) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
* 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]`.

Copilot AI review requested due to automatic review settings April 1, 2026 05:56
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

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 pit at the start of ppc_loo_pit_data() and ppc_loo_pit_qq() via validate_pit().
  • Update unit tests to assert errors for invalid user-provided pit values.
  • Modify .kde_correction() by removing the prior infinite-value filtering and adding an abort when the convolution result is entirely NA.

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.

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.

Validate user-provided pit at the entry point

5 participants