Add StyledHook + graph-level terminate!#226
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
8d79c83 to
327263d
Compare
327263d to
ce37a1f
Compare
simlapointe
left a comment
There was a problem hiding this comment.
Overall looks good to me. Two comments below; one of them might be a small bug but not sure it would arise in practice.
| function hooks(rc::RouteComponent{T}) where {T} | ||
| p0 = StyledHook( | ||
| PointHook(rc.r.p0, rc.r.α0), | ||
| Paths.nextstyle(reverse(rc.sty[1], zero(T))) |
There was a problem hiding this comment.
Not sure, but given src/paths/contstyles/trace.jl does reverse(s::GeneralTrace, 0) produce GeneralTrace(t -> width(s, -t)), evaluating at negative path lengths?
There was a problem hiding this comment.
It does, but my view was that it should never come up. GeneralTrace on a RouteComponent really never makes sense because you don't know the length ahead of time. You also can't terminate RouteComponents so the style can't be used there anyway.
A related problem is that nextstyle just repeats the GeneralTrace, so neither hook's style is really correct (e.g. for verifying that it matches whatever it's fused to) whether the correct pathlength is there or not. This should maybe be treated as a bug -- arguably the next style should be a constant trace with whatever the segment ended with, the same as a taper. I can't think of a case where you'd want to just repeat the GeneralTrace; if you're trying to make something periodic, you would use it inside an actual PeriodicStyle. If we fix that then at least once the path has been built the p1 style will be correct. I'll change 0 to pathlength(rc._path) so it's at least consistent if we apply that fix.
| p0_hook(pa::Path, right_handed=true) = HandedPointHook(p0(pa), α0(pa), right_handed) | ||
| p0_hook(pa::Path, right_handed=true) = StyledHook( | ||
| HandedPointHook(p0(pa), α0(pa), right_handed), | ||
| isempty(pa.nodes) ? nothing : nextstyle(without_attachments(reverse(pa[1]).sty)) |
There was a problem hiding this comment.
Nit: this computes both a reversed segment and a reversed style, but only style is used so segment reversal is wasted work.
There was a problem hiding this comment.
Fair enough, changed to reverse(pa[1].sty, pathlength(pa[1].seg))
Adds a `StyledHook{T, H<:Hook{T}, S} <: Hook{T}` wrapper that augments any
`Hook` with a carried path-style object, plus graph-level `terminate!`
methods that use the carried style (or an explicit `style=` kwarg) to
attach a termination cap to a schematic node's hook.
40e67dc to
503d9fa
Compare
Adds a
StyledHook{T, H<:Hook{T}, S} <: Hook{T}wrapper that augments anyHookwith a carried path-style object, plus graph-levelterminate!methods that use the carried style (or an explicitstyle=kwarg) to attach a termination cap to a schematic node's hook. ExportsStyledHookandhook_styleat the top level.PathandRouteComponenthooks are nowStyledHookscarrying the style at the start or end of the path. Forp1hooks, this is justnextstyle(ornothingfor empty paths). Forp0hooks, this is computed asnextstyleon the reversal of the initial node (ornothingfor empty paths), so this PR also implementsreversefor Path styles that still needed it.Also contains the same fix for RouteComponent
p1hook direction as in #213.StyledHookcan be used to verify style agreement for fused components, andterminate!can be useful in constructing truncated models for simulation.