-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Open
Labels
Description
Describe the issue:
For empty inputs (size=0), quantile yields an Index error:
>> np.quantile([], 0.5)
IndexError: index -1 is out of bounds for axis 0 with size 0
While median yields np.float64(nan)
(with warnings):
>> np.median([])
np.float64(nan)
The See also
section, suggests np.quantile(..., 0.5) == np.median(...)
, else I find no information on the case size=0, or any mention of raised errors.
The behavior of median is consistent with mean, which follows the specification of https://data-apis.org/array-api/latest/API_specification/generated/array_api.mean.html.
I would expect quantile to return NaN for empty arrays.
Reproduce the code example:
import numpy as np
np.quantil([], 0.5)
Error message:
Python and NumPy Versions:
2.2.6
3.12.6 | packaged by conda-forge | (main, Sep 30 2024, 18:08:52) [GCC 13.3.0]
Runtime Environment:
No response
Context for the issue:
No response