Repository navigation
docs: demonstrate the model-modification tooling and cut prose the code already says - #366
Conversation
|
@seabbs-review-bot |
Try this Pull Request!Option 1: Julia Package ManagerOpen Julia and type: import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ComposableTuringIDModels.jl", rev="docs/overview-cleanup")
using ComposableTuringIDModelsOption 2: Local CheckoutIf you have the repo locally: git checkout docs/overview-cleanup
julia --project=. -e "using Pkg; Pkg.instantiate()" |
There was a problem hiding this comment.
This PR moves the swap demonstration from design.md into overview.md using the public swap function, and drops incidental length(...) reporting from several doc examples across design.md and two tutorials. The code in every changed example checks out: swap(f, model::IDModel) exists and behaves as shown, only(delays) is safe given obs has exactly one LatentDelay, and the depleting/Z_t variables referenced are all in scope. The one real regression is in design.md, where a substantive explanation of what SusceptibleDepletion does was replaced with a vague filler sentence.
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.
| A [`RenewalStep`](@ref) is a force-of-infection core plus an ordered tuple of modifiers that share one incidence window. | ||
| The first modifier, [`SusceptibleDepletion`](@ref), scales the proposed incidence by the available susceptible fraction and depletes the pool, turning the renewal process into one with a fixed population. | ||
| [`Renewal`](@ref) is a step-composing helper, so passing the modifier composes it onto the step. | ||
| As a demonstration, a [`SusceptibleDepletion`](@ref) modifier is composed onto the renewal step. |
There was a problem hiding this comment.
suggestion This replaces a real mechanism explanation with meta-commentary about the example. The deleted text said SusceptibleDepletion scales incidence by the susceptible fraction and depletes the pool (turning the renewal process into one with a fixed population), and that Renewal is a step-composing helper so passing the modifier composes it onto the step. The new sentence, 'As a demonstration, a SusceptibleDepletion modifier is composed onto the renewal step', tells the reader an example follows but not what the modifier does or why the constructor takes it positionally. The link to the renewal-modifiers tutorial covers the statistical effect, but not the 'Renewal is a step-composing helper' API point, which isn't stated anywhere else. Consider keeping at least one sentence on what the modifier does, e.g. 'SusceptibleDepletion scales the proposed incidence by the available susceptible fraction and depletes the pool, turning the renewal process into one with a fixed population; see [Renewal modifiers](@ref renewal-modifiers) for its effect on a fitted model.'
There was a problem hiding this comment.
Rejecting this one, with the reasons rather than on the maintainer's say-so alone.
Cutting that paragraph was the explicit ask behind this PR: "Just say as a demonstration here we compose a susceptible process or similar? point to the more complex docs for this?" Restoring the mechanism sentence would undo the change the PR exists to make, so it stays cut and goes back to @seabbs rather than being reverted here.
The claim that the "step-composing helper" point is stated nowhere else is wrong. src/infection_models/Renewal.jl:33 opens a paragraph of the Renewal docstring with "Renewal is a step-composing helper: AbstractRenewalModifiers, given positionally or through the modifiers keyword, are composed onto the renewal RenewalStep", and gives the depletion equation and the pop_size meaning below it. That docstring is rendered in the API reference.
The deleted mechanism sentence was itself a copy of SusceptibleDepletion's docstring at src/steps/RenewalStep.jl:84, which opens "Scales the proposed incidence by the available susceptible fraction and depletes the susceptible pool" with the same equation. So the design page was repeating two docstrings, and the tutorial link covers the fitted effect.
There was a problem hiding this comment.
Reverted in 3362c48. Both sentences are back, and the renewal-modifiers pointer is back at the end of the section where it was, so this hunk now matches main exactly.
|
Review bot pass acted on. One finding, rejected, with the reasoning in the inline reply.
Nothing else was raised. The rest of the pass agreed the changed examples are sound. This was opened by a bot. Please ping @seabbs for any questions. |
|
Second round pushed (a9f7ff0). Verification numbers, since they are the load-bearing part:
The naive recent
The discrete interval is slightly shorter and tighter than the
One pre-existing flake found while verifying, not caused by this PR and not fixed in it. This was opened by a bot. Please ping @seabbs for any questions. |
|
@seabbs-review-bot |
There was a problem hiding this comment.
This is a docs-only PR that adds Accessors.@set alongside the existing swap tool for editing composed models, and trims duplicated tutorial prose. The mechanism is sound (verified against DirectInfections/RandomWalk/LatentDelay/Split constructors and ConstructionBase.constructorof overrides), but two claims in the new design.md text misdescribe the actual machinery.
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.
| ``` | ||
|
|
||
| `Accessors.@set` replaces **one** component named by its path. | ||
| The path is the field path the model prints, so a component nested several levels down is one line. |
There was a problem hiding this comment.
issue "The path is the field path the model prints" is contradicted by src/base/prettyprinting.jl's _role_label, which strips the _model/_models suffix for display: IDModel's tree shows infection:/observation:, not infection_model:/observation_model:. A reader who follows the printed label literally would write @set base.infection.Z = AR() and get an error, when the real path (used two lines above in this same file) is base.infection_model.Z. Drop the claim that the path equals the printed label, or note explicitly that role labels in the tree have their _model(s) suffix stripped while the real field name keeps it.
There was a problem hiding this comment.
Accepted and fixed in d18113c. Confirmed against src/base/prettyprinting.jl:10, where _role_label strips a trailing _models/_model, and against the rendered tree, which shows infection: and observation: for the infection_model and observation_model fields. The sentence now says a path is the objects own field path, and notes that a printed branch label has the suffix trimmed.
|
|
||
| The [`LatentDelay`](@ref) survives with its delay intact, so only the named stream changes. | ||
|
|
||
| `ComposableTuringIDModels.wrapped_models` and `ComposableTuringIDModels.rewrap` sit underneath both tools. |
There was a problem hiding this comment.
suggestion "wrapped_models and rewrap sit underneath both tools" overstates it: @set never calls either — Accessors works through ConstructionBase.setproperties/constructorof directly on the object's own fields (and NamedTuples natively), independent of the traversal seam. The rewrap docstring in traversal.jl already says this precisely: a component with a transforming constructor "needs no rewrap method... defines ConstructionBase.constructorof instead, which fixes Accessors". Rephrase to say constructorof is the seam @set depends on, and wrapped_models/rewrap are only what swap depends on.
There was a problem hiding this comment.
Accepted and fixed in d18113c. Confirmed: @set goes through ConstructionBase.setproperties/constructorof (a wrong-target @set in my own testing errored with "Please define ConstructionBase.setproperties", never touching rewrap), and src/observation_models/traversal.jl:151-155 says a component with a transforming constructor needs no rewrap and defines constructorof instead. The text now attributes wrapped_models/rewrap to swap and constructorof to @set.
The overview said "swap" and then rebuilt the model, so it now calls `swap` on the assembled model. Blocks that ended in `length(...)` only to show they had run print their value instead. The design page's duplicate swap section is cut, its modifier paragraph is replaced by a pointer to the renewal modifiers tutorial, and a code comment restating the prose above it is removed. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…mposed The design page's swap section is restored and rebuilt around which tool to reach for, with `swap`, `Accessors.@set` and the `wrapped_models`/`rewrap` author seam each shown rather than described. `Accessors` joins the docs project. The nowcast page derives its three corrections from one model and maps one sampler call over the four fits instead of writing it out four times, and the SIR page derives its stochastic variant the same way. Blocks that built a composed object and hid it now print the component tree, and the prose that read that tree back in words is cut. Summaries that reported a length or a size in place of the number the text claimed are replaced by the number: the generation interval is compared against the distribution it came from, the forecast block shows its predictive interval. The FlexiChains and PairPlots explanations are stated once, in the first tutorial. The tutorials index gains a theme table so a page can appear under every theme it covers. Em-dashes are gone from the hand-authored prose. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Reverted at the maintainer's request on the review thread. The mechanism sentence and the step-composing note return to the accumulation-steps section, with the renewal-modifiers pointer back at the end of it. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`@set` rebuilds through `ConstructionBase.constructorof`, not through `wrapped_models`/`rewrap`, which only `swap` walks. A path is the object's own field path, and the printed tree trims the `_model` suffix from its labels, so the tree label is not the path. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
d18113c to
c1158f1
Compare
|
Rebased onto current main (658bf8f, which brings in #362) and force-pushed; the head is now c1158f1 and all eight review comments are still attached. The diff no longer shows For anyone reading a stale checkout: the branch carries four commits, not one. Against the merge base it touches 14 files. FlexiChains sentences removed: 8 lines across four pages, one kept. This was opened by a bot. Please ping @seabbs for any questions. |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
The overview now derives the negative-binomial model with `swap`, so design.md's "the overview shows ... rebuilding the assembly with one argument different" no longer describes it. Also drops sentences that restate the code block or the paragraph above them, and splits three sentences that joined clauses with a comma. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Prose pass over this PR's own additions, plus a re-check of the review-bot threads and the red CI. Review-bot threadsAll four inline findings already carry replies. I re-verified each against source rather than taking the earlier replies on trust.
No thread cites a repo standard, so there is nothing to check against Prose passOne real inaccuracy, introduced by this PR's own earlier commits. Cut as restatement of the block or paragraph above:
Split, for the one-clause-per-sentence rule: Left in place, and why:
The diff still has zero em-dashes, en-dashes and banned filler words, and Re-verifiedThe five CITen of ten The failure is in
This was opened by a bot. Please ping @seabbs for any questions. |
|
@seabbs-review-bot |
There was a problem hiding this comment.
This is a docs-only PR that reworks the swap-in/swap-out and observation-chain-traversal sections of design.md to introduce Accessors.@set alongside swap, trims prose that only restated adjacent code or comments, and replaces several placeholder outputs in the overview and tutorials with real computed values. I checked the new @set and swap examples against the actual struct field names (IDModel.observation_model/infection_model, LatentDelay.model, Ascertainment.model, Split.streams, RandomWalk.init) and the wrapped_models/rewrap/swap implementation in src/observation_models/traversal.jl, and they all resolve correctly; the new generation-interval mean/sd computation in renewal-negbin.md matches the documented lag-0-drop-and-renormalise behaviour in Renewal.jl. The Accessors dependency was added to both [deps] and [compat] in docs/Project.toml. No correctness issues or standards breaches found.
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.
The lead-in already promised that everything wrapped around a swapped Split stream comes through untouched. Naming the stored pmf makes it the part a reader would expect to go wrong, since LatentDelay reverses it on construction. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Follow-up to #354.
Show the tooling instead of describing it
docs/src/design.md's Swap-in, swap-out section is rebuilt around which tool to reach for, with a runnable example each.swapfor every component matching a predicateAccessors.@setfor one component named by its path, covering a latent process, a prior on a nested component, and one stream of aSplitwith theLatentDelayaround it survivingwrapped_models/rewrapreframed as the seam a component author implements, not something a user callsThe old two-step
rewrapdance for a singleSplitstream is gone from Inspecting and updating an observation chain.That section now points at
@setand keeps the walk for what it is good at.Accessorsis added todocs/Project.toml, deps and compat, so the examples run.Two more pages derive rather than rebuild, each verified against the hand-built object first.
realtime-nowcast.mdThree fits.The three corrections are
@seton one plain model's observation model, and the four fits are aNamedTupleof(model, data)specs mapped over onesamplecall, which was previously written out four times.The old
naive_post/rt_chainnames are rebound from the map so the plotting code, being rewritten ondocs/aog-plotting, is untouched.Recent Rt is now
mapover the fits.sir-ode.md.The stochastic-ascertainment model is
@seton the deterministic one's observation model.Print composed objects, cut the narration
Seven
nothing # hidesuppressions of composed model objects are dropped so the component tree prints, and the prose that described the same structure in words is cut.That is
delays-dayofweek.md(arima211,weekly_latent,dayofweek_negbin,observation,tv_observation) andsir-ode.md(model,stochastic_model).split-observations.md'scascadeis split out of its simulate block so the cascade tree prints.The rest of the 38 suppressions stay: sampler chains, plot handles, function definitions, seeds, large simulated arrays, and
IDProblem, which prints a wall of type parameters rather than a tree.Cut as narration of the block above them:
delays-dayofweek.md, the "from the inside out" enumeration and the priors-seam thesis, which is design.md's subjectgroup_levelcomment inhierarchy-stacked.md, whose second half is a real identifiability fact and is promoted into the prosesplit-observations.mdandrenewal-negbin.mdmodel-assembly sentencespatch-models.md's "The model is a shared, partially pooled process, …"time-varying-damping.md's "ρ is tracked as a generated quantity" commentUninformative summaries replaced, not just deleted
Show the number the prose claims, else show something a reader learns, else delete.
renewal-negbin.md:57sum(gen_int), length(gen_int)Gamma(6.5, 0.62)it came fromrenewal-negbin.md:246size(fc)overview.md:105lengthsZ_ttime-varying-damping.md:46,58lengthstime-varying-damping.md:23(order = …, coefficient_is_constant = true), a hardcoded booleandesign.md:262length(delays), first(delays).delayonly(delays).delayhierarchy-stacked.md:61data_size = size(Ydata)in the tupletrue_levelsis the point and stayshierarchy-stacked.md:80size(chain, 1)split-observations.md:211The
gen_intnumbers came out against the old prose.The discrete interval's mean and sd are slightly below the continuous ones, from dropping the lag-0 bin and truncating, not "shifted and spread".
The prose is corrected to match the numbers.
Kept, because the length is the claim:
split-observations.md:78andgaussian-process.md:25.Left alone as plumbing:
length/sizeinside plotting helpers and axis ranges, including the four in the AoG agent's files.Repeats cut across pages
That
samplereturns a FlexiChains chain is explained once, in the first tutorial (renewal-negbin.md), trimmed of the ESS/R-hat clause the printed table shows.It is removed from
catalyst-ode.md,delays-dayofweek.md,realtime-nowcast.mdandsir-ode.md.The PairPlots extension sentence is likewise kept once, in
renewal-negbin.md.Tutorials index
A theme table replaces the "they progress from…" framing, with pages appearing under every theme they cover.
The infection, observation and latent rows use the package's own role names so the index, the design page and the API reference agree.
The annotated list is kept below it, since it carries the citations that feed the page's bibliography.
docs/pages.jlis untouched.index.md:42no longer presentsas_turing_model,IDModelandIDProblemas interchangeable.It leads with
as_turing_model.Dashes
The two em-dashes in the hand-authored overview SVG are rewritten, keeping the strings near their original length so the centred
<text>still sits correctly.gaussian-process.md's two en-dashes were the compound "matrix–vector", now hyphenated.Everything else in
docs/srcis in managed files (.vitepress/*,components/*,benchmarks/ad-comparison.jl) and is left alone.The em-dashes in
ad-comparison.jlbelong on EpiAware/EpiAwarePackageTools.jl#520 with its prose.This PR's own diff has zero em-dashes, en-dashes and mid-sentence
-.Reverted on request
The susceptible-depletion paragraph in
design.md's accumulation-steps section is restored at @seabbs's request on the review thread.That hunk matches main.
Held pending #372, tracked in #386
Each of these is a real instance of "prose promises composability, code rebuilds", left as it is because
@seton the target silently produces a different object today.Held means the page still builds the second object from scratch, exactly as it does on main.
Nothing is suppressed and no output is wrong, so this PR is correct on its own and stays correct whichever order it and #372 merge in.
None of the three becomes right by itself when #372 lands, so each needs the edit recorded in #386 afterwards.
split-observations.mdcases/deaths, whereAscertainmentdrops thePrefixLatentModelwrap. No helper-function workaround, as instructed.delays-dayofweek.mdtv_observationfromobservation, where the target isLatentDelay.delay, whose storage refactor(construction): derive fields in-constructor, dropping every constructorof #372 changes.patch-models.mdindependent/pooled/coupled, where the target isRenewal, which is not in the verified-clean set.One more for #369/#372, found here.
ARderivestransformfrom the type ofdamp,tanhfor a process andidentityfor aDistribution.So
@set AR(; damp = Normal(0.4, 0.1)).damp = RandomWalk()keepsidentitywhere the hand-builtAR(; damp = RandomWalk())getstanh, and the two are not equal.ARwas on the verified-clean list.time-varying-damping.mdtherefore still builds both by hand.#372 will change one printed output here, and it needs no tracking.
design.md'sonly(delays).delayprints the stored pmf,[0.2, 0.3, 0.5]today and[0.5, 0.3, 0.2]onceLatentDelaystores it as given.It sits in an
@exampleblock, so Documenter regenerates it on the next build and no prose states the vector.catalyst-ode.md's fivenothing # hideare left as they are.Catalyst is not installed in the environment I can run locally, so I could not check what the objects render as, and the sweep's rule is to check rather than assume.
Verified
@exampleblock touched here was executed. That covers thedesign,traversalandoverviewchains extracted verbatim from the pages, thedelays,sir-ode,split-observationsandhierarchy-stackedobjects, and the two pages that sample.realtime-nowcast.md's four fits were run end to end through Recent Rt, and the naive/corrected direction the prose describes still holds. Runtime and the recovered values are in the PR thread.renewal-negbin.mdwas fit and forecast to check the new generation-interval and forecast blocks.@setconversion was checked against the hand-built object by recursive field comparison.==andisequalboth fall back to===on structs holding arrays, so they report false negatives here.@reftarget grepped.Runic --check src test docs benchmark extexits 0.Not claimed: the docs build.
Documenter is red repo-wide (#353), and adding
Accessorsto the docs project has not been through a build here.Prose pass on this PR's own additions
A second pass over what this PR adds, after the tooling changes above.
design.mdsaid "the overview shows the plainest case, rebuilding the assembly with one argument different". The overview now derives its second model withswap, so that no longer described it and the sentence is rewritten without the cross-reference.design.md,overview.md,sir-ode.mdanddesign.md'sswaplead-in.overview.mdsaid "leaves the rest untouched" three times on one page. It now says it once.index.md,hierarchy-stacked.mdandrealtime-nowcast.md.index.md's "Most readers arrive with a task rather than a concept" and "once the vocabulary is familiar" are dropped as filler.Left in place, and why.
Split@setexample appears in both Swap-in, swap-out and Inspecting and updating an observation chain. The two sections address different readers, one choosing a tool and one implementing a component, and the second is where the seam is explained.realtime-nowcast.mdrebinds eight names offfits. That is there so the plotting code ondocs/aog-plottingneeds no edit, and collapsing it would reach outside this PR.Notes
CI's red test jobs are an upstream dependency break, not this PR.
Every failing
testjob anddowngrade-compatends inUndefVarError: SS_Int not defined in AMD, which fails precompilation ofLinearSolve,ModelingToolkitand eight more.The same failure is on
docs/catalyst-compositionandfix/369-accessors, neither of which touches docs.A docs-only diff cannot reach it.
#348 carries prose that predates the #354 sweep, including the paragraph cut here at
delays-dayofweek.md, and will reintroduce em-dashes when it merges.Untouched, flagged only.
delays-dayofweek.md'sdriftingblock usestruncated(Normal(0.47, 0.2), 0, Inf), the NaN-gradient trap in #297.The page flags rather than fits that model, so no gradient is taken and it is safe as written.
renewal-modifiers.mdstill lives undergetting-started/tutorials/while every other tutorial is undertutorials/.The table links it correctly.
Moving it changes a URL, so it belongs in its own PR.
This was opened by a bot. Please ping @seabbs for any questions.