Skip to content

Conversation

@galio1237
Copy link

BUG: Raise error in quantile when weights sum to zero

Added a check in np.quantile to raise a ValueError when the weights parameter are all zero, preventing invalid computations. Added corresponding tests to verify this behavior.

Closes #28589.

@galio1237
Copy link
Author

Hello,

I'm a new contributor to this project and have submitted this pull request to address [Issue #28589].

However, I noticed that some of the status checks are failing. I've reviewed the output but am unsure how to resolve these issues. Could someone please provide guidance on the reasons for these failures and suggest steps to address them?

Thank you for your assistance.

with pytest.raises(ValueError, match="Weights must contain non-zero value."):
np.quantile(y, 0.5, weights=w, method="inverted_cdf")


Copy link
Contributor

Choose a reason for hiding this comment

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

Could someone please provide guidance on the reasons for these failures and suggest steps to address them?

You can reproduce the linter failure observed in CI locally by running spin lint on your branch. Purging the extra blank line it complains about will allow spin lint to pass locally and in CI. I checked the full test suite locally on this branch and it seems "ok."

The Qemu job failure in CI is clearly unrelated so don't worry about that.

For bug fixes, we usually prefix commits and titles of PRs with BUG:. You can find the list of prefixes in our docs.

Note for other NumPy devs--gh-28594 is very similar to this.

@seberg
Copy link
Member

seberg commented Dec 19, 2025

Thanks, but this was addressed in gh-28595, which was opened the same day I think...

@seberg seberg closed this Dec 19, 2025
@github-project-automation github-project-automation bot moved this from Pending authors' response to Completed in NumPy first-time contributor PRs Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

BUG: quantile should error when weights are all zeros

4 participants