-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
da.percentile and np.percentile can have different output shapes #11989
Copy link
Copy link
Closed
Labels
bugSomething is brokenSomething is broken
Description
Describe the issue:
It seems that da.percentile and np.percentile return arrays of different shapes. Also confusingly da.percentile and da.nanpercentile differ in their outputs (and implementations).
Found in the context of #11988.
Minimal Complete Verifiable Example:
import dask.array as da
import numpy as np
x_np = np.ones(3)
x_da = da.from_array(x_np)
np_percentile_result = np.percentile(x_np, 50) # np.array(1.)
np_nanpercentile_result = np.nanpercentile(x_np, 50) # np.array(1.)
da_percentile_result = da.percentile(x_da, 50).compute() # np.array(1.)
da_nanpercentile_result = da.nanpercentile(x_da, 50).compute() # np.array([1.])
# ok
assert np_percentile_result.shape == np_nanpercentile_result.shape
# ok
assert np_percentile_result.shape == da_nanpercentile_result.shape
# fails
assert np_percentile_result.shape == da.percentile_result.shapeAnything else we need to know?:
Environment:
- Dask version: 2025.5.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething is brokenSomething is broken