Skip to content

Commit e485bbb

Browse files
committed
Add tests removeunit
1 parent 68e93f0 commit e485bbb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

test/spaces.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ println("------------------------------------")
279279
@test @constinferred((V1, V2, V3 V4)) == P
280280
@test @constinferred((V1, V2 V3, V4)) == P
281281
@test @constinferred(insertunit(P, 3)) == V1 * V2 * oneunit(V1) * V3 * V4
282+
@test @constinferred(removeunit(V1 * V2 * oneunit(V1)' * V3 * V4, 3)) == P
282283
@test fuse(V1, V2', V3) V1 V2' V3
283284
@test fuse(V1, V2', V3) V1 V2' V3
284285
@test fuse(V1, V2', V3) V1 V2' V3
@@ -339,6 +340,7 @@ println("------------------------------------")
339340
@test @constinferred((V1, V2, V3)) == P
340341
@test @constinferred(adjoint(P)) == dual(P) == V3' V2' V1'
341342
@test @constinferred(insertunit(P, 3; conj=true)) == V1 * V2 * oneunit(V1)' * V3
343+
@test P == @constinferred(removeunit(insertunit(P, 3), 3))
342344
@test fuse(V1, V2', V3) V1 V2' V3
343345
@test fuse(V1, V2', V3) V1 V2' V3 fuse(V1 V2' V3)
344346
@test fuse(V1, V2') V3 V1 V2' V3
@@ -420,11 +422,14 @@ println("------------------------------------")
420422
@test permute(W, ((2, 4, 5), (3, 1))) == (V2 V4' V5' V3 V1')
421423
@test (V1 V2 V1 V2) == @constinferred TensorKit.compose(W, W')
422424
@test @constinferred(insertunit(W)) == (V1 V2 V3 V4 V5 oneunit(V5))
425+
@test @constinferred(removeunit(insertunit(W), numind(W) + 1)) == W
423426
@test @constinferred(insertunit(W; conj=true)) == (V1 V2
424427
V3 V4 V5 oneunit(V5)')
425428
@test @constinferred(insertunit(W, 1)) == (oneunit(V1) V1 V2 V3 V4 V5)
426429
@test @constinferred(insertunit(W, 3)) == (V1 V2 oneunit(V1) V3 V4 V5)
430+
@test @constinferred(removeunit(insertunit(W, 3))) == W
427431
@test @constinferred(insertunit(W, 3; preferdomain=true)) ==
428432
(V1 V2 oneunit(V1) V3 V4 V5)
433+
@test @constinferred(removeunit(insertunit(W, 3; preferdomain=true), 3)) == W
429434
end
430435
end

test/tensors.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,25 @@ for V in spacelist
182182
@test space(t2) == insertunit(space(t))
183183
@test scalartype(t2) === T
184184
@test t.data === t2.data
185+
@test @constinferred(removeunit(t2, numind(t2))) == t
185186
t3 = @constinferred insertunit(t; copy=true)
186187
@test t.data !== t3.data
187188
for (c, b) in blocks(t)
188189
@test b == block(t3, c)
189190
end
191+
@test @constinferred(removeunit(t3, numind(t3))) == t
190192
t4 = @constinferred insertunit(t, 4; dual=true)
191193
@test numin(t4) == numin(t) && numout(t4) == numout(t) + 1
192194
for (c, b) in blocks(t)
193195
@test b == block(t4, c)
194196
end
197+
@test @constinferred(removeunit(t4, 4)) == t
195198
t5 = @constinferred insertunit(t, 4; dual=true)
196199
@test numin(t5) == numin(t) + 1 && numout(t5) == numout(t)
197200
for (c, b) in blocks(t)
198201
@test b == block(t5, c)
199202
end
203+
@test @constinferred(removeunit(t5, 4)) == t
200204
end
201205
end
202206
if hasfusiontensor(I)

0 commit comments

Comments
 (0)