Skip to content

Commit c697bb2

Browse files
authored
add fusion product iterator test (#99)
* add fusion product iterator test * oopsie * isingbimodule length of fusion iterator * change iteratorsize * test only when iterator size isn't unknown + combine * be kind to compile times
1 parent a806193 commit c697bb2

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/multifusion.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ Base.length(::SectorValues{IsingBimodule}) = length(all_isingbimod_objects)
3737
const IsingBimoduleProdIterator = SectorProductIterator{IsingBimodule}
3838
(a::IsingBimodule, b::IsingBimodule) = SectorProductIterator(a, b)
3939

40-
Base.IteratorSize(::Type{IsingBimoduleProdIterator}) = Base.SizeUnknown()
40+
Base.IteratorSize(::Type{IsingBimoduleProdIterator}) = Base.HasLength()
41+
function Base.length(x::IsingBimoduleProdIterator)
42+
a, b = x.a, x.b
43+
a.col == b.row || return 0
44+
a.row == b.col && a.row != a.col && return 2
45+
return 1
46+
end
4147

4248
function Base.iterate(iter::IsingBimoduleProdIterator, state = 0)
4349
a, b = iter.a, iter.b

test/sectors.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ end
7171

7272
@testsuite "Fusion and dimensions" I -> begin
7373
for a in smallset(I), b in smallset(I)
74+
cs = a b
75+
if Base.IteratorSize(typeof(cs)) !== Base.SizeUnknown()
76+
@test length(cs) == length(collect(cs))
77+
end
7478
can_fuse(a, b) || continue
7579
da = dim(a)
7680
db = dim(b)

0 commit comments

Comments
 (0)