Skip to content

BUG: raise NotImplementedError for da.quantile with weights on NumPy < 2.0 - #12370

Merged
crusaderky merged 2 commits into
dask:mainfrom
mitre88:fix-issue-12322-quantile-weights
May 7, 2026
Merged

crusaderky merged 2 commits into
dask:mainfrom
mitre88:fix-issue-12322-quantile-weights

Conversation

@mitre88

@mitre88 mitre88 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix ValueError when passing weights to da.quantile on NumPy < 2.0.

Problem

When weights were passed to da.quantile on NumPy < 2.0, the weights argument was silently ignored because:

  • NUMPY_GE_200 is False, so kwargs = {}
  • The weights were never forwarded to np.quantile
  • This caused incorrect results with a confusing error message

Solution

Raise a clear NotImplementedError when weights is provided and NumPy version is < 2.0, explaining that weights support requires NumPy >= 2.0.

Example

import dask.array as da
import numpy as np

x = np.random.random((10, 4))
weights = np.ones(10)

# Before fix: confusing ValueError about shape mismatch
# After fix: clear NotImplementedError explaining NumPy >= 2.0 requirement
da.quantile(da.from_array(x), weights=weights, q=0.5, axis=0)
# NotImplementedError: da.quantile with weights requires NumPy >= 2.0

Fixes #12322

…< 2.0

When weights are passed to da.quantile on NumPy < 2.0, the weights
argument was silently ignored since kwargs was empty. This caused
incorrect results that were hard to debug.

The fix raises a clear NotImplementedError when weights are provided
and NumPy version is < 2.0, explaining that weights support requires
NumPy >= 2.0.

Fixes dask#12322
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

     20 files  ±0       20 suites  ±0   4h 57m 45s ⏱️ - 11m 37s
 18 295 tests ±0   17 011 ✅ ±0   1 272 💤 ±0  12 ❌ ±0 
299 528 runs  ±0  257 307 ✅ +3  42 209 💤  - 3  12 ❌ ±0 

For more details on these failures, see this check.

Results for commit e93359d. ± Comparison against base commit af302b2.

@crusaderky crusaderky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could you add a unit test for the use case?

@crusaderky crusaderky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On second though, nevermind. We hope to clear up numpy 1.x soon hopefully.

@crusaderky
crusaderky merged commit 38085eb into dask:main May 7, 2026
23 of 24 checks passed
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.

da.quantile with weights fails

2 participants