|
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 |
7 | 7 | using NamedDimsArrays: dename |
8 | | -using Test: @test, @test_broken, @testset |
| 8 | +using Test: @test, @testset |
9 | 9 |
|
10 | 10 | @testset "SymmetrySectorsExt" begin |
11 | 11 | t = SiteType("S=1/2"; gradings=("Sz",)) |
@@ -54,36 +54,27 @@ using Test: @test, @test_broken, @testset |
54 | 54 | @test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
55 | 55 | @test blocklengths(r2) == [1, 1] |
56 | 56 |
|
57 | | - # TODO: There is a bug slicing `BitVector` by `GradedOneTo` in Julia 1.11, |
58 | | - # investigate. See: https://github.com/ITensor/GradedUnitRanges.jl/issues/9 |
59 | 57 | t = SiteType("S=1/2"; gradings=("Sz",)) |
60 | | - @test state("0", t) == [1, 0] broken = VERSION ≥ v"1.11" |
| 58 | + @test state("0", t) == [1, 0] |
61 | 59 |
|
62 | 60 | # Force conversion to `Vector{Float64}` before conversion, |
63 | 61 | # since there is a bug slicing `BitVector` by `GradedOneTo`. |
64 | 62 | t = SiteType("S=1/2"; gradings=("Sz",)) |
65 | 63 | a = AbstractArray(2.0 * StateName("0"), t) |
66 | 64 | @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 |
| 65 | + @test a isa BlockSparseArray |
72 | 66 | (r1,) = axes(a) |
73 | 67 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
74 | 68 | @test blocklengths(r1) == [1, 1] |
75 | 69 |
|
76 | 70 | t = SiteType("S=1/2"; gradings=("Sz",)) |
77 | 71 | a = op("σ⁺", t) |
78 | 72 | @test a == [0 2; 0 0] |
79 | | - @test a isa AbstractBlockArray |
80 | | - @test_broken a isa BlockSparseArray |
| 73 | + @test a isa BlockSparseArray |
81 | 74 | (r1, r2) = axes(a) |
82 | 75 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
83 | 76 | @test blocklengths(r1) == [1, 1] |
84 | | - # TODO: This is a bug in indexing with GradedUnitRangeDual, fix this. |
85 | | - @test_broken blocklabels(r2) == |
86 | | - [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
| 77 | + @test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
87 | 78 | @test blocklengths(r2) == [1, 1] |
88 | 79 | end |
89 | 80 |
|
|
97 | 88 |
|
98 | 89 | i′ = prime(i) |
99 | 90 | a = op("σ⁺", i) |
100 | | - # TODO: The indices should be `(i′, dual(i))`. |
101 | | - @test a == ITensor([0 2; 0 0], (i′, i)) |
| 91 | + @test a == ITensor([0 2; 0 0], (i′, dual(i))) |
| 92 | + @test all(isdual.(axes(a)) .== (false, true)) |
102 | 93 | a′ = dename(a) |
103 | | - @test a′ isa AbstractBlockArray |
104 | | - @test_broken a′ isa BlockSparseArray |
| 94 | + @test a′ isa BlockSparseArray |
105 | 95 | # TODO: Test these without denaming `a`. |
106 | 96 | (r1, r2) = axes(a′) |
107 | 97 | @test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))] |
108 | 98 | @test blocklengths(r1) == [1, 1] |
109 | | - # TODO: This is a bug in indexing with GradedUnitRangeDual, fix this. |
110 | | - @test_broken blocklabels(r2) == |
111 | | - [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
| 99 | + @test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))] |
112 | 100 | @test blocklengths(r2) == [1, 1] |
113 | 101 | end |
0 commit comments