Skip to content

Commit cd288f3

Browse files
committed
avoid double @cached definition
1 parent f9c42b8 commit cd288f3

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

src/fusiontrees/braiding_manipulations.jl

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -299,44 +299,44 @@ Base.@assume_effects :foldable function _fsdicttype(::Type{T}) where {I, N₁, N
299299
return Pair{FusionTreeBlock{I, N₁, N₂, Tuple{F₁, F₂}}, Matrix{E}}
300300
end
301301

302-
@cached function fsbraid(key::K)::_fsdicttype(K) where {I, N₁, N₂, K <: FSPBraidKey{I, N₁, N₂}}
303-
((f₁, f₂), (p1, p2), (l1, l2)) = key
304-
p = linearizepermutation(p1, p2, length(f₁), length(f₂))
305-
levels = (l1..., reverse(l2)...)
306-
(f, f0), coeff1 = repartition((f₁, f₂), N₁ + N₂)
307-
f′, coeff2 = braid(f, p, levels)
308-
(f₁′, f₂′), coeff3 = repartition((f′, f0), N₁)
309-
return (f₁′, f₂′) => coeff1 * coeff2 * coeff3
310-
end
311-
@cached function fsbraid(key::K)::_fsdicttype(K) where {I, N₁, N₂, K <: FSBBraidKey{I, N₁, N₂}}
312-
src, (p1, p2), (l1, l2) = key
302+
@cached function fsbraid(key::K)::_fsdicttype(K) where {I, N₁, N₂, K <: Union{FSPBraidKey{I, N₁, N₂}, FSBBraidKey{I, N₁, N₂}}}
303+
if K <: FSPBraidKey
304+
((f₁, f₂), (p1, p2), (l1, l2)) = key
305+
p = linearizepermutation(p1, p2, length(f₁), length(f₂))
306+
levels = (l1..., reverse(l2)...)
307+
(f, f0), coeff1 = repartition((f₁, f₂), N₁ + N₂)
308+
f′, coeff2 = braid(f, p, levels)
309+
(f₁′, f₂′), coeff3 = repartition((f′, f0), N₁)
310+
return (f₁′, f₂′) => coeff1 * coeff2 * coeff3
313311

314-
p = linearizepermutation(p1, p2, numout(src), numin(src))
315-
levels = (l1..., reverse(l2)...)
312+
else
313+
src, (p1, p2), (l1, l2) = key
316314

317-
dst, U = repartition(src, numind(src))
315+
p = linearizepermutation(p1, p2, numout(src), numin(src))
316+
levels = (l1..., reverse(l2)...)
318317

319-
for s in permutation2swaps(p)
320-
inv = levels[s] > levels[s + 1]
321-
dst, U_tmp = artin_braid(dst, s; inv)
322-
U = U_tmp * U
323-
l = levels[s]
324-
levels = TupleTools.setindex(levels, levels[s + 1], s)
325-
levels = TupleTools.setindex(levels, l, s + 1)
326-
end
318+
dst, U = repartition(src, numind(src))
327319

328-
if N₂ == 0
329-
return dst => U
330-
else
331-
dst, U_tmp = repartition(dst, N₁)
332-
U = U_tmp * U
333-
return dst => U
320+
for s in permutation2swaps(p)
321+
inv = levels[s] > levels[s + 1]
322+
dst, U_tmp = artin_braid(dst, s; inv)
323+
U = U_tmp * U
324+
l = levels[s]
325+
levels = TupleTools.setindex(levels, levels[s + 1], s)
326+
levels = TupleTools.setindex(levels, l, s + 1)
327+
end
328+
329+
if N₂ == 0
330+
return dst => U
331+
else
332+
dst, U_tmp = repartition(dst, N₁)
333+
U = U_tmp * U
334+
return dst => U
335+
end
334336
end
335337
end
336338

337-
CacheStyle(::typeof(fsbraid), k::FSPBraidKey{I}) where {I} =
338-
FusionStyle(I) isa UniqueFusion ? NoCache() : GlobalLRUCache()
339-
CacheStyle(::typeof(fsbraid), k::FSBBraidKey{I}) where {I} =
339+
CacheStyle(::typeof(fsbraid), k::Union{FSPBraidKey{I}, FSBBraidKey{I}}) where {I} =
340340
FusionStyle(I) isa UniqueFusion ? NoCache() : GlobalLRUCache()
341341

342342
"""

0 commit comments

Comments
 (0)