Skip to content

Commit 415d404

Browse files
github-actions[bot]CompatHelper Juliamtfishman
authored
CompatHelper: bump compat for BlockSparseArrays to 0.5 for package test, (keep existing compat) (#50)
Co-authored-by: CompatHelper Julia <[email protected]> Co-authored-by: Matt Fishman <[email protected]> Co-authored-by: mtfishman <[email protected]>
1 parent e527533 commit 415d404

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuantumOperatorDefinitions"
22
uuid = "826dd319-6fd5-459a-a990-3a4f214664bf"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.2.1"
4+
version = "0.2.2"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -19,7 +19,7 @@ QuantumOperatorDefinitionsGradedArraysExt = ["BlockArrays", "GradedArrays"]
1919

2020
[compat]
2121
BlockArrays = "1.3.0"
22-
GradedArrays = "0.3"
22+
GradedArrays = "0.4"
2323
ITensorBase = "0.2"
2424
LinearAlgebra = "1.10"
2525
NamedDimsArrays = "0.7"

ext/QuantumOperatorDefinitionsGradedArraysExt/QuantumOperatorDefinitionsGradedArraysExt.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
module QuantumOperatorDefinitionsGradedArraysExt
22

3-
using BlockArrays: blocklasts, blocklengths
4-
using GradedArrays: AbstractGradedUnitRange, GradedOneTo, gradedrange
5-
using GradedArrays.LabelledNumbers: label, labelled, unlabel
6-
using GradedArrays.SymmetrySectors: SectorProduct, U1, Z, ×, dual
3+
using BlockArrays: blocklasts, blocklength, blocklengths
4+
using GradedArrays:
5+
AbstractGradedUnitRange, GradedOneTo, SectorProduct, U1, Z, ×, dual, gradedrange, sectors
76
using QuantumOperatorDefinitions:
87
QuantumOperatorDefinitions,
98
@GradingType_str,
@@ -19,12 +18,15 @@ end
1918

2019
sortedunion(a, b) = sort(union(a, b))
2120
function QuantumOperatorDefinitions.combine_axes(a1::GradedOneTo, a2::GradedOneTo)
21+
blocklength(a1) == blocklength(a2) ||
22+
throw(ArgumentError("Axes must have the same number of blocks."))
23+
nblocks = blocklength(a1)
2224
return gradedrange(
23-
map(blocklengths(a1), blocklengths(a2)) do s1, s2
24-
l1 = unlabel(s1)
25-
l2 = unlabel(s2)
26-
@assert l1 == l2
27-
labelled(l1, label(s1) × label(s2))
25+
map(Base.OneTo(nblocks)) do i
26+
l1 = blocklengths(a1)[i]
27+
l2 = blocklengths(a2)[i]
28+
l1 == l2 || throw(ArgumentError("Blocks must have the same length."))
29+
return sectors(a1)[i] × sectors(a2)[i] => l1
2830
end,
2931
)
3032
end

test/Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1515
[compat]
1616
Aqua = "0.8.9"
1717
BlockArrays = "1"
18-
BlockSparseArrays = "0.4"
19-
GradedArrays = "0.3"
18+
BlockSparseArrays = "0.5"
19+
GradedArrays = "0.4"
2020
ITensorBase = "0.2"
2121
NamedDimsArrays = "0.7"
2222
QuantumOperatorDefinitions = "0.2"

test/test_gradedarraysext.jl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using BlockArrays: AbstractBlockArray, blocklengths
22
using BlockSparseArrays: BlockSparseArray
3-
using GradedArrays: blocklabels, dual, isdual
4-
using GradedArrays.SymmetrySectors: SectorProduct, U1, Z
3+
using GradedArrays: SectorProduct, U1, Z, dual, isdual, sectors
54
using ITensorBase: ITensor, Index, gettag, prime, settag
65
using NamedDimsArrays: dename
76
using QuantumOperatorDefinitions: OpName, SiteType, StateName, op, state
@@ -11,13 +10,13 @@ using Test: @test, @testset
1110
t = SiteType("S=1/2"; gradings=("Sz",))
1211
r = AbstractUnitRange(t)
1312
@test r == 1:2
14-
@test blocklabels(r) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
13+
@test sectors(r) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
1514
@test blocklengths(r) == [1, 1]
1615

1716
t = SiteType("Electron"; gradings=("Nf", "Sz"))
1817
r = AbstractUnitRange(t)
1918
@test r == 1:4
20-
@test blocklabels(r) == [
19+
@test sectors(r) == [
2120
SectorProduct((; Nf=U1(0), Sz=U1(0))),
2221
SectorProduct((; Nf=U1(1), Sz=U1(1))),
2322
SectorProduct((; Nf=U1(1), Sz=U1(-1))),
@@ -28,7 +27,7 @@ using Test: @test, @testset
2827
t = SiteType("Electron"; gradings=("Nf" => "NfA", "Sz" => "SzA"))
2928
r = AbstractUnitRange(t)
3029
@test r == 1:4
31-
@test blocklabels(r) == [
30+
@test sectors(r) == [
3231
SectorProduct((; NfA=U1(0), SzA=U1(0))),
3332
SectorProduct((; NfA=U1(1), SzA=U1(1))),
3433
SectorProduct((; NfA=U1(1), SzA=U1(-1))),
@@ -39,7 +38,7 @@ using Test: @test, @testset
3938
t = SiteType("Electron"; gradings=("NfParity", "Sz"))
4039
r = AbstractUnitRange(t)
4140
@test r == 1:4
42-
@test blocklabels(r) == [
41+
@test sectors(r) == [
4342
SectorProduct((; NfParity=Z{2}(0), Sz=U1(0))),
4443
SectorProduct((; NfParity=Z{2}(1), Sz=U1(1))),
4544
SectorProduct((; NfParity=Z{2}(1), Sz=U1(-1))),
@@ -49,9 +48,9 @@ using Test: @test, @testset
4948

5049
t = SiteType("S=1/2"; gradings=("Sz",))
5150
(r1, r2) = axes(OpName("σ⁺"), (t,))
52-
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
51+
@test sectors(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
5352
@test blocklengths(r1) == [1, 1]
54-
@test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))]
53+
@test sectors(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
5554
@test blocklengths(r2) == [1, 1]
5655

5756
t = SiteType("S=1/2"; gradings=("Sz",))
@@ -64,17 +63,17 @@ using Test: @test, @testset
6463
@test a == [2, 0]
6564
@test a isa BlockSparseArray
6665
(r1,) = axes(a)
67-
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
66+
@test sectors(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
6867
@test blocklengths(r1) == [1, 1]
6968

7069
t = SiteType("S=1/2"; gradings=("Sz",))
7170
a = op("σ⁺", t)
7271
@test a == [0 2; 0 0]
7372
@test a isa BlockSparseArray
7473
(r1, r2) = axes(a)
75-
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
74+
@test sectors(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
7675
@test blocklengths(r1) == [1, 1]
77-
@test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))]
76+
@test sectors(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
7877
@test blocklengths(r2) == [1, 1]
7978
end
8079

@@ -83,7 +82,7 @@ end
8382
@test gettag(i, "sitetype") == "S=1/2"
8483
# TODO: Test without denaming.
8584
@test dename(i) == 1:2
86-
@test blocklabels(dename(i)) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
85+
@test sectors(dename(i)) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
8786
@test blocklengths(dename(i)) == [1, 1]
8887

8988
i′ = prime(i)
@@ -94,8 +93,8 @@ end
9493
@test a′ isa BlockSparseArray
9594
# TODO: Test these without denaming `a`.
9695
(r1, r2) = axes(a′)
97-
@test blocklabels(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
96+
@test sectors(r1) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
9897
@test blocklengths(r1) == [1, 1]
99-
@test blocklabels(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(-1)))]
98+
@test sectors(r2) == [SectorProduct((; Sz=U1(0))), SectorProduct((; Sz=U1(1)))]
10099
@test blocklengths(r2) == [1, 1]
101100
end

0 commit comments

Comments
 (0)