Skip to content

Commit

Permalink
enforce U1(Int32(1)) == U1(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
ogauthe committed Oct 22, 2024
1 parent 3f05a81 commit 8901076
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ abelian_label_fusion_rule(sector_type::Type{<:U1}, n1, n2) = sector_type(n1 + n2
function Base.show(io::IO, u::U1)
return print(io, "U(1)[", sector_label(u), "]")
end

# enforce U1(Int32(1)) == U1(1)
Base.:(==)(s1::U1, s2::U1) = sector_label(s1) == sector_label(s2)
5 changes: 5 additions & 0 deletions NDTensors/src/lib/SymmetrySectors/test/test_simple_sectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ using Test: @inferred, @test, @testset, @test_throws
@test dual(U1(2)) == U1(-2)
@test isless(U1(1), U1(2))
@test !isless(U1(2), U1(1))
@test U1(Int8(1)) == U1(1)
@test U1(UInt32(1)) == U1(1)

@test U1(0) == TrivialSector()
@test TrivialSector() == U1(0)
Expand Down Expand Up @@ -70,6 +72,9 @@ using Test: @inferred, @test, @testset, @test_throws

@test Z{2}(0) == TrivialSector()
@test TrivialSector() < Z{2}(1)
@test Z{2}(0) != Z{2}(1)
@test Z{2}(0) != Z{3}(0)
@test Z{2}(0) != U1(0)
end

@testset "O(2)" begin
Expand Down

0 comments on commit 8901076

Please sign in to comment.