Skip to content

Make sequential cumsum match NumPy accumulation order - #12406

Open
puneetdixit200 wants to merge 4 commits into
dask:mainfrom
puneetdixit200:exact-sequential-cumsum
Open

puneetdixit200 wants to merge 4 commits into
dask:mainfrom
puneetdixit200:exact-sequential-cumsum

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary

  • make the sequential cumulative-reduction path seed each later chunk with the previous cumulative value before scanning the chunk
  • preserve masked-array masks while using the prior cumulative data value for the seed
  • add a regression test that checks chunked cumsum matches NumPy's accumulation order exactly

Tests

  • .venv\Scripts\python -m pytest dask\array\tests\test_reductions.py -q
  • .venv\Scripts\python -m pytest dask\array\tests\test_array_core.py -k "cumulative" -q
  • .venv\Scripts\python -m pytest dask\array\tests\test_masked.py -k "cumulative" -q
  • .venv\Scripts\python -m ruff check dask\array\reductions.py dask\array\tests\test_reductions.py
  • git diff --check

AI assistance was used for code and test iteration. I reviewed the changes and take responsibility for the contribution.

@github-actions

github-actions Bot commented May 21, 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.

     24 files  +     4       24 suites  +4   6h 21m 36s ⏱️ + 52m 18s
 18 291 tests  -     11   17 027 ✅ +    13   1 264 💤  -     7  0 ❌  - 17 
372 007 runs  +72 367  324 733 ✅ +67 170  47 274 💤 +5 238  0 ❌  - 41 

Results for commit 9984f54. ± Comparison against base commit ac04b15.

This pull request removes 13 and adds 2 tests. Note that renamed tests count towards both.
dask.tests.test_ci ‑ test_upstream_packages_installed
dask.tests.test_docs ‑ test_development_guidelines_matches_ci[.github/workflows/additional.yml]
dask.tests.test_docs ‑ test_development_guidelines_matches_ci[.github/workflows/upstream.yml]
dask.tests.test_docs ‑ test_development_guidelines_matches_ci[docs/source/develop.rst]
dask.tests.test_spark_compat ‑ test_read_decimal_dtype_pyarrow
dask.tests.test_spark_compat ‑ test_roundtrip_hive_parquet_spark_to_dask[pyarrow]
dask.tests.test_spark_compat ‑ test_roundtrip_parquet_dask_to_spark[pyarrow-10]
dask.tests.test_spark_compat ‑ test_roundtrip_parquet_dask_to_spark[pyarrow-1]
dask.tests.test_spark_compat ‑ test_roundtrip_parquet_dask_to_spark[pyarrow-5]
dask.tests.test_spark_compat ‑ test_roundtrip_parquet_spark_to_dask[pyarrow-10]
…
dask.array.tests.test_reductions ‑ test_array_sequential_cumsum_matches_numpy_order
dask.tests.test_docs ‑ test_development_guidelines_matches_ci
This pull request skips 3 tests.
dask.dataframe.tests.test_dataframe ‑ test_cumulative_empty_partitions[func2]
dask.dataframe.tests.test_dataframe ‑ test_cumulative_empty_partitions[func3]
dask.tests.test_utils ‑ test_funcname_multipledispatch

♻️ This comment has been updated with latest results.

Comment thread dask/array/tests/test_reductions.py Resolved
Comment thread dask/array/tests/test_reductions.py Resolved
Comment thread dask/cli.py Resolved
@puneetdixit200
puneetdixit200 force-pushed the exact-sequential-cumsum branch from 9984f54 to 1605bbc Compare May 23, 2026 16:31
@puneetdixit200

Copy link
Copy Markdown
Author

The current head addresses the review comments:

  • the regression input now uses values with a large leading term so accumulation order matters
  • the test uses assert_eq
  • the unrelated dask/cli.py change was reverted

The remaining red checks I can see are not from the array change: py314t test-ci failed during checkout/fetch with fatal: could not read Username for 'https://github.com': terminal prompts disabled, and upstream nightly is a separate upstream-dependency lane.

@crusaderky crusaderky mentioned this pull request Jun 5, 2026
1 task
@github-actions github-actions Bot added the needs attention It's been a while since this was pushed on. Needs attention from the owner or a maintainer. label Jun 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs attention It's been a while since this was pushed on. Needs attention from the owner or a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'cumsum' results differ from 'cumsum' on a pure numpy array

2 participants