Skip to content

docs: add summary lines to 19 reducer operation docstrings#4129

Open
TaiSakuma wants to merge 3 commits into
scikit-hep:mainfrom
TaiSakuma:docs-reducers-docstrings
Open

docs: add summary lines to 19 reducer operation docstrings#4129
TaiSakuma wants to merge 3 commits into
scikit-hep:mainfrom
TaiSakuma:docs-reducers-docstrings

Conversation

@TaiSakuma

Copy link
Copy Markdown
Member

Summary

Rolls the pilot from #3946 out to the 19 operations (28 functions, including the nan* variants) in the Reducers batch of #3980:

all, any, sum, prod, count, count_nonzero, min, max, argmin, argmax, mean, std, var, moment, corr, covar, ptp, linear_fit, softmax.

Each docstring now has:

  • A one-line summary on the opening """.
  • Returns: and Examples: section headers (the latter only where examples exist).

Original body text is preserved; only structural edits are applied. The summary lines were reviewed against the checklist posted in #3980.

Summary lines

Operation Summary
ak.all Returns whether all elements are True over one or all levels of nesting.
ak.any Returns whether any elements are True over one or all levels of nesting.
ak.sum Sums an array's elements over one or all levels of nesting.
ak.nansum Sums an array's elements, treating NaN values as missing.
ak.prod Multiplies an array's elements over one or all levels of nesting.
ak.nanprod Multiplies an array's elements, treating NaN values as missing.
ak.count Counts an array's elements over one or all levels of nesting.
ak.count_nonzero Counts an array's nonzero elements over one or all levels of nesting.
ak.min Returns the minimum value over one or all levels of nesting.
ak.nanmin Returns the minimum value, treating NaN values as missing.
ak.max Returns the maximum value over one or all levels of nesting.
ak.nanmax Returns the maximum value, treating NaN values as missing.
ak.argmin Returns the index of the minimum value over one or all levels of nesting.
ak.nanargmin Returns the index of the minimum value, treating NaN values as missing.
ak.argmax Returns the index of the maximum value over one or all levels of nesting.
ak.nanargmax Returns the index of the maximum value, treating NaN values as missing.
ak.mean Computes the mean over one or all levels of nesting.
ak.nanmean Computes the mean, treating NaN values as missing.
ak.std Computes the standard deviation over one or all levels of nesting.
ak.nanstd Computes the standard deviation, treating NaN values as missing.
ak.var Computes the variance over one or all levels of nesting.
ak.nanvar Computes the variance, treating NaN values as missing.
ak.moment Computes the nth moment over one or all levels of nesting.
ak.corr Computes the correlation of x and y over one or all levels of nesting.
ak.covar Computes the covariance of x and y over one or all levels of nesting.
ak.ptp Returns the range of values over one or all levels of nesting.
ak.linear_fit Computes the linear fit of y against x over one or all levels of nesting.
ak.softmax Computes the softmax over the innermost level of nesting.

Notes for reviewers

  • Base reducers share the tail "…over one or all levels of nesting." to cover both axis=None (scalar result) and axis=int (group-wise); nan* variants share "…, treating NaN values as missing." and keep the verbatim "Like #ak.X, but…" text in the body.
  • ak.softmax deviates deliberately ("over the innermost level of nesting"): its implementation only supports the innermost axis and raises NotImplementedError otherwise.
  • ak.argmin/ak.argmax read "Returns the index of the minimum/maximum value…"; the "…, returning integer indexes" register of ak.argcartesian did not fit the line budget with the modes tail.
  • Pre-existing issues left verbatim in the bodies (out of scope here): nanargmin's Args block documents mask_identity twice, and ak.mean's first walkthrough doctest is malformed in main (missing ... continuation prefixes).

Test plan

  • pre-commit passes locally on the modified files (ruff check, ruff format, codespell, mypy).
  • Mechanical validation: code outside docstrings byte-identical; Args: blocks and doctests byte-identical; no original narrative text lost.
  • Sphinx docs build cleanly on CI.
  • Rendered docstrings spot-checked in the docs preview.

Part of #3980. Draft for initial review; will mark ready once CI passes and the preview is checked.

AI assistance disclosure

Drafted with Claude Code: summaries drafted by Claude Opus 4.8, adversarially verified against the implementations by independent Claude Opus 4.8 agents, mechanically validated (docstring-only changes, original text preserved), and reviewed by a human before submission.

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

@github-actions github-actions Bot added the type/docs PR title type: docs (set automatically) label Jun 12, 2026
@codecov

codecov Bot commented Jun 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.74%. Comparing base (722a1b9) to head (77b358f).

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/operations/ak_all.py 96.66% <ø> (ø)
src/awkward/operations/ak_any.py 96.66% <ø> (ø)
src/awkward/operations/ak_argmax.py 94.59% <ø> (ø)
src/awkward/operations/ak_argmin.py 94.59% <ø> (ø)
src/awkward/operations/ak_corr.py 97.43% <ø> (ø)
src/awkward/operations/ak_count.py 100.00% <ø> (ø)
src/awkward/operations/ak_count_nonzero.py 96.77% <ø> (ø)
src/awkward/operations/ak_covar.py 97.05% <ø> (ø)
src/awkward/operations/ak_linear_fit.py 100.00% <ø> (ø)
src/awkward/operations/ak_max.py 94.73% <ø> (ø)
... and 9 more

@TaiSakuma

Copy link
Copy Markdown
Member Author

Follow-up per @ikrommyd's review on #4130: the Returns: sections now describe the returned object (a noun phrase) rather than restating the operation. Final Returns: lines for this batch:

Returns

Operation Returns
ak.all True in each group of elements from array (many types supported, including all Awkward Arrays and Records) if all values are True; False otherwise.
ak.any True in each group of elements from array (many types supported, including all Awkward Arrays and Records) if any values are True; False otherwise.
ak.sum The sum over array (many types supported, including all Awkward Arrays and Records).
ak.prod The product of the elements of array (many types supported, including all Awkward Arrays and Records).
ak.count The number of elements of array (many types supported, including all Awkward Arrays and Records).
ak.count_nonzero The number of nonzero elements of array (many types supported, including all Awkward Arrays and Records).
ak.min The minimum value in each group of elements from array (many types supported, including all Awkward Arrays and Records).
ak.max The maximum value in each group of elements from array (many types supported, including all Awkward Arrays and Records).
ak.argmin The index position of the minimum value in each group of elements from array (many types supported, including all Awkward Arrays and Records).
ak.argmax The index position of the maximum value in each group of elements from array (many types supported, including all Awkward Arrays and Records).
ak.mean The mean in each group of elements from x (many types supported, including all Awkward Arrays and Records).
ak.std The standard deviation in each group of elements from x (many types supported, including all Awkward Arrays and Records).
ak.var The variance in each group of elements from x (many types supported, including all Awkward Arrays and Records).
ak.moment The nth moment in each group of elements from x (many types supported, including all Awkward Arrays and Records).
ak.corr The correlation of x and y (many types supported, including all Awkward Arrays and Records, must be broadcastable to each other).
ak.covar The covariance of x and y (many types supported, including all Awkward Arrays and Records, must be broadcastable to each other).
ak.ptp The range of values in each group of elements from array (many types supported, including all Awkward Arrays and Records).
ak.linear_fit The linear fit of y with respect to x (many types supported, including all Awkward Arrays and Records, must be broadcastable to each other).
ak.softmax The softmax in each group of elements from x (many types supported, including all Awkward Arrays and Records).

TaiSakuma and others added 3 commits June 30, 2026 18:36
Add a Google-style one-line summary and `Returns:`/`Examples:` section
headers to the 19 reducer operations (28 functions, including the nan*
variants) in `src/awkward/operations/`: all, any, sum, prod, count,
count_nonzero, min, max, argmin, argmax, mean, std, var, moment, corr,
covar, ptp, linear_fit, softmax.

Follows the pilot in scikit-hep#3946 on `ak.flatten`. Original body text is
preserved; only structural edits are applied.

Refs scikit-hep#3980.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
…#3980.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tion. Refs scikit-hep#3980.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TaiSakuma TaiSakuma force-pushed the docs-reducers-docstrings branch from 57fe7ba to 77b358f Compare June 30, 2026 22:51
@TaiSakuma TaiSakuma marked this pull request as ready for review June 30, 2026 22:53
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR4129

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

Labels

type/docs PR title type: docs (set automatically)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant