docs: add summary lines to 8 missing-value operation docstrings - #4130
docs: add summary lines to 8 missing-value operation docstrings#4130TaiSakuma wants to merge 4 commits into
Conversation
ikrommyd
left a comment
There was a problem hiding this comment.
The "Returns:" statement should always describe the object it returns and not be be a statement that describes the operation which is often identical or very similar to the summary line. You need to make sure that this is the case in all such open docs PRs and there a couple of cases where this needs fixing already in main.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
|
|
Follow-up per @ikrommyd's review on #4130: the Returns
|
ikrommyd
left a comment
There was a problem hiding this comment.
I'll keep commenting here but it applies to all similar PRs. I think what we want for "Returns" is a similar to "Args" right above. A very short description that also includes the type of the output.
The longer description of what it actually does and returns can go below in the longer description with examples and not in the "Returns" block.
|
@ikrommyd, thank you for your comments.
I'll have Claude Code research on these two points. |
|
The style definitely does not require it to be short. I’m just commenting on what’s actually happening in packages out there and what people generally want. The return statement in the docstring has the same purpose as the args statements. It has to be concise. And in the same way args specify types, returns needs to say “ak.Array” or “tuple of arrays” or whatever. |
Research on the two points, with citations. 1.
2. The return type in
So the rule cuts both ways: with a 🤖 Researched and written with Claude Code |
|
Whether the code contains type annotations does not matter at all. When one is reading a documentation page, they don't have to be in an IDE at the same time nor do they even need to have an IDE that shows the annotations in general. Take every function in the numpy docs. All the inputs and outputs of a function show the types and they are described concisely. Of course there is no hard requirement on the length of docstrings that is enforced. But nobody wants to read paragraphs to understand an argument or the return value of a function. |
|
@ikrommyd - Issue comment #3980 (comment) has a checklist for |
We have to keep in mind that we are annotating it for AI as well. We need as detailed and as precise description. |
5cd2feb to
3ea099d
Compare
|
The documentation preview is ready to be viewed at http://preview.awkward-array.org.s3-website.us-east-1.amazonaws.com/PR4130 |
Add a Google-style one-line summary and `Returns:`/`Examples:` section headers to the 8 missing-value operations in `src/awkward/operations/`: fill_none, drop_none, is_none, firsts, singletons, mask, nan_to_none, nan_to_num. 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>
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>
3ea099d to
e741f92
Compare
| attrs (None or dict): Custom attributes for the output array, if | ||
| high-level. | ||
|
|
||
| Converts NaN ("not a number") into None, i.e. missing values with option-type. |
There was a problem hiding this comment.
@TaiSakuma - I think this explanation feels more appropriate, e.g. more clear? It might be my English...
Summary
Rolls the pilot from #3946 out to the 8 operations in the Missing-value batch of #3980:
fill_none,drop_none,is_none,firsts,singletons,mask,nan_to_none,nan_to_num.Each docstring now has:
""".Returns:andExamples: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
ak.fill_noneak.drop_noneak.is_noneak.firstsak.singletonsak.maskak.nan_to_noneak.nan_to_numNotes for reviewers
ak.mask's summary compresses thevalid_whensemantics to "where a mask condition fails"; the exactoutput[i] = array[i] if mask[i] == valid_when else Noneformula is preserved verbatim in the body.ak.nan_to_none's summary adds "in floating-point arrays" — the implementation only converts floating-point data, which the original text did not state.ak.firsts/ak.singletonsare phrased as a near-inverse pair.Test plan
Args:blocks and doctests byte-identical; no original narrative text lost.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