@@ -830,6 +830,10 @@ V = Vect[I](values(I)[k] => 1 for k in 1:length(values(I)))
830830 end
831831end
832832
833+ # no conversion tests because no fusion tensor
834+ # no permute tests: NoBraiding()
835+
836+ # TODO ? test only for i>j?
833837@timedtestset " Tensors with symmetry involving $Istr ($i , $j )" verbose = true for i in 1 : r, j in 1 : r
834838 VC = (Vect[I]((i, i, label) => 1 for label in 1 : MTK. _numlabels (I, i, i)),
835839 Vect[I](one (I (i, i, 1 )) => 2 ),
@@ -872,18 +876,14 @@ end
872876 Vect[I](one (I (i, i, 1 )) => 2 , rand_object (I, i, i) => 3 )
873877 )
874878
875- Vcol = i != j ? (VC, VD, VM1, VM2, VMop1, VMop2) : (VC,) # avoid duplicate runs
879+ Vcol = i != j ? (VM1, VM2, VMop1, VMop2) : (VC,) # avoid duplicate runs
876880
877881 for V in Vcol
878882 V1, V2, V3, V4, V5 = V
879883 @timedtestset " Basic tensor properties" begin
880- W = V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5 # fusion matters
884+ W = i == j ? V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5 : V3 ⊗ V4 ⊗ V5 # fusion matters
881885 for T in (Int, Float32, Float64, ComplexF32, ComplexF64, BigFloat)
882- t = @constinferred zeros (T, W)
883- if isempty (t. data) # non-diagonal sector fuses poorly
884- W = V3 ⊗ V4 ⊗ V5
885- t = @constinferred zeros (T, W) # also empty because M isn't diagonal so can't fuse to empty space
886- end
886+ t = @constinferred zeros (T, W) # empty for i != j b/c blocks are module-graded
887887 @test @constinferred (hash (t)) == hash (deepcopy (t))
888888 @test scalartype (t) == T
889889 @test norm (t) == 0
905905 end
906906 end
907907 end
908+
908909 @timedtestset " Tensor Dict conversion" begin
909910 W = V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5 # rewritten to be compatible with module fusion
910911 for T in (Int, Float32, ComplexF64)
913914 @test t == convert (TensorMap, d)
914915 end
915916 end
916- # no tensor array conversion tests: no fusion tensor
917+
917918 @timedtestset " Basic linear algebra" begin
918919 W = V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5
919920 for T in (Float32, ComplexF64)
970971 end
971972 end
972973 end
974+
973975 @timedtestset " Trivial space insertion and removal" begin
974976 W = V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5
975977 for T in (Float32, ComplexF64)
@@ -1004,7 +1006,7 @@ end
10041006 @test @constinferred (removeunit (t5, 4 )) == t
10051007 end
10061008 end
1007- # no basic linear algebra tests via conversion: no fusion tensor
1009+
10081010 @timedtestset " Tensor conversion" begin
10091011 W = V1 ⊗ V2
10101012 t = @constinferred randn (W ← W) # fusion matters here
@@ -1016,8 +1018,7 @@ end
10161018 @test Base. promote_typeof (t, tc) == typeof (tc)
10171019 @test Base. promote_typeof (tc, t) == typeof (tc + t)
10181020 end
1019- # no permutations test via inner product invariance: NoBraiding
1020- # no permutations test via conversion: NoBraiding and no fusion tensor
1021+
10211022 @timedtestset " Full trace: test self-consistency" begin
10221023 t = rand (ComplexF64, V1 ⊗ V2 ← V1 ⊗ V2)
10231024 s = @constinferred tr (t)
@@ -1037,14 +1038,15 @@ end
10371038 @test isa (e, SectorMismatch)
10381039 end
10391040 end
1041+
10401042 @timedtestset " Partial trace: test self-consistency" begin
10411043 t = rand (ComplexF64, V3 ⊗ V4 ⊗ V5 ← V3 ⊗ V4 ⊗ V5) # rewritten to be compatible with module fusion
10421044 @planar t2[a; b] := t[c a d; c b d]
10431045 @planar t4[a b; c d] := t[e a b; e c d]
10441046 @planar t5[a; b] := t4[a c; b c]
10451047 @test t2 ≈ t5
10461048 end
1047- # no trace test via conversion: NoBraiding and no fusion tensor
1049+
10481050 @timedtestset " Trace and contraction" begin # TODO : find some version of this that works for off-diagonal case
10491051 t1 = rand (ComplexF64, V3 ⊗ V4 ⊗ V5)
10501052 t2 = rand (ComplexF64, V3 ⊗ V4 ⊗ V5)
@@ -1058,8 +1060,7 @@ end
10581060 @test ta ≈ tb
10591061 end
10601062 end
1061- # no tensor contraction test via conversion: NoBraiding and no fusion tensor
1062- # no index flipping tests: NoBraiding
1063+
10631064 @timedtestset " Multiplication of isometries: test properties" begin
10641065 W2 = V4 ⊗ V5
10651066 W1 = W2 ⊗ (rightoneunit (V5) ⊕ rightoneunit (V5))
@@ -1076,6 +1077,7 @@ end
10761077 end
10771078 end
10781079 end
1080+
10791081 @timedtestset " Multiplication and inverse: test compatibility" begin
10801082 W1 = V1 ⊗ V2
10811083 W2 = V3 ⊗ V4 ⊗ V5
@@ -1094,7 +1096,7 @@ end
10941096 @test tp ≈ tp * tp
10951097 end
10961098 end
1097- # no multiplication and inverse test via conversion: NoBraiding and no fusion tensor
1099+
10981100 @timedtestset " diag/diagm" begin
10991101 W = V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5
11001102 t = randn (ComplexF64, W)
@@ -1103,6 +1105,7 @@ end
11031105 @test LinearAlgebra. isdiag (D)
11041106 @test LinearAlgebra. diag (D) == d
11051107 end
1108+
11061109 @timedtestset " Factorization" begin
11071110 WL = V3 ⊗ V4 ⊗ V2 ← V1' ⊗ V5' # old left permute resulted in this space
11081111 WR = V3 ⊗ V4 ← V2' ⊗ V1' ⊗ V5' # old right permute
@@ -1179,10 +1182,10 @@ end
11791182 @testset " cond and rank" begin
11801183 d1 = dim (codomain (t))
11811184 d2 = dim (domain (t))
1182- @test rank (t) == min (d1, d2)
1185+ @test rank (t) ≈ min (d1, d2) # reduced to approx
11831186 if isdiag # leftnull doesn't work for off-diagonal case
11841187 M = leftnull (t)
1185- @test rank (M) == max (d1, d2) - min (d1, d2)
1188+ @test rank (M) ≈ max (d1, d2) - min (d1, d2) # reduced to approx
11861189 end
11871190 t2 = unitary (T, V1 ⊗ V2, V1 ⊗ V2)
11881191 @test cond (t2) ≈ one (real (T))
@@ -1271,6 +1274,7 @@ end
12711274 end
12721275 end
12731276 end
1277+
12741278 @timedtestset " Tensor truncation" begin
12751279 for T in (Float32, ComplexF64)
12761280 # Test both a normal tensor and an adjoint one.
@@ -1295,7 +1299,7 @@ end
12951299 end
12961300 end
12971301 end
1298- # no tensor functions tests: NoBraiding and no fusion tensor
1302+
12991303 @timedtestset " Sylvester equation" begin
13001304 for T in (Float32, ComplexF64)
13011305 tA = rand (T, V1 ⊗ V2, V1 ⊗ V2) # rewritten for modules
@@ -1311,6 +1315,7 @@ end
13111315 # no reshape test: NoBraiding and no fusion tensor
13121316 end
13131317 end
1318+
13141319 @timedtestset " Tensor product: test via norm preservation" begin
13151320 for T in (Float32, ComplexF64)
13161321 t1 = rand (T, V3 ⊗ V4 ⊗ V5 ← V1 ⊗ V2)
@@ -1323,8 +1328,8 @@ end
13231328 @test norm (t) ≈ norm (t1) * norm (t2)
13241329 end
13251330 end
1326- # no tensor product test via conversion: NoBraiding and no fusion tensor
1327- @timedtestset " Tensor product: test via tensor contraction" begin # works for diagonal case
1331+
1332+ @timedtestset " Tensor product: test via tensor contraction" begin
13281333 W = V3 ⊗ V4 ⊗ V5 ← V1 ⊗ V2
13291334 isdiag = all (a. i == a. j for a in blocksectors (W))
13301335 for T in (Float32, ComplexF64)
0 commit comments