Skip to content

Commit 44d9dad

Browse files
committed
Add insertunit tests for TensorMap
1 parent 6f74698 commit 44d9dad

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/tensors.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,32 @@ for V in spacelist
173173
@test w * w' == (w * w')^2
174174
end
175175
end
176+
@timedtestset "Trivial spaces" begin
177+
W = V1 V2 V3 V4 V5
178+
for T in (Float32, ComplexF64)
179+
t = @constinferred rand(T, W)
180+
t2 = @constinferred insertunit(t)
181+
@test numind(t2) == numind(t) + 1
182+
@test space(t2) == insertunit(space(t))
183+
@test scalartype(t2) === T
184+
@test t.data === t2.data
185+
t3 = @constinferred insertunit(t; copy=true)
186+
@test t.data !== t3.data
187+
for (c, b) in blocks(t)
188+
@test b == block(t3, c)
189+
end
190+
t4 = @constinferred insertunit(t, 4; dual=true)
191+
@test numin(t4) == numin(t) && numout(t4) == numout(t) + 1
192+
for (c, b) in blocks(t)
193+
@test b == block(t4, c)
194+
end
195+
t5 = @constinferred insertunit(t, 4; dual=true)
196+
@test numin(t5) == numin(t) + 1 && numout(t5) == numout(t)
197+
for (c, b) in blocks(t)
198+
@test b == block(t5, c)
199+
end
200+
end
201+
end
176202
if hasfusiontensor(I)
177203
@timedtestset "Basic linear algebra: test via conversion" begin
178204
W = V1 V2 V3 V4 V5

0 commit comments

Comments
 (0)