Skip to content

docs: add summary lines to 11 to_* array-library converter docstrings#4138

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

docs: add summary lines to 11 to_* array-library converter docstrings#4138
TaiSakuma wants to merge 3 commits into
scikit-hep:mainfrom
TaiSakuma:docs-to-arraylib-docstrings

Conversation

@TaiSakuma

Copy link
Copy Markdown
Member

Summary

Rolls the pilot from #3946 out to the 11 operations in the to_* array-library converters batch of #3980:

to_numpy, to_cupy, to_jax, to_torch, to_tensorflow, to_cudf, to_raggedtensor, to_list, to_layout, to_dataframe, to_rdataframe.

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.to_numpy Converts an Awkward Array into a NumPy array, if possible.
ak.to_cupy Converts an Awkward Array into a CuPy array, if possible.
ak.to_jax Converts an Awkward Array into a JAX Array, if possible.
ak.to_torch Converts an Awkward Array into a PyTorch Tensor, if possible.
ak.to_tensorflow Converts an Awkward Array into a TensorFlow Tensor, if possible.
ak.to_cudf Converts an Awkward Array into a cuDF Series.
ak.to_raggedtensor Converts an Awkward Array into a TensorFlow RaggedTensor, if possible.
ak.to_list Converts an Awkward Array into Python objects.
ak.to_layout Converts data into a low-level layout object.
ak.to_dataframe Converts an Awkward Array into a pandas DataFrame.
ak.to_rdataframe Converts an Awkward Array into ROOT RDataFrame columns.

Notes for reviewers

  • ", if possible" is applied uniformly to to_numpy/to_cupy/to_jax/to_torch/to_tensorflow/to_raggedtensor — each raises on unsupported layouts, and their bodies already say so. to_cudf deliberately omits it (its body makes no such claim; failure there is version-gated, not data-shape).
  • ak.to_layout deviates from the "Converts an Awkward Array…" register on purpose: it accepts arbitrary array-like data and returns a low-level layout.
  • ak.to_jax says "JAX Array" (the modern term); the body's "JAX Device Array" stays verbatim.

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 Sonnet 4.6, 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 Sonnet 4.6 noreply@anthropic.com

@github-actions github-actions Bot added the type/docs PR title type: docs (set automatically) label Jun 13, 2026
@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.to_numpy A NumPy array with the same data as array, if the conversion is possible.
ak.to_cupy A CuPy array with the same data as array, if the conversion is possible.
ak.to_jax A JAX array with the same data as array, if the conversion is possible.
ak.to_torch A PyTorch tensor with the same data as array, if the conversion is possible.
ak.to_tensorflow A TensorFlow Tensor with the same data as array, if the conversion is possible.
ak.to_cudf A cuDF Series with the same data as array.
ak.to_raggedtensor A TensorFlow RaggedTensor with the same data as array, if the conversion is possible.
ak.to_list The contents of array as Python objects (lists, dicts, numbers, etc.).
ak.to_layout A low-level #ak.contents.Content (or scalar) holding the data of array.
ak.to_dataframe A Pandas MultiIndex DataFrame holding the data of array.
ak.to_rdataframe A ROOT RDataFrame whose columns are the fields of array.

@codecov

codecov Bot commented Jun 19, 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 (c0c3a71).

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/operations/ak_to_cudf.py 35.00% <ø> (ø)
src/awkward/operations/ak_to_cupy.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_dataframe.py 92.20% <ø> (ø)
src/awkward/operations/ak_to_jax.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_layout.py 85.24% <ø> (ø)
src/awkward/operations/ak_to_list.py 81.25% <ø> (ø)
src/awkward/operations/ak_to_numpy.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_raggedtensor.py 21.81% <ø> (ø)
src/awkward/operations/ak_to_rdataframe.py 85.71% <ø> (ø)
src/awkward/operations/ak_to_tensorflow.py 28.12% <ø> (ø)
... and 1 more

TaiSakuma and others added 3 commits June 30, 2026 18:37
Add a Google-style one-line summary and `Returns:`/`Examples:` section
headers to the 11 to_* array-library converters in
`src/awkward/operations/`: to_numpy, to_cupy, to_jax, to_torch,
to_tensorflow, to_cudf, to_raggedtensor, to_list, to_layout,
to_dataframe, to_rdataframe.

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 Sonnet 4.6 <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-to-arraylib-docstrings branch from 44d52b2 to c0c3a71 Compare June 30, 2026 22:44
@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/PR4138

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