Skip to content

Commit 9e20f7c

Browse files
lkdvosborisdevos
andauthored
Replace c == one(I) with isone(c) (#225)
This is a convenience change that should not alter the implementation, but allows multifusion sectors to work better. Taken from Boris' fork Co-authored-by: Boris De Vos <[email protected]>
1 parent 0a66eb2 commit 9e20f7c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/fusiontrees/fusiontrees.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ include("iterator.jl")
235235
# _abelianinner: generate the inner indices for given outer indices in the abelian case
236236
_abelianinner(outer::Tuple{}) = ()
237237
function _abelianinner(outer::Tuple{I}) where {I<:Sector}
238-
return outer[1] == one(I) ? () : throw(SectorMismatch())
238+
return isone(outer[1]) ? () : throw(SectorMismatch())
239239
end
240240
function _abelianinner(outer::Tuple{I,I}) where {I<:Sector}
241241
return outer[1] == dual(outer[2]) ? () : throw(SectorMismatch())
242242
end
243243
function _abelianinner(outer::Tuple{I,I,I}) where {I<:Sector}
244-
return first((outer...)) == one(I) ? () : throw(SectorMismatch())
244+
return isone(first((outer...))) ? () : throw(SectorMismatch())
245245
end
246246
function _abelianinner(outer::Tuple{I,I,I,I,Vararg{I}}) where {I<:Sector}
247247
c = first(outer[1] outer[2])

src/fusiontrees/iterator.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Base.IteratorEltype(::FusionTreeIterator) = Base.HasEltype()
3737
Base.eltype(::Type{<:FusionTreeIterator{I,N}}) where {I<:Sector,N} = fusiontreetype(I, N)
3838

3939
Base.length(iter::FusionTreeIterator) = _fusiondim(iter.uncouplediterators, iter.coupled)
40-
_fusiondim(::Tuple{}, c::I) where {I<:Sector} = Int(one(c) == c)
40+
_fusiondim(::Tuple{}, c::I) where {I<:Sector} = Int(isone(c))
4141
_fusiondim(iters::NTuple{1}, c::I) where {I<:Sector} = Int(c iters[1])
4242
function _fusiondim(iters::NTuple{2}, c::I) where {I<:Sector}
4343
d = 0
@@ -60,9 +60,9 @@ end
6060
# * Iterator methods:
6161
# Start with special cases:
6262
function Base.iterate(it::FusionTreeIterator{I,0},
63-
state=(it.coupled != one(I))) where {I<:Sector}
63+
state=!isone(it.coupled)) where {I<:Sector}
6464
state && return nothing
65-
tree = FusionTree{I}((), one(I), (), (), ())
65+
tree = FusionTree{I}((), it.coupled, (), (), ())
6666
return tree, true
6767
end
6868

src/fusiontrees/manipulations.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ function merge(f₁::FusionTree{I,N₁}, f₂::FusionTree{I,N₂},
230230
return insertat(f, N₁ + 1, f₂)
231231
end
232232
function merge(f₁::FusionTree{I,0}, f₂::FusionTree{I,0}, c::I, μ) where {I}
233-
c == one(I) ||
233+
isone(c) ||
234234
throw(SectorMismatch("cannot fuse sectors $(f₁.coupled) and $(f₂.coupled) to $c"))
235235
return fusiontreedict(I)(f₁ => Fsymbol(c, c, c, c, c, c)[1, 1, 1, 1])
236236
end
@@ -349,7 +349,7 @@ function foldright(f₁::FusionTree{I,N₁}, f₂::FusionTree{I,N₂}) where {I<
349349
for μ in 1:Nsymbol(c1, c2, c)
350350
fc = FusionTree((c1, c2), c, (!isduala, false), (), (μ,))
351351
for (fl′, coeff1) in insertat(fc, 2, f₁)
352-
N₁ > 1 && fl′.innerlines[1] != one(I) && continue
352+
N₁ > 1 && !isone(fl′.innerlines[1]) && continue
353353
coupled = fl′.coupled
354354
uncoupled = Base.tail(Base.tail(fl′.uncoupled))
355355
isdual = Base.tail(Base.tail(fl′.isdual))
@@ -694,7 +694,7 @@ corresponding coefficients.
694694
function elementary_trace(f::FusionTree{I,N}, i) where {I<:Sector,N}
695695
(N > 1 && 1 <= i <= N) ||
696696
throw(ArgumentError("Cannot trace outputs i=$i and i+1 out of only $N outputs"))
697-
i < N || f.coupled == one(I) ||
697+
i < N || isone(f.coupled) ||
698698
throw(ArgumentError("Cannot trace outputs i=$N and 1 of fusion tree that couples to non-trivial sector"))
699699

700700
T = sectorscalartype(I)
@@ -808,15 +808,15 @@ function artin_braid(f::FusionTree{I,N}, i; inv::Bool=false) where {I<:Sector,N}
808808
inner = f.innerlines
809809
inner_extended = (uncoupled[1], inner..., coupled′)
810810
vertices = f.vertices
811-
u = one(I)
812811
oneT = one(sectorscalartype(I))
813812

814-
if u in (uncoupled[i], uncoupled[i + 1])
813+
if isone(uncoupled[i]) || isone(uncoupled[i + 1])
815814
# braiding with trivial sector: simple and always possible
816815
inner′ = inner
817816
vertices′ = vertices
818817
if i > 1 # we also need to alter innerlines and vertices
819-
inner′ = TupleTools.setindex(inner, inner_extended[a == u ? (i + 1) : (i - 1)],
818+
inner′ = TupleTools.setindex(inner,
819+
inner_extended[isone(a) ? (i + 1) : (i - 1)],
820820
i - 1)
821821
vertices′ = TupleTools.setindex(vertices′, vertices[i], i - 1)
822822
vertices′ = TupleTools.setindex(vertices′, vertices[i - 1], i)

0 commit comments

Comments
 (0)