11using BlockArrays: Block
22using TensorAlgebra: ⊗
3- using GradedUnitRanges: GradedUnitRanges, gradedrange, label
3+ using GradedUnitRanges: GradedUnitRanges, gradedrange, dual, isdual, label
4+ using SymmetrySectors: U1
45using Test: @test , @testset
56
6- struct U1
7- dim:: Int
8- end
9- Base. isless (l1:: U1 , l2:: U1 ) = isless (l1. dim, l2. dim)
10- GradedUnitRanges. fuse_labels (l1:: U1 , l2:: U1 ) = U1 (l1. dim + l2. dim)
11-
12- # # TODO : This should need to get implemented, but `dual`
13- # # isn't being used right now in `GradedUnitRanges`.
14- # # GradedUnitRanges.dual(l::U1) = U1(-l.dim)
15-
167@testset " TensorAlgebraGradedUnitRangesExt" begin
178 a1 = gradedrange ([U1 (0 ) => 2 , U1 (1 ) => 3 ])
189 a2 = gradedrange ([U1 (2 ) => 3 , U1 (3 ) => 4 ])
@@ -25,4 +16,16 @@ GradedUnitRanges.fuse_labels(l1::U1, l2::U1) = U1(l1.dim + l2.dim)
2516 @test a[Block (2 )] == 7 : 15
2617 @test a[Block (3 )] == 16 : 23
2718 @test a[Block (4 )] == 24 : 35
19+ @test ! isdual (a)
20+
21+ a = a1 ⊗ dual (a2)
22+ @test label (a[Block (1 )]) == U1 (- 2 )
23+ @test label (a[Block (2 )]) == U1 (- 1 )
24+ @test label (a[Block (3 )]) == U1 (- 3 )
25+ @test label (a[Block (4 )]) == U1 (- 2 )
26+ @test a[Block (1 )] == 1 : 6
27+ @test a[Block (2 )] == 7 : 15
28+ @test a[Block (3 )] == 16 : 23
29+ @test a[Block (4 )] == 24 : 35
30+ @test ! isdual (a)
2831end
0 commit comments