Repository navigation
Docstring diet: private code keeps prose, not sections; one-line properties - #766
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/stepper --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/calibration --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/modes --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py $(ls src/solprop/translate/*.py | grep -v precision.py) --write --check --report --rename-closures precision.py is left out (it goes in the next PR). The two D200 skips (PropagationProblem._check_spatial_collar_stability, SeparableOperator._adopt_user_rate) are rewritten by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: uv run python tools/docstring_diet.py src/solprop/driver --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/*.py --write --check --report --rename-closures The three summaries the tool skipped (D200) are shortened by hand: log.LogReporter._say, pulses._analytic, transverse_monitor._insensitive_reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ate docs The slimming dropped some Raises and Returns prose that said why a value is refused or what a result means: the reference length's NaN and amplification hazards, the absorber's no-gain rule, the exit status after a late signal, the Taylor phase units, the aligner's refusals, why identities use float.hex, why between-plane statistics are refused at construction, the negative-fluence refusal, the aperture weight's zeros, the mixture-flow refusal, the Gaussian order range and why radial reads skip unused rows. Stokes is capitalised again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/processing --write --check --report --rename-closures The two summaries the tool skipped (D200) are shortened by hand: planes._source_part, scans._Builtin.reads_fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ate docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/coupling --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The slimming dropped the note that a frequency limit may be zero, as the lower edge of a low-pass band, while a wavelength limit must be positive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/plotting --write --check --report --rename-closures The summary the tool skipped (D200) is shortened by hand: geometry._planar_grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: uv run python tools/docstring_diet.py src/solprop/output --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…utput private docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: uv run python tools/docstring_diet.py src/solprop/service --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/nonlinear --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: uv run python tools/docstring_diet.py src/solprop/recipe --write --check --report --rename-closures Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hand The tool kept solve_pin's nested build, whose underscore name clashes with the module's _build; it is now _trial. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The slimming dropped a few entries the code does not say: the _channel_index_table coupled/include_area semantics, the loss policy's place before integration, the mode attributes _dispersion_phi reads, the taps' normalisation of the plasma band rule, the C-order flattening of the expansion products, the [1.0] constant prefactor weight, zero-off-band generators, and a few whys (_state's rank check, _degree_axis, the general flow's gauge identity, binary32 range). Also completes the tuple returns of _split/_split_segments and recapitalises Chebyshev, Cartesian and E. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py $(find src/solprop/backends -name '*.py' | grep -v -e numpy_ref/single.py -e numpy_ref/transforms.py) --write --check --report --rename-closures numpy_ref/single.py and numpy_ref/transforms.py are left out (they go in the next PR). The D200 skip (numpy_ref.tdse._roundoff_terms) is rewritten by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical: python tools/docstring_diet.py src/solprop/physdata --write --check --report --rename-closures By hand: _warn_dilute_scaling's sections (D200 skip) and one f-string reflowed after the _span rename lengthened its line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…docs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cartesian, Hermitian, Jones and the fibre frequency V. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…limming Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Mechanical pass: each public property's summary becomes a noun phrase, its Returns section goes, the description stays as a paragraph, and the def line carries `# numpydoc ignore=RT01`. The AST without docstrings is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hand review of the mechanical pass: a unit, range or shape moves into the one-line summary, a description that only restates the summary or the type goes, and conventions, conditions and reasons stay as a paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Private sectioned docstrings fall to 37: re-exported public API defined in a private module, and the single-precision reference modules. The module caps follow the shrunken files; tools.py and spatial.py are now below the general cap. Scan's three properties take the property rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Documentation build overview
306 files changed ·
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # tools/size_budget.toml
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # native/src/solprop_native/session.py # src/solprop/backends/host/driver.py # src/solprop/driver/executors/_queue_state.py # src/solprop/driver/simulation.py # src/solprop/service/record.py # src/solprop/translate/envelope_plasma.py # src/solprop/translate/expansion.py # src/solprop/translate/linop.py # src/solprop/translate/problem.py # src/solprop/translate/radial.py # src/solprop/translate/responses.py # src/solprop/translate/spatial.py
Thirty-five Returns and parameter bullets named nothing beyond the type: no unit, range, condition, convention or structure. Every other bullet says at least one of those, so it stays. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fifteen properties of NativeBackend, NativeSession, NativePrepared and the group classes now match their host twins: a noun-phrase summary with numpydoc ignore=RT01 on the def line, in place of a Returns section. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The stubs of Mode, ModalProvider, RadialPermittivity, PermittivityLaw, ModelIdentityLike, the session protocols, DispersionPath and ZProfile read "Return ..."; they now name the quantity as their implementations do, and every public stub carries numpydoc ignore=RT01 on its def line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The diet dropped the doctests of _even_chunk and tail, which no test covered; the cases now live in the unit tests, with the other _display examples. tail's docstring again says that the width counts the ellipsis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The diet renamed it to _nonlinear, which changed the __qualname__ callers see. It is the only renamed closure that reaches a caller: the others are called in place or passed to a solver. Its def line ignores PR01 and RT01, with the reason, and its docstring keeps the state's unit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md said every nested function's name starts with one, which 82 in src/solprop do not and a returned closure must not. A nested function is private, but numpydoc checks one without the underscore, so one with parameters or a return value takes it unless callers receive it. tooling.md says the same of the size report, whose private rule is numpydoc's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
"Positions", "Overrides" and "Its" read to numpydoc as third-person verbs (SS05). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #763 (base
chore/lean-rules). This applies the docstring rule that #763 wrote into AGENTS.md. Only docstrings, comments and the names of nested functions change, plus the size ratchets. One later change is planned: removing the single-precision code under ADR-077 deletesbackends/numpy_ref/single.py,numpy_ref/transforms.pyandtranslate/precision.py, so this PR leaves those three files alone.The rule (AGENTS.md, "Docstrings and comments")
Parameters,Returns,Yields,Raises,ExamplesorSee Alsosections. It keeps the summary line, and then only what the signature and annotations don't say: a non-SI unit, a valid range, a condition, a convention, or a reason."""Peak power, W.""", with# numpydoc ignore=RT01on itsdefline. Prose of real value (a convention, a condition, a reason, a reference) stays as a following paragraph. AReturnsblock that restates the type or the summary goes.How it was done
Private docstrings.
tools/docstring_diet.pywas added in the first commit and deleted in the last. It ran package by package with--write --check --report --rename-closures.__all__counts as public API.NotesandReferenceswere kept verbatim.--checkcompiled each file and compared its AST, with docstrings removed, before and after. Each package's commit message records the command it ran. Summaries the tool skipped (D200) were shortened by hand in the same commits.Public properties. A throwaway script (ast +
numpydoc.docscrape, not committed) handled 540 properties in two commits (Scan's 3 were done by hand, 543 in all):Returnsgoes, its description stays as a paragraph, and the pragma is added;The same AST comparison passed on all 105 files the property commits touched.
About the pragma. numpydoc attaches a
# numpydoc ignore=comment to the lastdeforclasstoken before it (numpydoc/validate.py,extract_ignore_validation_comments). Ruff's E501 counts the comment, because it is not a pragma ruff knows. Where the comment would push a line past 88 columns,ruff formatwraps the signature, which leaves the pragma on the) -> T:line. numpydoc still honours it there. This happens for 25 properties. Nonoqa: E501was added.Summaries and SS05. numpydoc's SS05 heuristic applies to properties. A summary whose first word ends in a single "s" ("Positions …", "Fields …") therefore keeps a leading "The".
Lines (
git diff --shortstat 256c8e27 HEAD -- <path>)src/solprop/*.py(top level)backendscalibrationcouplingdrivermodesnonlinearoutputphysdataplottingprocessingrecipeservicesteppertranslatesrc/solpropnative/srcThe public-property commits account for 1,717 + / 3,810 − of the
src/solpropfigures.Restored by hand
Each package's "Restore …" commit puts back what the tool dropped and the code does not say:
include_areasemantics of_channel_index_table, where the loss policy sits before integration, the mode attributes_dispersion_phireads, how the plasma band rule's taps are normalised, the C-order flattening of expansion products, the[1.0]constant prefactor weight, zero-off-band generators, and the reasons behind_state's rank check,_degree_axis, the general flow's gauge identity and the binary32 range.channel_labelparity rules,azimuthal_orderbounds, wall-truncation constants, Parseval weights and thescale_invariantreasons.ConstantDispersion.is_constanthad a summary that said "varies"; it now reads "Whether the path is constant along z: alwaysTrue."Closures renamed
--rename-closuresadded a leading underscore to 44 nested functions in public functions, because numpydoc would otherwise validate them as public:at,element,residual,walk,half_bins,samples,rates,correction,sampled,material,at_parameters,read,columnand others, in 27 modules. By hand,solve_pin's nestedbuildbecame_trial, because_buildwould have clashed with the module's_build.Private doctests converted to unit tests
Dropped private
Examplesthat carried real checks moved into the mirrored test modules:driver.run._history_of→tests/driver/test_run.pyoutput.schema._inlined,_array_name,_dotted,_flow_text→tests/output/test_schema.pyservice.machines._development→tests/service/test_agent.pyservice.results._scan_axis→tests/service/test_results.pyNoneand NaN text →tests/test_display.pyRatchets (
tools/size_budget.toml)ThreadBudget.explicit,thread_budget,current_executor,Scanwith__repr__,__len__,add,point,points,subsetandchunk, andexample_output. The ratchet uses numpydoc's naming rule, so it counts them as private.Scan's three properties follow the property rule.simulation.py10,741,problem.py5,701,schema.py5,073.tools.py(3,613) andspatial.py(3,686) are now under the 4,000-line cap, so their entries are removed.Size report (
uv run poe size, src/solprop)Before (256c8e2, the head of #763):
After:
The total falls by 32,173 lines (−12.3 %), and private docstring lines fall from 47,923 to 17,829. The code column rises by 56 because
ruff formatwrapped signatures to fit the pragma. The noqa counts, cross-package private imports (88) and clone figures are unchanged.Verification
_scan_modeledit was checked the same way. The earlier package commits ran the tool's own--check.uv run poe docstrings,ruff check .,ruff format --check .,codespell src,poe changelog-check,poe reuseandpoe size-check.pytest -n 2 -p no:randomly <files>: 747 passed).tools/docstring_diet.pybefore it was deleted.basedpyrightandpoe docswere not run locally. CI runs them.Leftovers
pulses.SpatialPulse.alignedreturnsTruewhen the beam is displaced or tilted, so the name reads backwards. The docstring describes the code as it is. Code was out of scope here.__all__re-exports or the names move to public modules.translate/modal_path.py: ModalPathTable.positionsreads worst.🤖 Generated with Claude Code