Skip to content

Commit

Permalink
fix aqua warning, make iterator more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jutho committed Sep 12, 2024
1 parent 74d2af5 commit 6994919
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/fusiontrees/iterator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ uncoupled sector labels and isomorphisms `uncoupled` and `isdual` respectively.
function fusiontrees(uncoupled::NTuple{N,I}, coupled::I,
isdual::NTuple{N,Bool}) where {N,I<:Sector}
uncouplediterators = map(tuple, uncoupled)
return FusionTreeIterator{I,N,Tuple{I}}(uncouplediterators, coupled, isdual)
return FusionTreeIterator(uncouplediterators, coupled, isdual)
end
function fusiontrees(uncoupled::Tuple{Vararg{I}}, coupled::I) where {I<:Sector}
isdual = ntuple(n -> false, length(uncoupled))
Expand All @@ -26,15 +26,15 @@ end
# Base.iterate(s::Sector, ::Any) = nothing
# TODO: reconsider whether this is desirable; currently it conflicts with the iteration of `ProductSector`

struct FusionTreeIterator{I<:Sector,N,G}
uncouplediterators::NTuple{N,G} # iterators over uncoupled sectors
struct FusionTreeIterator{I<:Sector,N,T<:NTuple{N}}
uncouplediterators::T # iterators over uncoupled sectors
coupled::I
isdual::NTuple{N,Bool}
end

Base.IteratorSize(::FusionTreeIterator) = Base.SizeUnknown()
Base.IteratorEltype(::FusionTreeIterator) = Base.HasEltype()
Base.eltype(::Type{FusionTreeIterator{I,N,G}}) where {I<:Sector,N,G} = fusiontreetype(I, N)
Base.eltype(::Type{<:FusionTreeIterator{I,N}}) where {I<:Sector,N} = fusiontreetype(I, N)

Base.length(iter::FusionTreeIterator) = _fusiondim(iter.uncouplediterators, iter.coupled)
_fusiondim(::Tuple{}, c::I) where {I<:Sector} = Int(one(c) == c)
Expand Down
9 changes: 3 additions & 6 deletions src/spaces/productspace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,9 @@ sector `blocksector`.
"""
function fusiontrees(P::ProductSpace{S,N}, blocksector::I) where {S,N,I}
I == sectortype(S) || throw(SectorMismatch())
if N == 0
return FusionTreeIterator{I,N,Tuple{I}}((), blocksector, ())
else
return FusionTreeIterator(map(sectors, P.spaces), blocksector,
map(isdual, P.spaces))
end
uncoupled = map(sectors, P.spaces)
isdualflags = map(isdual, P.spaces)
return FusionTreeIterator(uncoupled, blocksector, isdualflags)
end

"""
Expand Down

0 comments on commit 6994919

Please sign in to comment.