Skip to content

Commit 8562fe7

Browse files
committed
tests: more tests
1 parent baa9e1f commit 8562fe7

File tree

5 files changed

+47
-37
lines changed

5 files changed

+47
-37
lines changed

test/classicalmodels_test.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ using Random
55

66
Random.seed!(1234)
77

8-
export classicalisingmpo, exactZ, isingnetwork
8+
import TensorRenormalizationGroups.KrylovKit.initialize
9+
10+
export classicalisingmpo, exactZ, isingnetwork, initialize
911

1012
function statmechmpo(β, h, D)
1113
δ1 = zeros(D, D, D, D)

test/ctmrg_test.jl

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@testsetup module SetupCTMRG
22
using Reexport
33
@reexport using TensorKit, TensorRenormalizationGroups, TestExtras, CircularArrays
4+
@reexport import TensorRenormalizationGroups.KrylovKit.initialize
45
end
56

67
@testitem "Corner Methods" setup = [SetupCTMRG] begin
@@ -34,7 +35,7 @@ end
3435

3536
@test scalartype(corners) == ComplexF64
3637

37-
@test ITC.chispace(corners) == s
38+
@test TRGroups.chispace(corners) == s
3839
end
3940

4041
@testitem "CTMRG" setup = [SetupCTMRG] begin
@@ -52,10 +53,10 @@ end
5253

5354
alg = CTMRG(; verbose=false, bonddim=1, randinit=false)
5455

55-
uc = ITC.ensure_contractable(net)
56+
uc = TRGroups.ensure_contractable(net)
5657

5758
@testset "Initialization" verbose = true begin
58-
ten = @constinferred(ITC.inittensors(uc, alg))
59+
ten = @constinferred(TRGroups.inittensors(uc, alg))
5960

6061
st = @constinferred(initialize(uc, alg))
6162

@@ -65,22 +66,22 @@ end
6566

6667
for sp in convert.(ProductSpace, domain(ta))
6768
for ch in convert.(ProductSpace, (ℂ^2, sp, ℂ^6))
68-
eiso = @constinferred(ITC.get_embedding_isometry(sp, ch))
69+
eiso = @constinferred(TRGroups.get_embedding_isometry(sp, ch))
6970

7071
@test codomain(eiso) == sp
7172
@test domain(eiso) == ch
7273
end
73-
riso = @constinferred(ITC.get_removal_isometry(sp))
74+
riso = @constinferred(TRGroups.get_removal_isometry(sp))
7475

7576
@test codomain(riso) == sp
7677
@test domain(riso) == one(sp)
7778
end
7879

79-
c_raw = @constinferred(ITC.initcorners(uc, chi))
80-
e_raw = @constinferred(ITC.initedges(uc, chi))
80+
c_raw = @constinferred(TRGroups.initcorners(uc, chi))
81+
e_raw = @constinferred(TRGroups.initedges(uc, chi))
8182

82-
@constinferred(ITC.randomize_if_zero!(c_raw))
83-
@constinferred(ITC.randomize_if_zero!(e_raw))
83+
@constinferred(TRGroups.randomize_if_zero!(c_raw))
84+
@constinferred(TRGroups.randomize_if_zero!(e_raw))
8485

8586
C1, C2, C3, C4 = c_raw
8687
T1, T2, T3, T4 = c_raw
@@ -111,18 +112,18 @@ end
111112
end
112113

113114
@testset "Error calculation" verbose = true begin
114-
corn = ITC.initcorners(uc, chi)
115+
corn = TRGroups.initcorners(uc, chi)
115116
state = initialize(uc, alg)
116117

117-
Ss = @constinferred(ITC.initerror(state.primary))
118+
Ss = @constinferred(TRGroups.initerror(state.primary))
118119
Ss_old = deepcopy(Ss)
119120

120-
@test isa(@constinferred(ITC.ctmerror!(Ss, corn)), AbstractFloat)
121+
@test isa(@constinferred(TRGroups.ctmerror!(Ss, corn)), AbstractFloat)
121122
# Singular values should have updated:
122123
@test Ss !== Ss_old
123124
# Should get zero error with corners unchanged:
124125
C1, C2, C3, C4 = corn
125-
@test @constinferred(ITC.boundaryerror!(Ss[1], C1)) zero.(eltype.(C1))
126+
@test @constinferred(TRGroups.boundaryerror!(Ss[1], C1)) zero.(eltype.(C1))
126127

127128
end
128129
end

test/misc_test.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,26 @@ end
2424
test_t = (p1, p2, p3)
2525

2626
@testset "Utils" verbose = true begin
27-
@test space(ITC._transpose(t)) == ((s4' * s5') (s2' * s3'))
28-
@test @constinferred(convert(Array, ITC._transpose(t))) ==
27+
@test space(TRGroups._transpose(t)) == ((s4' * s5') (s2' * s3'))
28+
@test @constinferred(convert(Array, TRGroups._transpose(t))) ==
2929
permutedims(convert(Array, t), (3, 4, 1, 2))
30-
@test @constinferred(ITC.permutedom(t, (2, 1))) == permute(t, (1, 2), (4, 3))
31-
@test @constinferred(ITC.permutecod(t, (2, 1))) == permute(t, (2, 1), (3, 4))
30+
@test @constinferred(TRGroups.permutedom(t, (2, 1))) == permute(t, (1, 2), (4, 3))
31+
@test @constinferred(TRGroups.permutecod(t, (2, 1))) == permute(t, (2, 1), (3, 4))
3232

