Description
Describe the issue:
np.quantile
with weights
being all zeros should probably give a error/warning. It's effectively like asking for a quantile of an empty array. Currently numpy seems to return the first sample.
Reproduce the code example:
np.quantile([1,2,3,4], 0.5, weights=[0,0,0,0], method='inverted_cdf')
Error message:
/.../numpy/lib/_function_base_impl.py:4858: RuntimeWarning: invalid value encountered in divide
cdf /= cdf[-1, ...] # normalization to 1
Out[9]: array(1)
Python and NumPy Versions:
2.1.3
3.13.0 | packaged by conda-forge | (main, Nov 27 2024, 19:18:50) [GCC 13.3.0]
Runtime Environment:
No response
Context for the issue:
Context: Noticed when looking into scikit-learn/scikit-learn#31032