Skip to content

Add StyledHook + graph-level terminate!#226

Open
gpeairs wants to merge 2 commits into
mainfrom
gp/self-termination
Open

Add StyledHook + graph-level terminate!#226
gpeairs wants to merge 2 commits into
mainfrom
gp/self-termination

Conversation

@gpeairs
Copy link
Copy Markdown
Member

@gpeairs gpeairs commented May 21, 2026

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. Exports StyledHook and hook_style at the top level.

Path and RouteComponent hooks are now StyledHooks carrying the style at the start or end of the path. For p1 hooks, this is just nextstyle (or nothing for empty paths). For p0 hooks, this is computed as nextstyle on the reversal of the initial node (or nothing for empty paths), so this PR also implements reverse for Path styles that still needed it.

Also contains the same fix for RouteComponent p1 hook direction as in #213.

StyledHook can be used to verify style agreement for fused components, and terminate! can be useful in constructing truncated models for simulation.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 92.75362% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/paths/contstyles/strands.jl 0.00% 3 Missing ⚠️
src/paths/contstyles/tapers.jl 66.66% 1 Missing ⚠️
src/paths/discretestyles/simple.jl 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gpeairs gpeairs force-pushed the gp/self-termination branch 2 times, most recently from 8d79c83 to 327263d Compare May 21, 2026 11:55
@gpeairs gpeairs requested a review from simlapointe May 21, 2026 12:01
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.
@gpeairs gpeairs force-pushed the gp/self-termination branch from 327263d to ce37a1f Compare May 21, 2026 13:05
Copy link
Copy Markdown
Contributor

@simlapointe simlapointe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me. Two comments below; one of them might be a small bug but not sure it would arise in practice.

Comment thread src/schematics/routes.jl
function hooks(rc::RouteComponent{T}) where {T}
p0 = StyledHook(
PointHook(rc.r.p0, rc.r.α0),
Paths.nextstyle(reverse(rc.sty[1], zero(T)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread src/paths/paths.jl
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))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this computes both a reversed segment and a reversed style, but only style is used so segment reversal is wasted work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants