Skip to content

Commit 4f553e7

Browse files
committed
Run formatter
1 parent b492820 commit 4f553e7

File tree

7 files changed

+149
-72
lines changed

7 files changed

+149
-72
lines changed

src/paths/channels.jl

Lines changed: 98 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,61 @@ function RouteChannel(pa::Path{T}, capacity=0) where {T}
1414
end
1515

1616
# Return a node corresponding to the section of the channel that the segment actually runs through
17-
function segment_channel_section(ch::RouteChannel{T}, wireseg_start, wireseg_stop, prev_width, next_width; margin=zero(T)) where {T}
17+
function segment_channel_section(
18+
ch::RouteChannel{T},
19+
wireseg_start,
20+
wireseg_stop,
21+
prev_width,
22+
next_width;
23+
margin=zero(T)
24+
) where {T}
1825
d = wireseg_stop - wireseg_start
1926
# Adjust for margins and track vs channel direction to get the channel node section used by actual segment
20-
if abs(d) <= 2*margin + prev_width + next_width
27+
if abs(d) <= 2 * margin + prev_width + next_width
2128
# handle case where margin consumes entire segment
2229
# Just have a zero length Straight at the midpoint
23-
track_mid = (wireseg_start + wireseg_stop)/2
30+
track_mid = (wireseg_start + wireseg_stop) / 2
2431
midpoint = ch.node.seg(track_mid)
2532
middir = direction(ch.node.seg, track_mid)
26-
channel_section = Node(Straight(zero(T), midpoint, middir), SimpleTrace(width(ch.node.sty, track_mid)))
33+
channel_section = Node(
34+
Straight(zero(T), midpoint, middir),
35+
SimpleTrace(width(ch.node.sty, track_mid))
36+
)
2737
elseif d > zero(d) # segment is along channel direction
28-
channel_section = split(ch.node,
29-
[wireseg_start + margin + prev_width/2,
30-
wireseg_stop - margin - next_width/2])[2]
38+
channel_section = split(
39+
ch.node,
40+
[
41+
wireseg_start + margin + prev_width / 2,
42+
wireseg_stop - margin - next_width / 2
43+
]
44+
)[2]
3145
elseif d < zero(d) # segment is counter to channel direction
32-
channel_section = reverse(split(ch.node,
33-
[wireseg_stop + margin + next_width/2,
34-
wireseg_start - margin - prev_width/2])[2])
46+
channel_section = reverse(
47+
split(
48+
ch.node,
49+
[
50+
wireseg_stop + margin + next_width / 2,
51+
wireseg_start - margin - prev_width / 2
52+
]
53+
)[2]
54+
)
3555
end
3656
return channel_section
3757
end
3858

3959
function track_path_segment(n_tracks, channel_section, track_idx; reversed=false)
40-
return offset(channel_section.seg,
41-
track_section_offset(n_tracks, width(channel_section.sty), track_idx; reversed))
60+
return offset(
61+
channel_section.seg,
62+
track_section_offset(n_tracks, width(channel_section.sty), track_idx; reversed)
63+
)
4264
end
4365

44-
function track_section_offset(n_tracks, section_width::Coordinate, track_idx; reversed=false)
66+
function track_section_offset(
67+
n_tracks,
68+
section_width::Coordinate,
69+
track_idx;
70+
reversed=false
71+
)
4572
# (spacing) * number of tracks away from middle track
4673
sgn = reversed ? -1 : 1
4774
spacing = section_width / (n_tracks + 1)
@@ -50,7 +77,10 @@ end
5077

5178
function track_section_offset(n_tracks, section_width::Function, track_idx; reversed=false)
5279
# (spacing) * number of tracks away from middle track
53-
return t -> (reversed ? -1 : 1) * (section_width(t) / (n_tracks + 1)) * (track_idx - (1 + n_tracks) / 2)
80+
return t ->
81+
(reversed ? -1 : 1) *
82+
(section_width(t) / (n_tracks + 1)) *
83+
(track_idx - (1 + n_tracks) / 2)
5484
end
5585

