From 307a89da732dd59da63853cb4a0223cff1124092 Mon Sep 17 00:00:00 2001 From: lkdvos Date: Wed, 10 Apr 2024 09:26:36 +0200 Subject: [PATCH] Improve type-inference --- src/tensors/indexmanipulations.jl | 5 +++-- test/tensors.jl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/tensors/indexmanipulations.jl b/src/tensors/indexmanipulations.jl index fa017f10..05f1831b 100644 --- a/src/tensors/indexmanipulations.jl +++ b/src/tensors/indexmanipulations.jl @@ -215,8 +215,9 @@ If `copy=false`, `tdst` might share data with `tsrc` whenever possible. Otherwis To repartition into an existing destination, see [repartition!](@ref). """ -function repartition(t::AbstractTensorMap, N₁::Int, N₂::Int=numind(t) - N₁; - copy::Bool=false) +Base.@constprop :aggressive function repartition(t::AbstractTensorMap, N₁::Int, + N₂::Int=numind(t) - N₁; + copy::Bool=false) N₁ + N₂ == numind(t) || throw(ArgumentError("Invalid repartition: $(numind(t)) to ($N₁, $N₂)")) all_inds = (codomainind(t)..., reverse(domainind(t))...) diff --git a/test/tensors.jl b/test/tensors.jl index 9de845fc..b6269e35 100644 --- a/test/tensors.jl +++ b/test/tensors.jl @@ -202,7 +202,7 @@ for V in spacelist @test dot(t2′, t2) ≈ dot(t′, t) ≈ dot(transpose(t2′), transpose(t2)) end - t3 = @constinferred repartition(t, k) + t3 = @constinferred repartition(t, $k) @test norm(t3) ≈ norm(t) t3′ = @constinferred repartition!(similar(t3), t′) @test norm(t3′) ≈ norm(t′)