Skip to content

Commit 6efcb05

Browse files
borisdevoslkdvos
authored andcommitted
use the const TK in tests where appropriate
1 parent 0fb4d64 commit 6efcb05

File tree

5 files changed

+30
-30
lines changed

5 files changed

+30
-30
lines changed

test/ad.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function ChainRulesTestUtils.test_approx(
3333
end
3434

3535
# make sure that norms are computed correctly:
36-
function FiniteDifferences.to_vec(t::TensorKit.SectorDict)
36+
function FiniteDifferences.to_vec(t::TK.SectorDict)
3737
T = scalartype(valtype(t))
3838
vec = mapreduce(vcat, t; init = T[]) do (c, b)
3939
return reshape(b, :) .* sqrt(dim(c))
@@ -43,7 +43,7 @@ function FiniteDifferences.to_vec(t::TensorKit.SectorDict)
4343
function from_vec(x_real)
4444
x = T <: Real ? x_real : reinterpret(T, x_real)
4545
ctr = 0
46-
return TensorKit.SectorDict(
46+
return TK.SectorDict(
4747
c => (
4848
n = length(b);
4949
b′ = reshape(view(x, ctr .+ (1:n)), size(b)) ./ sqrt(dim(c));
@@ -197,7 +197,7 @@ spacelist = (
197197

198198
for V in spacelist
199199
I = sectortype(eltype(V))
200-
Istr = TensorKit.type_repr(I)
200+
Istr = TK.type_repr(I)
201201
eltypes = isreal(sectortype(eltype(V))) ? (Float64, ComplexF64) : (ComplexF64,)
202202
symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding
203203
println("---------------------------------------")

test/diagonal.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ diagspacelist = (
3232
b2 = @constinferred block(t, first(blocksectors(t)))
3333
@test b1 == b2
3434
@test eltype(bs) === Pair{typeof(c), typeof(b1)}
35-
@test typeof(b1) === TensorKit.blocktype(t)
35+
@test typeof(b1) === TK.blocktype(t)
3636
# basic linear algebra
3737
@test isa(@constinferred(norm(t)), real(T))
3838
@test norm(t)^2 ≈ dot(t, t)

test/fusiontrees.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ println("------------------------------------")
22
println("Fusion Trees")
33
println("------------------------------------")
44
ti = time()
5-
@timedtestset "Fusion trees for $(TensorKit.type_repr(I))" verbose = true for I in
5+
@timedtestset "Fusion trees for $(TK.type_repr(I))" verbose = true for I in
66
sectorlist
7-
Istr = TensorKit.type_repr(I)
7+
Istr = TK.type_repr(I)
88
N = 5
99
out = ntuple(n -> randsector(I), N)
1010
isdual = ntuple(n -> rand(Bool), N)
@@ -446,12 +446,12 @@ ti = time()
446446
ip = invperm(p)
447447
ip1, ip2 = ip[1:N], ip[(N + 1):(2N)]
448448

449-
d = @constinferred TensorKit.permute(f1, f2, p1, p2)
449+
d = @constinferred TK.permute(f1, f2, p1, p2)
450450
@test dim(incoming)
451451
sum(abs2(coef) * dim(f1.coupled) for ((f1, f2), coef) in d)
452452
d2 = Dict{typeof((f1, f2)), valtype(d)}()
453453
for ((f1′, f2′), coeff) in d
454-
d′ = TensorKit.permute(f1′, f2′, ip1, ip2)
454+
d′ = TK.permute(f1′, f2′, ip1, ip2)
455455
for ((f1′′, f2′′), coeff2) in d′
456456
d2[(f1′′, f2′′)] = get(d2, (f1′′, f2′′), zero(coeff)) +
457457
coeff2 * coeff
@@ -590,7 +590,7 @@ ti = time()
590590
end
591591
end
592592
end
593-
TensorKit.empty_globalcaches!()
593+
TK.empty_globalcaches!()
594594
end
595595
tf = time()
596596
printstyled(

test/spaces.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ println("------------------------------------")
6363
@test @constinferred(sectortype(V)) == Trivial
6464
@test ((@constinferred sectors(V))...,) == (Trivial(),)
6565
@test length(sectors(V)) == 1
66-
@test @constinferred(TensorKit.hassector(V, Trivial()))
66+
@test @constinferred(TK.hassector(V, Trivial()))
6767
@test @constinferred(dim(V)) == d == @constinferred(dim(V, Trivial()))
6868
@test dim(@constinferred(zerospace(V))) == 0
6969
@test (sectors(zerospace(V))...,) == ()
70-
@test @constinferred(TensorKit.axes(V)) == Base.OneTo(d)
70+
@test @constinferred(TK.axes(V)) == Base.OneTo(d)
7171
@test ℝ^d == ℝ[](d) == CartesianSpace(d) == typeof(V)(d)
7272
W = @constinferred ℝ^1
7373
@test @constinferred(unitspace(V)) == W == unitspace(typeof(V))
@@ -109,11 +109,11 @@ println("------------------------------------")
109109
@test @constinferred(sectortype(V)) == Trivial
110110
@test ((@constinferred sectors(V))...,) == (Trivial(),)
111111
@test length(sectors(V)) == 1
112-
@test @constinferred(TensorKit.hassector(V, Trivial()))
112+
@test @constinferred(TK.hassector(V, Trivial()))
113113
@test @constinferred(dim(V)) == d == @constinferred(dim(V, Trivial()))
114114
@test dim(@constinferred(zerospace(V))) == 0
115115
@test (sectors(zerospace(V))...,) == ()
116-
@test @constinferred(TensorKit.axes(V)) == Base.OneTo(d)
116+
@test @constinferred(TK.axes(V)) == Base.OneTo(d)
117117
@test ℂ^d == Vect[Trivial](d) == Vect[](Trivial() => d) == ℂ[](d) == typeof(V)(d)
118118
W = @constinferred ℂ^1
119119
@test @constinferred(unitspace(V)) == W == unitspace(typeof(V))
@@ -151,10 +151,10 @@ println("------------------------------------")
151151
@test isdual(V')
152152
@test !isdual(conj(V))
153153
@test isdual(conj(V'))
154-
@test !TensorKit.isconj(V)
155-
@test !TensorKit.isconj(V')
156-
@test TensorKit.isconj(conj(V))
157-
@test TensorKit.isconj(conj(V'))
154+
@test !TK.isconj(V)
155+
@test !TK.isconj(V')
156+
@test TK.isconj(conj(V))
157+
@test TK.isconj(conj(V'))
158158
@test isa(V, VectorSpace)
159159
@test isa(V, ElementarySpace)
160160
@test !isa(InnerProductStyle(V), HasInnerProduct)
@@ -163,20 +163,20 @@ println("------------------------------------")
163163
@test @constinferred(dual(V)) != @constinferred(conj(V)) != V
164164
@test @constinferred(field(V)) == ℂ
165165
@test @constinferred(sectortype(V)) == Trivial
166-
@test @constinferred(TensorKit.hassector(V, Trivial()))
166+
@test @constinferred(TK.hassector(V, Trivial()))
167167
@test @constinferred(dim(V)) == d == @constinferred(dim(V, Trivial()))
168-
@test @constinferred(TensorKit.axes(V)) == Base.OneTo(d)
168+
@test @constinferred(TK.axes(V)) == Base.OneTo(d)
169169
end
170170
171-
@timedtestset "ElementarySpace: $(TensorKit.type_repr(Vect[I]))" for I in sectorlist
171+
@timedtestset "ElementarySpace: $(TK.type_repr(Vect[I]))" for I in sectorlist
172172
if Base.IteratorSize(values(I)) === Base.IsInfinite()
173173
set = unique(vcat(unit(I), [randsector(I) for k in 1:10]))
174174
gen = (c => 2 for c in set)
175175
else
176176
gen = (values(I)[k] => (k + 1) for k in 1:length(values(I)))
177177
end
178178
V = GradedSpace(gen)
179-
@test eval(Meta.parse(TensorKit.type_repr(typeof(V)))) == typeof(V)
179+
@test eval(Meta.parse(TK.type_repr(typeof(V)))) == typeof(V)
180180
@test eval(Meta.parse(sprint(show, V))) == V
181181
@test eval(Meta.parse(sprint(show, V'))) == V'
182182
@test V' == GradedSpace(gen; dual = true)
@@ -222,12 +222,12 @@ println("------------------------------------")
222222
@test @constinferred(field(V)) ==
223223
@test @constinferred(sectortype(V)) == I
224224
slist = @constinferred sectors(V)
225-
@test @constinferred(TensorKit.hassector(V, first(slist)))
225+
@test @constinferred(TK.hassector(V, first(slist)))
226226
@test @constinferred(dim(V)) == sum(dim(s) * dim(V, s) for s in slist)
227227
@test @constinferred(reduceddim(V)) == sum(dim(V, s) for s in slist)
228228
@constinferred dim(V, first(slist))
229229
if hasfusiontensor(I)
230-
@test @constinferred(TensorKit.axes(V)) == Base.OneTo(dim(V))
230+
@test @constinferred(TK.axes(V)) == Base.OneTo(dim(V))
231231
end
232232
@test @constinferred((V, zerospace(V))) == V
233233
@test @constinferred((V, V)) == Vect[I](c => 2dim(V, c) for c in sectors(V))
@@ -398,7 +398,7 @@ println("------------------------------------")
398398

399399
@timedtestset "HomSpace" begin
400400
for (V1, V2, V3, V4, V5) in (Vtr, Vℤ₃, VSU₂)
401-
W = TensorKit.HomSpace(V1 V2, V3 V4 V5)
401+
W = TK.HomSpace(V1 V2, V3 V4 V5)
402402
@test W == (V3 V4 V5 V1 V2)
403403
@test W == (V1 V2 V3 V4 V5)
404404
@test W' == (V1 ⊗ V2 → V3 ⊗ V4 ⊗ V5)
@@ -415,7 +415,7 @@ println("------------------------------------")
415415
@test W == deepcopy(W)
416416
@test W == @constinferred permute(W, ((1, 2), (3, 4, 5)))
417417
@test permute(W, ((2, 4, 5), (3, 1))) == (V2 ⊗ V4' V5' ← V3 ⊗ V1')
418-
@test (V1 V2 V1 V2) == @constinferred TensorKit.compose(W, W')
418+
@test (V1 V2 V1 V2) == @constinferred TK.compose(W, W')
419419
@test (V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5 ⊗ unitspace(V5)) ==
420420
@constinferred(insertleftunit(W)) ==
421421
@constinferred(insertrightunit(W))
@@ -435,5 +435,5 @@ println("------------------------------------")
435435
@test_throws BoundsError insertleftunit(one(V1) V1, 0)
436436
end
437437
end
438-
TensorKit.empty_globalcaches!()
438+
TK.empty_globalcaches!()
439439
end

test/tensors.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ end
1717

1818
for V in spacelist
1919
I = sectortype(first(V))
20-
Istr = TensorKit.type_repr(I)
20+
Istr = TK.type_repr(I)
2121
println("---------------------------------------")
2222
println("Tensors with symmetry: $Istr")
2323
println("---------------------------------------")
@@ -42,7 +42,7 @@ for V in spacelist
4242
b2 = @constinferred block(t, first(blocksectors(t)))
4343
@test b1 == b2
4444
@test eltype(bs) === Pair{typeof(c), typeof(b1)}
45-
@test typeof(b1) === TensorKit.blocktype(t)
45+
@test typeof(b1) === TK.blocktype(t)
4646
@test typeof(c) === sectortype(t)
4747
end
4848
end
@@ -104,7 +104,7 @@ for V in spacelist
104104
b2 = @constinferred block(t', first(blocksectors(t')))
105105
@test b1 == b2
106106
@test eltype(bs) === Pair{typeof(c), typeof(b1)}
107-
@test typeof(b1) === TensorKit.blocktype(t')
107+
@test typeof(b1) === TK.blocktype(t')
108108
@test typeof(c) === sectortype(t)
109109
# linear algebra
110110
@test isa(@constinferred(norm(t)), real(T))
@@ -550,7 +550,7 @@ for V in spacelist
550550
@test t3 ≈ t4
551551
end
552552
end
553-
TensorKit.empty_globalcaches!()
553+
TK.empty_globalcaches!()
554554
end
555555
556556
@timedtestset "Deligne tensor product: test via conversion" begin

0 commit comments

Comments
 (0)