Repository navigation
fix(shape): let a component state which of its data's axes are streams - #363
seabbs-bot wants to merge 7 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
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="246-shape")
using ComposableTuringIDModelsOption 2: Local CheckoutIf you have the repo locally: git checkout 246-shape
julia --project=. -e "using Pkg; Pkg.instantiate()" |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 6 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Benchmark comparison vs baseMinimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:
Evaluation — 9 benchmarks (by time change)
AD gradients — 7 benchmarks (by time change)
|
|
📖 Documentation preview is ready! View the docs for this PR at: https://EpiAware.github.io/ComposableTuringIDModels.jl/previews/PR363/ This preview will be updated automatically when you push new commits. |
`_obs_data_shape` read the infection process's stratum count off the data's array dimensions: a matrix's row count, or a NamedTuple's entry count. That is right only where those dimensions happen to be observation streams. A `ReportTriangle` handed a dense count matrix turned its reference days into infection strata, and a `BinomialError` given `(y, N)` turned its trials vector into a second stream. Both then failed under an unstratified latent model with "RandomWalk produces one path. Wrap it in a `Stratify`", an error about a stratification the caller never asked for. Add `observation_streams(model, y_t)`, the seam a component uses to say how many observation streams a data value holds for it. It follows the same `wrapped_models` walk as `observation_lead_in` and `data_requirements`, takes its field names from the existing data contract, and returns `nothing` for a value with no stream axis, so a single series stays a plain length rather than a one-row panel. A `Split` that fixes its own stratum count now does so before any data is seen, so a weight map is honoured through a wrapping modifier and with `y_t = missing`. `IDModel`'s two-argument form shares the one implementation. No sampled variable is renamed: `keys(VarInfo(...))` is unchanged across ten composed models covering every branch. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The seam is public, so it needs a test that calls it rather than one that reaches it through the private shape helper. Covers the composed-model delegation, which the shape helper never exercises because it is always handed an observation model already. Say why the declared stratum count goes through `infection_strata` on a path where a weight map already answers it. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`define_y_t` unpacks `y_t.y` for every error family, not only the ones whose data contract names extra fields, so `(y = counts,)` is a supported way to supply any of them. Reading the whole NamedTuple's arity therefore counted a two-row panel wrapped in `(y = ...,)` as one stream, and left the same observations building a different infection process depending on whether they were wrapped. Count the axis of `y` instead, which is the field the model will read. `(y = vector,)` under an unstratified latent model now builds the model it should rather than failing with "RandomWalk produces one path". Give `IDModel` and `IDProblem` their own methods rather than reaching them through an `Any` fallback, matching `observation_lead_in`. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Trim the new comments in `requirements.jl` to the facts a reader cannot get from the code, and drop the em-dash. Split the colon-joined sentences in the `IDModel` and `IDProblem` docstrings. Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2259390 to
1502b69
Compare
|
Third pass answered on the threads, plus a quality sweep and a rebase. Review threads. Five findings were already fixed by the earlier commits and now have replies saying where. The Quality sweep. Comment narration cut in CI. This was opened by a bot. Please ping @seabbs for any questions. |
Co-Authored-By: Sam Abbott <contact@samabbott.co.uk> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Surely we don't need to replace reparameterised distributiosn here with wrapper functioanlt and why can't neg bin use observation erro? I thought it was just going to help with al the placeholder stuff obs error models use? |
The rebuild-coverage test item added in #372 does `using InteractiveUtils: subtypes`, but the stdlib was never added to `test/Project.toml`. Julia 1.12 refuses to load a stdlib that is not in the active environment, so every test matrix job on a branch carrying that item errors in `reconstruction.jl`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lw3PbYZfA1dZhfaaE9tbdp (cherry picked from commit 4d7322a)
|
The question above about reparameterised distributions and This branch is caught up with Merge order note: #373 moves Generated by Claude Code |
Closes #246
Closes #374
The description this PR carried until now was #348's, pasted here by mistake, which is why a question about
ObservationErrorlanded on this thread.This is the shape fix and nothing else.
The fault
_obs_data_shaperead the infection process's stratum count off any leading array axis orNamedTupleentry count.That is right for a
Split, whose rows or entries are observation streams.It is wrong for a
ReportTriangle, whose rows are reference days, and for aBinomialError, whose(y, N)is one stream and a trials covariate.Both built a stratified infection process nobody asked for and failed with
RandomWalk produces one path. Wrap it in a Stratify.A
ReportTrianglewas unusable throughIDProblemand through the two-argumentas_turing_model.The fix
observation_streams(model, y_t)is the seam a component uses to say how many observation streams a data value holds for it, ornothingfor a single series.The default reads the value's own axes.
A
ReportTrianglesays its matrix names no streams.An error family counts the axis of the
yfielddefine_y_tunpacks, so(y = matrix, N = matrix)is one stream axis and(y = vector,)is none.It is
public, documented, and hasIDModelandIDProblemmethods besideobservation_lead_in's._declared_stratais what a chain fixes for itself before it sees any data, aSplit's weight map or stream names._obs_data_shaperesolves the declared count first and reads the data only where the chain leaves the count open, mapping streams to strata throughinfection_stratain one place.IDProblem, the two-argumentas_turing_modelandforecastshare it, so the three build a data-driven shape the same way.Tests
Direct tests of
observation_streamson the default, a modifier, aReportTriangle, aBinomialError, aSplitand both composed types._obs_data_shapecases for the triangle as a matrix and as a carrier, the binomial as a single stream and as a panel, a series wrapped in(y = ...,)resolving the same shape as the bare series, and a nestedSplitwhose map fixes the count.A return-type check that the resolved shape is concrete, since it is built in a
@modelbody.Two
IDProblemitems building aBinomialErrormodel and aReportTrianglemodel and checking the variable names of a single-series process.Review
Five findings from
@seabbs-review-botare fixed and their threads resolved.One is rejected on all three passes, reading
size(m.map, 2)in place ofinfection_strata(m, size(m.map, 1)), because the seam is where the streams-to-strata rule lives.Merge note
#373 moves
_obs_data_shapetoo.This is the smaller change, so land it first and rebase #373 over it.
This was opened by a bot. Please ping @seabbs for any questions.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Lw3PbYZfA1dZhfaaE9tbdp