3333
perm = [1:10...]
3434

35-
@test isa(@constinferred(ITC.tcircshift(Tuple(perm), 0)), NTuple{10,Int})
35+
@test isa(@constinferred(TRGroups.tcircshift(Tuple(perm), 0)), NTuple{10,Int})
3636

3737
for i in (-1, 0, 1)
38-
@test ITC.tcircshift(Tuple(perm), i) == Tuple(circshift(perm, i))
38+
@test TRGroups.tcircshift(Tuple(perm), i) == Tuple(circshift(perm, i))
3939
end
4040

4141
for tn in test_t
42-
@test @constinferred(ITC.rotate(tn, 0)) == tn
43-
@test domain(ITC.rotate(tn, 1)) == s5' * s2 * s3 * s4'
42+
@test @constinferred(TRGroups.rotate(tn, 0)) == tn
43+
@test domain(TRGroups.rotate(tn, 1)) == s5' * s2 * s3 * s4'
4444
end
45-
@test @constinferred(ITC.rotate(tp, 0)) == tp
46-
@test domain(ITC.rotate(tp, 1)[1]) == s5' * s2 * s3 * s4'
47-
@test codomain(ITC.rotate(tp, 1)[2]) == s5' * s2 * s3 * s4'
45+
@test @constinferred(TRGroups.rotate(tp, 0)) == tp
46+
@test domain(TRGroups.rotate(tp, 1)[1]) == s5' * s2 * s3 * s4'
47+
@test codomain(TRGroups.rotate(tp, 1)[2]) == s5' * s2 * s3 * s4'
4848
end
4949
end

test/unitcell_test.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ end
4747
@test isa(ucc .* matf, TC)
4848
end
4949
@testset "Misc" begin
50-
@test isa(ITC.getdata(ucf), CircularArray)
51-
@test ITC.datatype(TF) == Matrix{Float64}
50+
@test isa(TRGroups.getdata(ucf), CircularArray)
51+
@test TRGroups.datatype(TF) == Matrix{Float64}
5252
end
5353
end

test/vumps_test.jl

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ end
2424
cl = C[1, 1]
2525
cr = C[0, 1]
2626

27-
@test isa(ITC._similar_ac(a, cl), typeof(a))
28-
@test isa(ITC._similar_ac(cr, a), typeof(a))
27+
@test isa(TRGroups._similar_ac(a, cl), typeof(a))
28+
@test isa(TRGroups._similar_ac(cr, a), typeof(a))
2929

30-
@test ITC.centraltensor(C, A)[1, 1] == ITC.mulbond(cr, a)
31-
@test ITC.centraltensor(A, C)[1, 1] == ITC.mulbond(a, cl)
30+
@test TRGroups.centraltensor(C, A)[1, 1] == TRGroups.mulbond(cr, a)
31+
@test TRGroups.centraltensor(A, C)[1, 1] == TRGroups.mulbond(a, cl)
3232

3333
mps = @constinferred(MPS(A))
3434
@test @constinferred(scalartype(mps)) == T
3535

3636
AL, C, AR, AC = mps
37-
@test all((AL, C, AR, AC) == ITC.unpack(mps))
37+
@test all((AL, C, AR, AC) == TRGroups.unpack(mps))
3838
@testset "Mixed canonical form" begin
3939
let mps = MPS(rand, T, ds, χs1), C = mps.C
4040
AL, C, AR, AC = mps
@@ -43,13 +43,20 @@ end
4343

4444
mps = @constinferred(MPS(rand, T, ds, χs))
4545

46-
for uc in ITC.unpack(mps)
47-
@test ITC.scalartype(uc) == T
46+
physbonds = UnitCell{SquareSymmetric}(fill(ComplexSpace(2), 2, 2))
47+
virtbonds = UnitCell{SquareSymmetric}(fill(ComplexSpace(2), 2, 2))
48+
mps_sym = MPS(rand, T, physbonds, virtbonds)
49+
50+
@test TRGroups.geometrytype(mps_sym.C) == SquareSymmetric
51+
52+
for uc in TRGroups.unpack(mps)
53+
@test TRGroups.scalartype(uc) == T
4854
end
4955

50-
@test ITC.isgauged(mps) == 1
51-
@test ITC.isgauged(MPS(A, C, A, A)) == 0
52-
@test ITC.isgauged(MPS(similar(A), C, A, A)) == -1
56+
@test TRGroups.isgauged(mps) == 1
57+
@test TRGroups.isgauged(mps_sym) == 1
58+
@test TRGroups.isgauged(MPS(A, C, A, A)) == 0
59+
@test TRGroups.isgauged(MPS(similar(A), C, A, A)) == -1
5360
end
5461
end
5562
end

0 commit comments

Comments
 (0)