Skip to content

docs: add summary lines to 13 to_* file/format converter docstrings#4139

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

docs: add summary lines to 13 to_* file/format converter docstrings#4139
TaiSakuma wants to merge 4 commits into
scikit-hep:mainfrom
TaiSakuma:docs-to-formats-docstrings

Conversation

@TaiSakuma

Copy link
Copy Markdown
Member

Summary

Rolls the pilot from #3946 out to the 13 operations in the to_* file/format converters batch of #3980:

to_arrow, to_arrow_table, to_parquet, to_parquet_dataset, to_parquet_row_groups, metadata_from_parquet, to_feather, to_json, to_safetensors, to_buffers, to_packed, to_regular, to_backend.

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_arrow Converts an Awkward Array into an Apache Arrow array.
ak.to_arrow_table Converts an Awkward Array into an Apache Arrow table.
ak.to_parquet Writes an Awkward Array to a Parquet file (through pyarrow).
ak.to_parquet_dataset Creates a _common_metadata and a _metadata in a directory of Parquet files.
ak.to_parquet_row_groups Writes a sequence of Awkward Arrays to a Parquet file as row groups.
ak.metadata_from_parquet Reads metadata from a Parquet file or dataset without reading the data.
ak.to_feather Writes an Awkward Array to a Feather file (through pyarrow).
ak.to_json Converts an Awkward Array into JSON text, as a string or to a file.
ak.to_safetensors Writes an Awkward Array to a safetensors file.
ak.to_buffers Decomposes an Awkward Array into a Form, length, and memory buffers.
ak.to_packed Packs an array's inner structure and materializes its virtual buffers.
ak.to_regular Converts one or all variable-length axes into regular ones, if possible.
ak.to_backend Returns an array on a different backend (kernel set).

Notes for reviewers

  • to_parquet, to_parquet_row_groups, and to_safetensors had pre-existing (malformed) Returns: headers mid-docstring; they were merged into the standard structure with doctests grouped under Examples:. Content was regrouped but mechanically verified lossless.
  • ak.to_regular reads "one or all variable-length axes … if possible" to cover axis=None, mirroring from_regular in the sibling PR. to_buffers/from_buffers are likewise mirrored ("Decomposes…"/"Reconstitutes… a Form, length, and memory buffers").
  • ak.to_backend reads "Returns an array on a different backend (kernel set)." — avoiding "moves"/"converts" language that would contradict the body's viewed-not-copied note.
  • ak.to_parquet_dataset keeps backticks on _common_metadata/_metadata — they are literal filenames (the checklist's meaning-bearing exception).
  • Pre-existing, out of scope: to_json's body says it returns "bytes" (it returns str; the summary says "string"), and metadata_from_parquet's body omits the returned uuid key.
  • Non-exported helpers write_metadata and get_filepaths are untouched.

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 83.74%. Comparing base (722a1b9) to head (3354226).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
Files with missing lines Coverage Δ
src/awkward/operations/ak_metadata_from_parquet.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_arrow.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_arrow_table.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_backend.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_buffers.py 93.75% <ø> (ø)
src/awkward/operations/ak_to_feather.py 83.33% <ø> (ø)
src/awkward/operations/ak_to_json.py 86.25% <ø> (ø)
src/awkward/operations/ak_to_packed.py 100.00% <ø> (ø)
src/awkward/operations/ak_to_parquet.py 65.71% <ø> (ø)
src/awkward/operations/ak_to_parquet_dataset.py 83.01% <ø> (ø)
... and 3 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.to_arrow An Apache Arrow array (pyarrow.Array) with the same data as array.
ak.to_arrow_table An Apache Arrow table (pyarrow.Table) with the same data as array.
ak.to_parquet A pyarrow._parquet.FileMetaData describing the written Parquet file.
ak.to_parquet_dataset A 2-tuple (common_metadata_path, metadata_path) with the paths to the _common_metadata and _metadata files created in the given directory of Parquet files.
ak.to_parquet_row_groups A pyarrow._parquet.FileMetaData describing the written Parquet file.
ak.metadata_from_parquet A dict of metadata describing the Parquet dataset (its form, filesystem, paths, row counts, and columns), read without reading the array data.
ak.to_feather None.
ak.to_json The JSON text as bytes when file is None; otherwise None, and the JSON is written to file.
ak.to_safetensors None.
ak.to_buffers A 3-tuple (form, length, container) decomposed from array, so that data can be losslessly written to file formats and storage devices that only map names to binary blobs (such as a filesystem directory).
ak.to_packed An array with the same type and values as the input, with all virtual buffers materialized (see #ak.materialize) and inner structures packed.
ak.to_regular An array with one or all variable-length axes converted to regular axes, if possible.
ak.to_backend An array with the same data as the input, moved to the requested backend (kernel set).

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 13 to_* file/format converters in
`src/awkward/operations/`: to_arrow, to_arrow_table, to_parquet,
to_parquet_dataset, to_parquet_row_groups, metadata_from_parquet,
to_feather, to_json, to_safetensors, to_buffers, to_packed, to_regular,
to_backend.

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-to-formats-docstrings branch from 39bb46f to c3fc938 Compare June 30, 2026 22:47
@TaiSakuma TaiSakuma marked this pull request as ready for review June 30, 2026 22:54
.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@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/PR4139

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