Skip to content

Commit 98806b3

Browse files
committed
Fix tests
1 parent e52acb6 commit 98806b3

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

src/sitetype.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ function Base.AbstractUnitRange(t::SiteType)
7979
end
8080
return Base.OneTo(length(t))
8181
end
82-
# kwargs are passed for fancier constructors, like `ITensors.Index`.
8382
function (rangetype::Type{<:AbstractUnitRange})(t::SiteType)
8483
return rangetype(AbstractUnitRange(t))
8584
end

test/test_itensorbaseext.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using GradedUnitRanges: GradedUnitRanges
12
using ITensorBase: ITensor, Index, gettag, hastag, prime, settag
23
using NamedDimsArrays: dename
34
using QuantumOperatorDefinitions: OpName, SiteType, StateName, op, site, sites, state

test/test_symmetrysectorsext.jl

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using BlockArrays: AbstractBlockArray, blocklengths
22
using BlockSparseArrays: BlockSparseArray
3-
using GradedUnitRanges: blocklabels
3+
using GradedUnitRanges: blocklabels, dual, isdual
44
using ITensorBase: ITensor, Index, gettag, prime, settag
55
using QuantumOperatorDefinitions: OpName, SiteType, StateName, op, state
66
using SymmetrySectors: SectorProduct, U1, Z
@@ -64,25 +64,19 @@ using Test: @test, @test_broken, @testset
6464
t = SiteType("S=1/2"; gradings=("Sz",))
6565
a = AbstractArray(2.0 * StateName("0"), t)
6666
@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
7268
(r1,) = axes(a)
7369
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
7470
@test blocklengths(r1) == [1, 1]
7571

7672
t = SiteType("S=1/2"; gradings=("Sz",))
7773
a = op("σ⁺", t)
7874
@test a == [0 2; 0 0]
79-
@test a isa AbstractBlockArray
80-
@test_broken a isa BlockSparseArray
75+
@test a isa BlockSparseArray
8176
(r1, r2) = axes(a)
8277
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
8378
@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) ==
8680
[SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))]
8781
@test blocklengths(r2) == [1, 1]
8882
end
@@ -97,17 +91,15 @@ end
9791

9892
i′ = prime(i)
9993
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))
10296
a′ = dename(a)
103-
@test a′ isa AbstractBlockArray
104-
@test_broken a′ isa BlockSparseArray
97+
@test a′ isa BlockSparseArray
10598
# TODO: Test these without denaming `a`.
10699
(r1, r2) = axes(a′)
107100
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
108101
@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) ==
111103
[SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))]
112104
@test blocklengths(r2) == [1, 1]
113105
end

0 commit comments

Comments
 (0)