Skip to content

Commit 2d1b2c1

Browse files
authored
Add converter and show method (#16)
1 parent 23c7701 commit 2d1b2c1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/multifusion.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function Base.iterate(iter::IsingBimodIterator, state=0)
4646
(IsingBimod(a.row, b.col, _state), state + 1) : nothing
4747
end
4848

49+
Base.convert(::Type{IsingBimod}, labels::NTuple{3,Int}) = IsingBimod(labels...)
50+
4951
function Base.convert(::Type{IsingAnyon}, a::IsingBimod) # identify RepZ2 ⊕ RepZ2 ≅ Ising
5052
(a.row != a.col) && return IsingAnyon()
5153
return IsingAnyon(a.label == 0 ? :I : )
@@ -89,3 +91,12 @@ end
8991
function Base.hash(a::IsingBimod, h::UInt)
9092
return hash(a.label, hash(a.row, hash(a.col, h)))
9193
end
94+
95+
function Base.show(io::IO, a::IsingBimod)
96+
if get(io, :typeinfo, nothing) === IsingBimod
97+
print(io, (a.row, a.col, a.label))
98+
else
99+
print(io, "IsingBimod", (a.row, a.col, a.label))
100+
end
101+
return nothing
102+
end

0 commit comments

Comments
 (0)