Skip to content

DOC: Improve coarsen docstring with detailed reduction requirements#12236

Open
VedantMadane wants to merge 1 commit intodask:mainfrom
VedantMadane:docs-coarsen-docstring
Open

DOC: Improve coarsen docstring with detailed reduction requirements#12236
VedantMadane wants to merge 1 commit intodask:mainfrom
VedantMadane:docs-coarsen-docstring

Conversation

@VedantMadane
Copy link

Summary

Improves the docstring for dask.array.coarsen by providing detailed documentation of the reduction function requirements.

Changes

  • Clarify that the reduction function must:
    • Accept an array as the first positional argument (matching the chunk array type)
    • Accept an axis keyword argument with a tuple of integer axes
    • Return an array of the same type as the input
  • Document the trim_excess parameter
  • Document that **kwargs are passed to the reduction function
  • Add a Returns section

Motivation

As noted in the issue, the original docstring only said 'Function like np.sum, np.mean, etc...' which doesn't clearly explain what properties a reduction function needs to have.

Closes #9825

@github-actions
Copy link
Contributor

github-actions bot commented Jan 16, 2026

Unit Test Results

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

     21 files  ±0       21 suites  ±0   5h 13m 31s ⏱️ + 8m 50s
 18 283 tests ±0   17 008 ✅ ±0   1 274 💤 ±0  1 ❌ ±0 
294 770 runs  ±0  252 433 ✅ ±0  42 336 💤 ±0  1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 979a2a7. ± Comparison against base commit e5a9087.

♻️ This comment has been updated with latest results.

Clarify the requirements for the reduction function parameter: must accept an array as the first argument, must accept an axis keyword argument with a tuple of axes, must return an array of the same type. Also document trim_excess, kwargs, and return value.

Closes dask#9825
@VedantMadane VedantMadane force-pushed the docs-coarsen-docstring branch from e9c4423 to 979a2a7 Compare February 10, 2026 11:12
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.

Docstring of dask.array.coarsen should provide more details on valid reduction functions

1 participant