Skip to content

Commit 6e990e2

Browse files
committed
apply tensors test changes from #263
1 parent db80ca8 commit 6e990e2

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

test/tensors/tensors.jl

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ end
2727
for V in spacelist
2828
I = sectortype(first(V))
2929
Istr = type_repr(I)
30+
symmetricbraiding = isa(BraidingStyle(I), SymmetricBraiding)
3031
println("---------------------------------------")
3132
println("Tensors with symmetry: $Istr")
3233
println("---------------------------------------")
@@ -224,6 +225,7 @@ for V in spacelist
224225
@test Base.promote_typeof(tc, t) == typeof(tc + t)
225226
end
226227
@timedtestset "Permutations: test via inner product invariance" begin
228+
@assert symmetricbraiding
227229
W = V1 V2 V3 V4 V5
228230
t = rand(ComplexF64, W)
229231
t′ = randn!(similar(t))
@@ -237,7 +239,7 @@ for V in spacelist
237239
@test dot(t2′, t2) dot(t′, t) dot(transpose(t2′), transpose(t2))
238240
end
239241

240-
t3 = VERSION < v"1.7" ? repartition(t, k) : @constinferred repartition(t, $k)
242+
t3 = @constinferred repartition(t, $k)
241243
@test norm(t3) norm(t)
242244
t3′ = @constinferred repartition!(similar(t3), t′)
243245
@test norm(t3′) norm(t′)
@@ -269,28 +271,27 @@ for V in spacelist
269271
end
270272
end
271273
@timedtestset "Full trace: test self-consistency" begin
272-
t = rand(ComplexF64, V1 V2' V2 V1')
273-
t2 = permute(t, ((1, 2), (4, 3)))
274-
s = @constinferred tr(t2)
275-
@test conj(s) tr(t2')
274+
t = rand(ComplexF64, V1 V2' V1 V2')
275+
s = @constinferred tr(t)
276+
@test conj(s) tr(t')
276277
if !isdual(V1)
277-
t2 = twist!(t2, 1)
278+
t2 = twist!(t, 1)
278279
end
279280
if isdual(V2)
280-
t2 = twist!(t2, 2)
281+
t2 = twist!(t, 2)
281282
end
282283
ss = tr(t2)
283-
@tensor s2 = t[a, b, b, a]
284-
@tensor t3[a, b] := t[a, c, c, b]
285-
@tensor s3 = t3[a, a]
284+
@plansor s2 = t[a b; a b]
285+
@plansor t3[a; b] := t[a c; b c]
286+
@plansor s3 = t3[a; a]
286287
@test ss s2
287288
@test ss s3
288289
end
289290
@timedtestset "Partial trace: test self-consistency" begin
290-
t = rand(ComplexF64, V1 V2' V3 V2 V1' V3')
291-
@tensor t2[a, b] := t[c, d, b, d, c, a]
292-
@tensor t4[a, b, c, d] := t[d, e, b, e, c, a]
293-
@tensor t5[a, b] := t4[a, b, c, c]
291+
t = rand(ComplexF64, V1 V2 V3 V1 V2 V3)
292+
@planar t2[a; b] := t[c d b; c d a]
293+
@planar t4[a b; c d] := t[e d c; e b a]
294+
@planar t5[a; b] := t4[a c; b c]
294295
@test t2 t5
295296
end
296297
if BraidingStyle(I) isa Bosonic && hasfusiontensor(I)
@@ -334,6 +335,7 @@ for V in spacelist
334335
end
335336
end
336337
@timedtestset "Index flipping: test via explicit flip" begin
338+
@assert symmetricbraiding
337339
t = rand(ComplexF64, V1 V1' V1' V1)
338340
F1 = unitary(flip(V1), V1)
339341

@@ -347,6 +349,7 @@ for V in spacelist
347349
@test twist!(flip(t, 4), 4) tf
348350
end
349351
@timedtestset "Index flipping: test via contraction" begin
352+
@assert symmetricbraiding
350353
t1 = rand(ComplexF64, V1 V2 V3 V4)
351354
t2 = rand(ComplexF64, V2' V5 V4' V1)
352355
@tensor ta[a, b] := t1[x, y, a, z] * t2[y, b, z, x]
@@ -529,6 +532,7 @@ for V in spacelist
529532
end
530533
end
531534
@timedtestset "Tensor product: test via tensor contraction" begin
535+
@assert symmetricbraiding
532536
for T in (Float32, ComplexF64)
533537
t1 = rand(T, V2 V3 V1)
534538
t2 = rand(T, V2 V1 V3)

0 commit comments

Comments
 (0)