You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ReportTriangle requires its reference days to match the expected series #316
Found while right-aligning BinomialError's trials vector (#306), checking
for other components that assume the observed and expected series are the
same length.
Since #302 the error families right-align the two series and score their
overlap, and #307 gave Aggregate the same treatment. ReportTriangle
still requires them to be equal:
@modelfunctionas_turing_model(obs_model::ReportTriangle, y_t, Y_t)
n =length(Y_t)
...@assertsize(observed, 1) == n "The triangle has $(size(observed, 1)) reference days; Y_t has $n"
and scores cell (t, d) against Y_t[t], indexing the expected series at
the reference day of the data.
Unlike the Aggregate case this fails loudly rather than misaligning, so
nothing is silently wrong today. It does mean a ReportTriangle cannot sit
under a Split whose branches have unequal lead-ins: one series length has
to serve every branch, so a branch with a shorter lead-in gets more expected
values than the caller has reference days, and the assertion fires.
Suggested fix
Right-align the triangle's reference days against the end of Y_t, the way
the error families and Aggregate now do, and score the overlap. A triangle
with fewer reference days than expected values would cover the last size(observed, 1) of them.
Worth deciding at the same time whether a triangle with more reference
days than expected values (the chain's own lead-in) should drop its head
rather than assert.
This was opened by a bot. Please ping @seabbs for any questions.
Checked against #246, the other shape issue in this batch. These are not the same fault, so this stays open.
#246 is a component's shape being inferred from its data's array dimensions rather than stated. _obs_data_shape read the infection process's stratum count off a matrix's row count, so a dense reporting triangle handed in as y_t turned its three reference days into three infection strata.
This issue is the opposite case. ReportTriangle already states its contract: _alignment(::ReportTriangle) = :exact in src/observation_models/requirements.jl says the triangle does not right-align, data_requirements reports that, and _check_exact_length rejects a mismatched length for a composed model before the body runs. The assertion quoted in this issue is the same statement made a second time. What is asked for here is a change of policy from :exact to :right on the time axis, so a triangle can sit under a Split whose branches have unequal lead-ins.
Verified on the #246 branch. After the stratum count stops coming from array dimensions, as_turing_model(ReportTriangle(PoissonError(), [0.5, 0.3, 0.2]), N, fill(50.0, 5)) with a three-reference-day N still fails with AssertionError: The triangle has 3 reference days; Y_t has 5. The #246 work touches neither the assertion nor the alignment.
The fix stands as written above: right-align the triangle's reference days against the end of Y_t, score the overlap, and move _alignment(::ReportTriangle) to :right so the requirements report agrees.
This was opened by a bot. Please ping @seabbs for any questions.
Activity
seabbs-bot commentedon Sep 4, 2026
Checked against #246, the other shape issue in this batch. These are not the same fault, so this stays open.
#246 is a component's shape being inferred from its data's array dimensions rather than stated.
_obs_data_shaperead the infection process's stratum count off a matrix's row count, so a dense reporting triangle handed in asy_tturned its three reference days into three infection strata.This issue is the opposite case.
ReportTrianglealready states its contract:_alignment(::ReportTriangle) = :exactinsrc/observation_models/requirements.jlsays the triangle does not right-align,data_requirementsreports that, and_check_exact_lengthrejects a mismatched length for a composed model before the body runs. The assertion quoted in this issue is the same statement made a second time. What is asked for here is a change of policy from:exactto:righton the time axis, so a triangle can sit under aSplitwhose branches have unequal lead-ins.Verified on the #246 branch. After the stratum count stops coming from array dimensions,
as_turing_model(ReportTriangle(PoissonError(), [0.5, 0.3, 0.2]), N, fill(50.0, 5))with a three-reference-dayNstill fails withAssertionError: The triangle has 3 reference days; Y_t has 5. The #246 work touches neither the assertion nor the alignment.The fix stands as written above: right-align the triangle's reference days against the end of
Y_t, score the overlap, and move_alignment(::ReportTriangle)to:rightso the requirements report agrees.This was opened by a bot. Please ping @seabbs for any questions.