5686
reverse(n::Node) = Paths.Node(reverse(n.seg), reverse(n.sty, pathlength(n.seg)))
@@ -67,7 +97,7 @@ function reverse(b::BSpline{T}) where {T}
6797
p1 = b.p0
6898
r = Interpolations.scale(
6999
interpolate(p, Interpolations.BSpline(Cubic(NeumannBC(t0, t1)))),
70-
range(1-tmax, stop=1-tmin, length=length(p))
100+
range(1 - tmax, stop=1 - tmin, length=length(p))
71101
)
72102
α0 = rotated_direction(b.α1, RotationPi())
73103
α1 = rotated_direction(b.α0, RotationPi())
@@ -80,23 +110,35 @@ reverse(s::TaperTrace{T}, l) where {T} = TaperTrace{T}(s.width_end, s.width_star
80110
reverse(s::SimpleTrace, l) = s
81111
reverse(s::GeneralTrace, l) = GeneralTrace(t -> width(s, l - t))
82112
# Define methods for CPW even though they're not allowed for channels
83-
reverse(s::TaperCPW{T}, l) where {T} = TaperCPW{T}(s.trace_end, s.gap_end, s.trace_start, s.gap_start, s.length)
113+
reverse(s::TaperCPW{T}, l) where {T} =
114+
TaperCPW{T}(s.trace_end, s.gap_end, s.trace_start, s.gap_start, s.length)
84115
reverse(s::SimpleCPW, l) = s
85116
reverse(s::GeneralCPW, l) = GeneralCPW(t -> trace(s, l - t), t -> gap(s, l - t))
86117
# For compound segments, reverse the individual sections and reverse their order
87118
# Keep the same tag so if a compound segment/style pair matched before they will still match
88119
reverse(s::CompoundSegment) = CompoundSegment(reverse(reverse.(s.segments)), s.tag)
89120
function reverse(s::CompoundStyle{T}, l) where {T}
90121
lengths = reverse(diff(s.tgrid))
91-
CompoundStyle{T}(reverse(reverse.(s.styles, lengths)), cumsum(reverse(lengths)), s.tag)
122+
return CompoundStyle{T}(
123+
reverse(reverse.(s.styles, lengths)),
124+
cumsum(reverse(lengths)),
125+
s.tag
126+
)
92127
end
93128

94129
abstract type AbstractMultiRouting <: RouteRule end
95130

96131
abstract type AbstractChannelRouting <: AbstractMultiRouting end
97132

98-
function _route!(p::Path{T}, p1::Point, α1, rule::AbstractChannelRouting,
99-
sty, waypoints, waydirs) where {T}
133+
function _route!(
134+
p::Path{T},
135+
p1::Point,
136+
α1,
137+
rule::AbstractChannelRouting,
138+
sty,
139+
waypoints,
140+
waydirs
141+
) where {T}
100142
# Track segments for each channel
101143
track_path_segs = track_path_segments(rule, p, p1)
102144
waypoints = Point{T}[] # Segments too short for margins will just become waypoints for transitions
@@ -105,14 +147,21 @@ function _route!(p::Path{T}, p1::Point, α1, rule::AbstractChannelRouting,
105147
if iszero(pathlength(track_path_seg)) # Was too short for margins
106148
push!(waypoints, p0(track_path_seg))
107149
else
108-
route!(p, p0(track_path_seg), α0(track_path_seg), next_entry_rule, sty; waypoints)
150+
route!(
151+
p,
152+
p0(track_path_seg),
153+
α0(track_path_seg),
154+
next_entry_rule,
155+
sty;
156+
waypoints
157+
)
109158
push!(p, Node(track_path_seg, sty), reconcile=false) # p0, α0 reconciled by construction
110-
p[end-1].next = p[end]
111-
p[end].prev = p[end-1]
159+
p[end - 1].next = p[end]
160+
p[end].prev = p[end - 1]
112161
# Note `auto_curvature` BSpline uses curvature from end of previous segment
113162
# and is not reconciled with the new node
114163
# But we can do this ourselves
115-
_reconcile_curvature!(p[end-1], next_entry_rule)
164+
_reconcile_curvature!(p[end - 1], next_entry_rule)
116165
empty!(waypoints)
117166
end
118167
end
@@ -132,7 +181,7 @@ function _reconcile_curvature!(n::Node{T}, rule::BSplineRouting) where {T}
132181
end
133182
κ1 = if n.next === n
134183
0.0 / oneunit(T)
135-
else
184+
else
136185
signed_curvature(segment(n.next), zero(coordinatetype(n)))
137186
end
138187
_set_endpoints_curvature!(segment(n), κ0, κ1)
@@ -145,8 +194,8 @@ end
145194

146195
struct SingleChannelRouting{T} <: AbstractChannelRouting
147196
channel::RouteChannel{T}
148-
transition_rules::Tuple{<:RouteRule,<:RouteRule}
149-
transition_margins::Tuple{T,T}
197+
transition_rules::Tuple{<:RouteRule, <:RouteRule}
198+
transition_margins::Tuple{T, T}
150199
segment_tracks::Dict{Path{T}, Int}
151200
end
152201
function SingleChannelRouting(ch::RouteChannel{T}, rule::RouteRule, margin::T) where {T}
@@ -159,18 +208,34 @@ exit_margin(scr::SingleChannelRouting) = last(scr.transition_margins)
159208
num_tracks(scr::SingleChannelRouting) = maximum(values(scr.segment_tracks))
160209
track_idx(scr, pa) = scr.segment_tracks[pa]
161210
function set_track!(scr, pa, track_idx)
162-
scr.segment_tracks[pa] = track_idx
211+
return scr.segment_tracks[pa] = track_idx
163212
end
164213

165214
function track_path_segments(rule::SingleChannelRouting, pa::Path, endpt)
166215
wireseg_start = pathlength_nearest(rule.channel.node.seg, p1(pa))
167216
wireseg_stop = pathlength_nearest(rule.channel.node.seg, endpt)
168-
return [track_path_segment(num_tracks(rule),
169-
segment_channel_section(rule.channel, wireseg_start, wireseg_stop, 2*entry_margin(rule), 2*exit_margin(rule)),
217+
return [
218+
track_path_segment(
219+
num_tracks(rule),
220+
segment_channel_section(
221+
rule.channel,
222+
wireseg_start,
223+
wireseg_stop,
224+
2 * entry_margin(rule),
225+
2 * exit_margin(rule)
226+
),
170227
track_idx(rule, pa),
171-
reversed=wireseg_start > wireseg_stop)]
228+
reversed=wireseg_start > wireseg_stop
229+
)
230+
]
172231
end
173232

174-
function _update_with_graph!(rule::SingleChannelRouting, route_node, graph; track=num_tracks(rule)+1, kwargs...)
175-
set_track!(rule, route_node.component._path, track)
176-
end
233+
function _update_with_graph!(
234+
rule::SingleChannelRouting,
235+
route_node,
236+
graph;
237+
track=num_tracks(rule) + 1,
238+
kwargs...
239+
)
240+
return set_track!(rule, route_node.component._path, track)
241+
end

src/paths/routes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,4 +612,4 @@ function _route_leg!(
612612
end
613613

614614
function _update_with_plan!(rule::RouteRule, route_node, schematic) end
615-
function _update_with_graph!(rule::RouteRule, route_node, graph; kwargs...) end
615+
function _update_with_graph!(rule::RouteRule, route_node, graph; kwargs...) end

src/polygons.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ struct Ray{T} <: D1{T}
14851485
end
14861486
Ray(p0::Point{S}, p1::Point{T}) where {S, T} = Ray(promote(p0, p1)...)
14871487
Ray(p0::Point{S}, dir) where {S} =
1488-
Ray(promote(p0, p0 + Point(cos(dir), sin(dir))*oneunit(S))...)
1488+
Ray(promote(p0, p0 + Point(cos(dir), sin(dir)) * oneunit(S))...)
14891489

14901490
struct Line{T} <: D1{T}
14911491
p0::Point{T}

src/render/cpw.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@ function to_polygons(f, len, s::Paths.CPW; kwargs...)
4545
return [Polygon(uniquepoints(ppts)), Polygon(uniquepoints(mpts))]
4646
end
4747

48-
function to_polygons(seg::Paths.OffsetSegment{T}, s::Paths.CPW; atol=DeviceLayout.onenanometer(T), kwargs...) where {T}
48+
function to_polygons(
49+
seg::Paths.OffsetSegment{T},
50+
s::Paths.CPW;
51+
atol=DeviceLayout.onenanometer(T),
52+
kwargs...
53+
) where {T}
4954
bsp = Paths.bspline_approximation(seg; atol)
5055
return to_polygons(bsp, s; atol, kwargs...)
5156
end
5257

53-
5458
function to_polygons(f::Paths.Straight{T}, s::Paths.SimpleCPW; kwargs...) where {T}
5559
g = cpw_points(f, s)
5660

src/render/trace.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ function to_polygons(f, len, s::Paths.Trace; kwargs...)
1313
return Polygon(uniquepoints(pts))
1414
end
1515

16-
function to_polygons(seg::Paths.OffsetSegment{T}, s::Paths.Trace; atol=DeviceLayout.onenanometer(T), kwargs...) where {T}
16+
function to_polygons(
17+
seg::Paths.OffsetSegment{T},
18+
s::Paths.Trace;
19+
atol=DeviceLayout.onenanometer(T),
20+
kwargs...
21+
) where {T}
1722
bsp = Paths.bspline_approximation(seg; atol)
1823
return to_polygons(bsp, s; atol, kwargs...)
1924
end

src/schematics/SchematicDrivenLayout.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ import DeviceLayout:
5858
transform,
5959
transformation,
6060
_geometry!
61-
import ..Paths: setα0p0!, setp0!, Route, RouteRule, route!, _update_with_plan!, _update_with_graph!
61+
import ..Paths:
62+
setα0p0!, setp0!, Route, RouteRule, route!, _update_with_plan!, _update_with_graph!
6263
import ..CoordinateSystems: append_coordsys!
6364

6465
export Component,

0 commit comments

Comments
 (0)