11using MultiTensorKit
2- using TensorKitSectors
2+ using TensorKitSectors, TensorKit
33using Test, TestExtras
44
55I = A4Object
7575 @test dual (s) == A4Object (j, i, MultiTensorKit. _get_dual_cache (I)[2 ][i, j][s. label])
7676 @test dual (dual (s)) == s
7777end
78+
79+ @testset " A4 Category ($i , $j ) left and right units" for i in 1 : 12 , j in 1 : 12
80+ Cij_obs = A4Object .(i, j, MultiTensorKit. _get_dual_cache (I)[2 ][i, j])
81+
82+ s = rand (Cij_obs, 1 )[1 ]
83+ sp = Vect[A4Object](s => 1 )
84+ W = sp ← sp
85+ for T in (Float32, ComplexF64)
86+ t = @constinferred rand (T, W)
87+
88+ for a in 1 : 2
89+ tl = @constinferred insertleftunit (t, Val (a))
90+ @test numind (tl) == numind (t) + 1
91+ @test space (tl) == insertleftunit (space (t), a)
92+ @test scalartype (tl) === T
93+ @test t. data === tl. data
94+ @test @constinferred (removeunit (tl, $ (a))) == t
95+
96+ tr = @constinferred insertrightunit (t, Val (a))
97+ @test numind (tr) == numind (t) + 1
98+ @test space (tr) == insertrightunit (space (t), a)
99+ @test scalartype (tr) === T
100+ @test t. data === tr. data
101+ @test @constinferred (removeunit (tr, $ (a + 1 ))) == t
102+ end
103+
104+ @test_throws ErrorException insertleftunit (t) # default should error here
105+ @test insertrightunit (t) isa TensorMap
106+ @test_throws ErrorException insertleftunit (t, numind (t) + 1 ) # same as default
107+ @test_throws ErrorException insertrightunit (t, numind (t) + 1 ) # not same as default
108+
109+ t2 = @constinferred insertrightunit (t; copy= true )
110+ @test t. data != = t2. data
111+ for (c, b) in blocks (t)
112+ @test b == block (t2, c)
113+ end
114+ @test @constinferred (removeunit (t2, $ (numind (t2)))) == t
115+ end
116+ end
0 commit comments