Skip to content

Commit

Permalink
improve type stability
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Dec 12, 2024
1 parent 7eaa6d3 commit fbddfd6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/tensors/indexmanipulations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fbddfd6

Please sign in to comment.