From 5a00dd693fbbb52a159f205df28fc8f629c7cd13 Mon Sep 17 00:00:00 2001 From: Benedikt Kloss Date: Sun, 28 Jan 2024 12:42:59 -0500 Subject: [PATCH] Make copy on ProjectedTTN copy-safe. Workaround for issue #98 in Dictionaries.jl. --- src/treetensornetworks/projttns/projttn.jl | 2 +- src/treetensornetworks/projttns/projttn_apply.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/treetensornetworks/projttns/projttn.jl b/src/treetensornetworks/projttns/projttn.jl index 18baa3e2..959d732a 100644 --- a/src/treetensornetworks/projttns/projttn.jl +++ b/src/treetensornetworks/projttns/projttn.jl @@ -11,7 +11,7 @@ function ProjTTN(H::TTN) return ProjTTN(vertices(H), H, Dictionary{edgetype(H),ITensor}()) end -copy(P::ProjTTN) = ProjTTN(P.pos, copy(P.H), copy(P.environments)) +copy(P::ProjTTN) = ProjTTN(P.pos, copy(P.H), NamedGraphs.copy_keys_values(P.environments)) # trivial if we choose to specify position as above; only kept to allow using alongside # ProjMPO diff --git a/src/treetensornetworks/projttns/projttn_apply.jl b/src/treetensornetworks/projttns/projttn_apply.jl index 67b8980b..7beb67dd 100644 --- a/src/treetensornetworks/projttns/projttn_apply.jl +++ b/src/treetensornetworks/projttns/projttn_apply.jl @@ -10,7 +10,7 @@ function ProjTTNApply(psi0::TTN, H::TTN) end function copy(P::ProjTTNApply) - return ProjTTNApply(P.pos, copy(P.psi0), copy(P.H), copy(P.environments)) + return ProjTTNApply(P.pos, copy(P.psi0), copy(P.H), NamedGraphs.copy_keys_values(P.environments)) end function set_nsite(P::ProjTTNApply, nsite)