feat: split rebuild_leaf from leaf_signature - #346
Conversation
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/ComposedDistributions.jl", rev="feat/rebuild-leaf-split")
using ComposedDistributionsOption 2: Local CheckoutIf you have the repo locally: git checkout feat/rebuild-leaf-split
julia --project=. -e "using Pkg; Pkg.instantiate()" |
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:
|
|
📖 Documentation preview is ready! View the docs for this PR at: https://EpiAware.github.io/ComposedDistributions.jl/previews/PR346/ This preview will be updated automatically when you push new commits. |
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 — 17 benchmarks (by time change)
AD gradients — 36 benchmarks (by time change)
|
`_update_leaf` now calls `rebuild_leaf(leaf, vals)`, an ordinary method with no constructor-identity contract, instead of building through `leaf_ctor` directly. `tie` groups leaves by the new `leaf_signature(leaf)` hook, which keeps the egal-stability requirement that only tie identity actually needs. A leaf whose free parameters are not its native constructor arguments can now override `rebuild_leaf` (an ordinary method) rather than being forced into a callable-struct `leaf_ctor` just to satisfy `tie`'s equality check.
Both hooks' defaults previously dispatched on the outer wrapped leaf directly, so an override on an inner leaf (e.g. one wrapped in truncated/uncertain) was never consulted: rebuild_leaf re-entered leaf_ctor's own peeling instead of the override, and leaf_signature could mis-group structurally distinct wrapped leaves under tie. Peel one free_leaf layer at a time before dispatching, mirroring how leaf_ctor already peels, so an inner-leaf override is honoured under any wrapper stack. leaf_signature keeps the parameter-names half keyed on the outer leaf so a wrapper's own extra_leaf_params names are not dropped. Add a testitem covering both hooks under truncated/uncertain wrappers, including a tie-rejection case that fails without the fix.
029ab33 to
46ead89
Compare
|
Superseded by #381, which folds this and seven other PRs into one branch off This branch is preserved and the PR body is kept for its rationale — the detail here is the record of why, which #381 summarises rather than repeats. Closing so it does not compete for review. This comment was posted by a bot. Please ping @seabbs for any questions. |
Splits the two questions leaf_ctor currently fuses: rebuild_leaf(leaf, vals) is the reconstruction hook (a plain method, no egal-stable callable struct needed), and leaf_signature(leaf) is the tie-identity hook, which now carries the egal-stability contract explicitly. Both peel wrapper layers, so an inner-leaf override is honoured under truncated/censored/uncertain wrappers — review caught that the naive defaults silently bypassed overrides and could tie two incompatible wrapped leaves into one parameter; both defects are fixed and pinned by a test that fails without the peeling. The signature keeps parameter names from the outer leaf so wrapper-owned extras survive.
This strengthens the instance-level leaf protocol that the staged codec change (runtime dispatch replacing the leaf registries) leans on. Gates: test-fast 1616/1616, quality clean post-format.
This was opened by a bot. Please ping @seabbs for any questions.
Refs #332. Refs EpiAware/ModifiedDistributions.jl#142.