Skip to content

chore: prune over-long code comments - #335

Merged
seabbs merged 3 commits into
mainfrom
chore/prune-comments
Sep 2, 2026
Merged

seabbs merged 3 commits into
mainfrom
chore/prune-comments

Conversation

@seabbs-bot

Copy link
Copy Markdown
Collaborator

What

Recent PRs (#272, #302, #309, #317, #283) landed comment blocks with essay-length rationales — multi-paragraph justifications above short functions that repeat the code's own point. This PR tightens the worst 13 blocks in src/ and one in test/, keeping each block's essential technical point while cutting the filler.

Comments only. No code, docstring, string-literal, or test-assertion changes. Verified with a script that 0 non-comment lines changed and git diff --check is clean.

What was kept

The genuinely-necessary invariants stay, just condensed:

  • Enzyme reverse-mode array-typing invariants (MissingObservations scoring, ReportTriangle narrowing)
  • forecast's independent-tail factorisation guarantee
  • the GP nugget floor / hyperprior-support rationale
  • right-alignment semantics (BinomialError trials, Aggregate windows, Split lead-in)

Files (13)

src/base/priors.jl, src/infection_models/Renewal.jl, src/inference/IDProblem.jl, src/inference/forecast.jl, src/latent_models/models/ExactGP.jl, src/latent_models/models/HilbertSpaceGP.jl, src/observation_models/ObservationErrorModels/{BinomialError,methods}.jl, src/observation_models/modifiers/{Aggregate,ReportTriangle}.jl, src/observation_models/traversal.jl, src/steps/RenewalStep.jl, test/unit/observation_models/observations_extra.jl

Net diff: -65 comment lines (107 insertions, 172 deletions).

Recent PRs (#272, #302, #309, #317, #283) inserted comment blocks with
essay-length justifications. Tighten the worst 13: keep each block's
essential technical point (Enzyme array-typing invariants, right-alignment,
forecast factorisation, GP nugget floor) but cut the repeated rationale,
filler, and self-referential prose. Comments only — no code, docstring, or
test-assertion changes.
@seabbs-bot
seabbs-bot requested a review from seabbs as a code owner August 28, 2026 16:02
@github-actions

Copy link
Copy Markdown
Contributor

Try this Pull Request!

Option 1: Julia Package Manager

Open Julia and type:

import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ComposableTuringIDModels.jl", rev="chore/prune-comments")
using ComposableTuringIDModels

Option 2: Local Checkout

If you have the repo locally:

git checkout chore/prune-comments
julia --project=. -e "using Pkg; Pkg.instantiate()"

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark comparison vs base

Minimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:

Group 🟢 <50% 🟢 50–75% 🟢 75–95% ⚪ 95–105% 🔴 105–125% 🔴 125–150% 🔴 >150%
Evaluation · · 1 5 3 · ·
ForwardDiff · 1 1 · · · ·
ReverseDiff (tape) · · · 1 1 · ·
Mooncake reverse · · · 2 · · ·
Enzyme reverse · · 1 · · · ·
Evaluation — 9 benchmarks (by time change)
Benchmark base PR time memory
Sampling / NUTS (DirectInfections+Poisson, 50 draws) 108.79 ms 98.55 ms 🟢 0.91× ⚪ 1.0×
Model evaluation / RandomWalk latent / rand 420.0 ns 451.0 ns 🔴 1.07× ⚪ 1.0×
Model evaluation / AR latent / rand 610.0 ns 651.0 ns 🔴 1.07× ⚪ 1.0×
Model evaluation / DirectInfections+Poisson / rand 651.0 ns 691.0 ns 🔴 1.06× ⚪ 1.0×
Model evaluation / RandomWalk latent / forward 430.0 ns 420.0 ns ⚪ 0.98× ⚪ 1.0×
Model evaluation / Renewal+NegativeBinomial / rand 2.15 μs 2.19 μs ⚪ 1.02× ⚪ 1.0×
Model evaluation / Renewal+NegativeBinomial / forward 4.64 μs 4.72 μs ⚪ 1.02× ⚪ 1.0×
Model evaluation / AR latent / forward 550.0 ns 541.0 ns ⚪ 0.98× ⚪ 1.0×
Model evaluation / DirectInfections+Poisson / forward 1.1 μs 1.11 μs ⚪ 1.01× ⚪ 1.0×
AD gradients — 7 benchmarks (by time change)
Benchmark base PR time memory
AD gradients / AR latent logjoint / ForwardDiff 8.74 μs 5.83 μs 🟢 0.67× ⚪ 1.0×
AD gradients / DirectInfections+Poisson posterior / ReverseDiff (tape) 98.54 μs 104.97 μs 🔴 1.07× ⚪ 1.0×
AD gradients / DirectInfections+Poisson posterior / Enzyme reverse 3.78 μs 3.54 μs 🟢 0.94× ⚪ 1.0×
AD gradients / DirectInfections+Poisson posterior / ForwardDiff 14.65 μs 13.78 μs 🟢 0.94× ⚪ 1.0×
AD gradients / AR latent logjoint / Mooncake reverse 5.52 μs 5.31 μs ⚪ 0.96× ⚪ 1.0×
AD gradients / DirectInfections+Poisson posterior / Mooncake reverse 8.89 μs 8.66 μs ⚪ 0.97× ⚪ 1.0×
AD gradients / AR latent logjoint / ReverseDiff (tape) 96.14 μs 97.45 μs ⚪ 1.01× ⚪ 1.0×

@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation preview is ready!

View the docs for this PR at: https://EpiAware.github.io/ComposableTuringIDModels.jl/previews/PR335/

This preview will be updated automatically when you push new commits.

@codecov

codecov Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
ad-enzyme-reverse 64.41% <ø> (ø)
ad-forwarddiff 64.95% <ø> (ø)
ad-mooncake-forward 64.95% <ø> (ø)
ad-mooncake-reverse 64.95% <ø> (ø)
ad-reversediff 65.11% <ø> (ø)
ad-reversediff-compiled 65.11% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/base/priors.jl 92.30% <ø> (ø)
src/infection_models/Renewal.jl 100.00% <ø> (ø)
src/inference/IDProblem.jl 100.00% <ø> (ø)
src/inference/forecast.jl 89.09% <ø> (ø)
src/latent_models/models/ExactGP.jl 100.00% <ø> (ø)
src/latent_models/models/HilbertSpaceGP.jl 100.00% <ø> (ø)
...ion_models/ObservationErrorModels/BinomialError.jl 88.46% <ø> (ø)
...servation_models/ObservationErrorModels/methods.jl 100.00% <ø> (ø)
src/observation_models/modifiers/Aggregate.jl 76.47% <ø> (ø)
src/observation_models/modifiers/ReportTriangle.jl 100.00% <ø> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@seabbs-review-bot seabbs-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR only trims explanatory # comments in 12 source files and one test file to be shorter, per the org standard that comments should be short and state the why without narration; no function bodies, signatures, tests, or docstrings are touched. I checked each hunk against its surrounding code and against the julia-standards.md rules on comment style, and the trimming preserves the load-bearing rationale in every case (e.g. the generation-interval lag-0 convention removed from Renewal.jl's inline comment is still stated at its owning definition, _drop_lag_zero). The broad CI failure list looks unrelated to a comment-only diff and is worth confirming separately rather than attributing to this change.

Automated first pass by seabbs-review-bot (Claude sonnet), triggered by: first pass. Not a human review. Comment @seabbs-review-bot to ask for another pass: @seabbs any time, the author's agent once it has pushed changes. Add the no-review label to opt this PR out. Ping @seabbs with any questions.

@seabbs-review-bot seabbs-review-bot Bot added the llm-reviewed Reviewed by seabbs-review-bot label Sep 2, 2026
Six of the shortened blocks lost something a reader needs and cannot get
from the code:

- Mooncake's actual error text, "Unreachable reached", which is what
  someone hitting it will search for.
- Why the GP guard needs ℓ > 0 at all: no spectral density, and a singular
  covariance, at ℓ ≤ 0.
- That a container-held model is printed but not walked — the observable
  consequence of `wrapped_models` differing from the printing walk.
- That an absent entry is missing at random, which is what licenses
  dropping it from the likelihood rather than imputing it.
- That no heuristic on the time-axis length is used or wanted, since an
  innovation stream is typically shorter than the series it drives.
- That the resolve-before-scan seam means nothing ever tests what a
  modifier is.

Also unpick a "so … so" in the trials comment, restore the note that the
longer series' head goes unused, and drop a stray blank line in the
forecast splice loop.

Co-Authored-By: Sam Abbott <contact@samabbott.co.uk>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UmmqqzQPhrB74RfAv2TqBQ
@seabbs-bot

Copy link
Copy Markdown
Collaborator Author

@seabbs-review-bot

The pruned nugget comment named the code's own choice as the failure mode.
The nugget in the code IS jitter-scaled; the rejected alternative was one
with an absolute floor of `jitter`. The `ExactGP` docstring says so, and the
worked number at σ = 1e-3 is what made it checkable. Put both back.

Four other blocks lost the mechanism that supported their claim:

- The Enzyme constraint had become a non-sequitur without the `y_t[i] ~ dist`
  run-time `=== missing` check that is what would need the array.
- "DynamicPPL owns the copying" was unsupported without the deepcopy of an
  argument that still holds a `missing`.
- `n_strata` is `infection_strata` applied to the stream count, not the
  stream count, and the two `time_steps` sources are why the helper is shared.
- The i.i.d. parenthetical had attached to the latent rather than to its
  resized stream.

Also split a sentence in `priors.jl` carrying both a semicolon and a dash,
and make "the worked example" indefinite now that the sentence naming it is
gone.

Co-Authored-By: Sam Abbott <contact@samabbott.co.uk>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UmmqqzQPhrB74RfAv2TqBQ

@seabbs-review-bot seabbs-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is comment-only: every hunk trims prose in existing #/docstring comments, plus one incidental blank-line removal in forecast.jl; no logic, signatures, tests, or behaviour change anywhere in the diff. I checked the trimmed comments (nugget formula in ExactGP.jl, the factorisation guard and innovation-extension logic in forecast.jl, the missing-observation scoring in ObservationErrorModels/methods.jl, the Aggregate/BinomialError alignment comments) against the code they describe and found no drift — the branch's own follow-up commits already restored facts an earlier pass over-pruned and fixed a wrong nugget-formula comment. No development-history language, issue references, or restated-signature docstrings were introduced. Nothing to flag.

Automated first pass by seabbs-review-bot (Claude sonnet), triggered by: re-review requested by seabbs-bot. Not a human review. Comment @seabbs-review-bot to ask for another pass: @seabbs any time, the author's agent once it has pushed changes. Add the no-review label to opt this PR out. Ping @seabbs with any questions.

Comment thread src/base/priors.jl
# [`AR`](@ref)'s damping for the worked example.
# `Distribution` ⇒ one RV, a constant) OR a length-`n` path (an
# `AbstractPriorModel` process ⇒ the process's own draw). A component reads
# the result per step with `at`, so ONE recursion serves both the constant

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no all caps in docs

@seabbs
seabbs merged commit 71731c3 into main Sep 2, 2026
7 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-reviewed Reviewed by seabbs-review-bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants