|
1 | 1 | using BlockArrays: AbstractBlockArray, blocklengths |
2 | 2 | using BlockSparseArrays: BlockSparseArray |
3 | | -using GradedUnitRanges: blocklabels |
| 3 | +using GradedUnitRanges: blocklabels, dual, isdual |
4 | 4 | using ITensorBase: ITensor, Index, gettag, prime, settag |
5 | 5 | using QuantumOperatorDefinitions: OpName, SiteType, StateName, op, state |
6 | 6 | using SymmetrySectors: SectorProduct, U1, Z |
@@ -64,25 +64,19 @@ using Test: @test, @test_broken, @testset |
64 | 64 | t = SiteType("S=1/2"; gradings=("Sz",)) |
65 | 65 | a = AbstractArray(2.0 * StateName("0"), t) |
66 | 66 | @test a == [2, 0] |
67 | | - @test a isa AbstractBlockArray |
68 | | - # TODO: Currently slicing a dense array by graded ranges outputs a `BlockedArray` |
69 | | - # rather than a `BlockSparseArray`. |
70 | | - # See: https://github.com/ITensor/GradedUnitRanges.jl/issues/9 |
71 | | - @test_broken a isa BlockSparseArray |
| 67 | + @test a isa BlockSparseArray |
72 | 68 | (r1,) = axes(a) |
73 | 69 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
74 | 70 | @test blocklengths(r1) == [1, 1] |
75 | 71 |
|
76 | 72 | t = SiteType("S=1/2"; gradings=("Sz",)) |
77 | 73 | a = op("σ⁺", t) |
78 | 74 | @test a == [0 2; 0 0] |
79 | | - @test a isa AbstractBlockArray |
80 | | - @test_broken a isa BlockSparseArray |
| 75 | + @test a isa BlockSparseArray |
81 | 76 | (r1, r2) = axes(a) |
82 | 77 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
83 | 78 | @test blocklengths(r1) == [1, 1] |
84 | | - # TODO: This is a bug in indexing with GradedUnitRangeDual, fix this. |
85 | | - @test_broken blocklabels(r2) == |
| 79 | + @test blocklabels(r2) == |
86 | 80 | [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
87 | 81 | @test blocklengths(r2) == [1, 1] |
88 | 82 | end |
|
97 | 91 |
|
98 | 92 | i′ = prime(i) |
99 | 93 | a = op("σ⁺", i) |
100 | | - # TODO: The indices should be `(i′, dual(i))`. |
101 | | - @test a == ITensor([0 2; 0 0], (i′, i)) |
| 94 | + @test a == ITensor([0 2; 0 0], (i′, dual(i))) |
| 95 | + @test all(isdual.(axes(a)) .== (false, true)) |
102 | 96 | a′ = dename(a) |
103 | | - @test a′ isa AbstractBlockArray |
104 | | - @test_broken a′ isa BlockSparseArray |
| 97 | + @test a′ isa BlockSparseArray |
105 | 98 | # TODO: Test these without denaming `a`. |
106 | 99 | (r1, r2) = axes(a′) |
107 | 100 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
108 | 101 | @test blocklengths(r1) == [1, 1] |
109 | | - # TODO: This is a bug in indexing with GradedUnitRangeDual, fix this. |
110 | | - @test_broken blocklabels(r2) == |
| 102 | + @test blocklabels(r2) == |
111 | 103 | [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
112 | 104 | @test blocklengths(r2) == [1, 1] |
113 | 105 | end |
0 commit comments