diff --git a/Project.toml b/Project.toml index 28f64b0e5a..22fe3200e3 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ITensors" uuid = "9136182c-28ba-11e9-034c-db9fb085ebd5" authors = ["Matthew Fishman ", "Miles Stoudenmire "] -version = "0.6.9" +version = "0.6.10" [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" diff --git a/src/lib/ITensorMPS/src/mps.jl b/src/lib/ITensorMPS/src/mps.jl index 42c15b93ab..ef462a8462 100644 --- a/src/lib/ITensorMPS/src/mps.jl +++ b/src/lib/ITensorMPS/src/mps.jl @@ -516,8 +516,8 @@ SiteTypes.siteinds(M::MPS; kwargs...) = siteinds(first, M; kwargs...) function replace_siteinds!(M::MPS, sites) for j in eachindex(M) - sj = siteind(only, M, j) - replaceind!(M[j], sj, sites[j]) + sj = only(siteinds(M, j)) + M[j] = replaceinds(M[j], sj => sites[j]) end return M end diff --git a/src/lib/ITensorMPS/test/base/test_mps.jl b/src/lib/ITensorMPS/test/base/test_mps.jl index 7d07139ed8..8dce11c1e2 100644 --- a/src/lib/ITensorMPS/test/base/test_mps.jl +++ b/src/lib/ITensorMPS/test/base/test_mps.jl @@ -271,6 +271,17 @@ include(joinpath(@__DIR__, "utils", "util.jl")) end end + @testset "replace_siteinds" begin + s = siteinds("S=1/2", 4) + x = MPS(s, j -> isodd(j) ? "↑" : "↓") + @test siteinds(x) == s + t = sim.(s) + y = replace_siteinds(x, t) + @test siteinds(y) == t + # Regression test for https://github.com/ITensor/ITensors.jl/issues/1439. + @test siteinds(x) == s + end + @testset "copy and deepcopy" begin s = siteinds("S=1/2", 3) M1 = random_mps(s; linkdims=3)