Skip to content

docs: add summary lines to 10 type/validity operation docstrings#4135

Open
TaiSakuma wants to merge 4 commits into
scikit-hep:mainfrom
TaiSakuma:docs-type-validity-docstrings
Open

docs: add summary lines to 10 type/validity operation docstrings#4135
TaiSakuma wants to merge 4 commits into
scikit-hep:mainfrom
TaiSakuma:docs-type-validity-docstrings

Conversation

@TaiSakuma

Copy link
Copy Markdown
Member

Summary

Rolls the pilot from #3946 out to the 10 operations in the Type / validity / equality batch of #3980:

almost_equal, array_equal, is_valid, validity_error, is_categorical, is_tuple, categories, enforce_type, values_astype, strings_astype.

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.almost_equal Returns True if two arrays are equal within the given tolerances and options.
ak.array_equal Returns True if two arrays have the same shape and elements.
ak.is_valid Returns True if the array has no structural errors and False otherwise.
ak.validity_error Returns an error message if the array has a structural error, or empty if valid.
ak.is_categorical Returns True if the array is categorical.
ak.is_tuple Returns True if a record, or the outermost record of an array, is a tuple.
ak.categories Returns the categories of a categorical array.
ak.enforce_type Returns an array whose structure is modified to match the given type.
ak.values_astype Converts all numbers in the array to a new type, leaving the structure untouched.
ak.strings_astype Converts all strings in the array to a new type, leaving the structure untouched.

Notes for reviewers

  • ak.enforce_type's body is one continuous bulleted explanation, so everything sits under a single Returns: header (the ak.concatenate model — no Examples: split that would break the prose). Its doctests are nested inside bullets and were uniformly re-indented by 4 spaces with the bullets; content is byte-identical.
  • ak.array_equal delegates to almost_equal with exact settings, so its summary carries no tolerance language, distinguishing the pair.
  • Pre-existing issues left verbatim (out of scope here): ak.values_astype has a malformed doctest output in main (datetime64[ms]['), and ak.strings_astype's "See also #ak.numbers_astype" references a non-existent operation.

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 13, 2026
@codecov

codecov Bot commented Jun 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.03%. Comparing base (c4aab45) to head (76b7e4c).

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/operations/ak_almost_equal.py 96.36% <ø> (ø)
src/awkward/operations/ak_array_equal.py 100.00% <ø> (ø)
src/awkward/operations/ak_categories.py 100.00% <ø> (ø)
src/awkward/operations/ak_enforce_type.py 83.16% <ø> (ø)
src/awkward/operations/ak_is_categorical.py 100.00% <ø> (ø)
src/awkward/operations/ak_is_tuple.py 100.00% <ø> (ø)
src/awkward/operations/ak_is_valid.py 100.00% <ø> (ø)
src/awkward/operations/ak_strings_astype.py 100.00% <ø> (ø)
src/awkward/operations/ak_validity_error.py 92.85% <ø> (ø)
src/awkward/operations/ak_values_astype.py 100.00% <ø> (ø)

@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.almost_equal True if the two array-like arguments are equal within the given options and tolerances, False otherwise.
ak.array_equal True if two arrays have the same shape and elements, False otherwise.
ak.is_valid True if array has no structural errors, False otherwise.
ak.validity_error An empty string if array is valid, or a string describing the structural error otherwise.
ak.is_categorical True if array is categorical, False otherwise.
ak.is_tuple True if array (or its outermost record) is a tuple, False otherwise.
ak.categories The distinct category values of array (if it is categorical).
ak.enforce_type An array whose structure is modified to match the given type.
ak.values_astype An array with every number converted to the given to type, leaving the structure untouched.
ak.strings_astype An array with every string converted to the given to type, leaving the structure untouched.

@TaiSakuma
TaiSakuma force-pushed the docs-type-validity-docstrings branch from a755000 to b0e8b61 Compare June 30, 2026 22:45
@TaiSakuma
TaiSakuma marked this pull request as ready for review June 30, 2026 22:54
@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/PR4135

@TaiSakuma
TaiSakuma requested a review from ianna July 10, 2026 18:51
TaiSakuma and others added 4 commits July 23, 2026 09:52
Add a Google-style one-line summary and `Returns:`/`Examples:` section
headers to the 10 type/validity/equality operations in
`src/awkward/operations/`: almost_equal, array_equal, is_valid,
validity_error, is_categorical, is_tuple, categories, enforce_type,
values_astype, strings_astype.

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>
Per the Examples:-section checklist on scikit-hep#3980: narrative that describes
behavior, arguments, or history belongs above Args: in the extended
description; Examples: keeps only doctest walkthroughs and their
connecting prose; "See also" lines go directly above Args:.

Refs scikit-hep#3980.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@TaiSakuma
TaiSakuma force-pushed the docs-type-validity-docstrings branch from b0e8b61 to 76b7e4c Compare July 23, 2026 14:01
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