diff --git a/src/tensors/indexmanipulations.jl b/src/tensors/indexmanipulations.jl index c376b329..50035e67 100644 --- a/src/tensors/indexmanipulations.jl +++ b/src/tensors/indexmanipulations.jl @@ -308,11 +308,12 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis This operation undoes the work of [`insertunit`](@ref). """ -function removeunit(t::TensorMap, i::Int; copy::Bool=false) +Base.@constprop :aggressive function removeunit(t::TensorMap, i::Int; copy::Bool=false) W = removeunit(space(t), i) return TensorMap{scalartype(t)}(copy ? Base.copy(t.data) : t.data, W) end -function removeunit(t::AbstractTensorMap, i::Int=numind(t) + 1; copy::Bool=true) +Base.@constprop :aggressive function removeunit(t::AbstractTensorMap, i::Int; + copy::Bool=true) W = removeunit(space(t), i) tdst = similar(t, W) for (c, b) in blocks(t) diff --git a/test/spaces.jl b/test/spaces.jl index ca525e75..34f400fa 100644 --- a/test/spaces.jl +++ b/test/spaces.jl @@ -422,7 +422,7 @@ println("------------------------------------") @test permute(W, ((2, 4, 5), (3, 1))) == (V2 ⊗ V4' ⊗ V5' ← V3 ⊗ V1') @test (V1 ⊗ V2 ← V1 ⊗ V2) == @constinferred TensorKit.compose(W, W') @test @constinferred(insertunit(W)) == (V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5 ⊗ oneunit(V5)) - @test @constinferred(removeunit(insertunit(W), numind(W) + 1)) == W + @test @constinferred(removeunit(insertunit(W), $(numind(W) + 1))) == W @test @constinferred(insertunit(W; conj=true)) == (V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5 ⊗ oneunit(V5)') @test @constinferred(insertunit(W, 1)) == (oneunit(V1) ⊗ V1 ⊗ V2 ← V3 ⊗ V4 ⊗ V5)