-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reindex! by returing the final index replace mapping #178
Conversation
test/Quantum_test.jl
Outdated
|
||
Tenet.@reindex! outputs(qtn) => inputs(qtn2) | ||
|
||
@test issetequal([qtn2.sites[i] for i in inputs(qtn2)], [qtn.sites[i] for i in outputs(qtn)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test issetequal([qtn2.sites[i] for i in inputs(qtn2)], [qtn.sites[i] for i in outputs(qtn)]) | |
@test issetequal([inds(qtn2, at=i) for i in inputs(qtn2)], [inds(qtn, at=i) for i in outputs(qtn)]) |
test/Quantum_test.jl
Outdated
|
||
Tenet.@reindex! outputs(qtn) => inputs(qtn2) | ||
|
||
@test issetequal([qtn2.sites[i] for i in inputs(qtn2)], [qtn.sites[i] for i in outputs(qtn)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@test issetequal([qtn2.sites[i] for i in inputs(qtn2)], [qtn.sites[i] for i in outputs(qtn)]) | |
@test issetequal([inds(qtn2, at=i) for i in inputs(qtn2)], [inds(qtn, at=i) for i in outputs(qtn)]) |
test/TensorNetwork_test.jl
Outdated
@@ -528,6 +528,27 @@ | |||
end | |||
end | |||
|
|||
@testset "complicated replacement" begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@testset "complicated replacement" begin | |
@testset "overlapping replacement" begin |
test/TensorNetwork_test.jl
Outdated
# [:L, :U, :C, :M] | ||
# [:M, :P, :D, :N] | ||
# [:N, :J, :E] | ||
@test issetequal(vcat(collect(values(tn.tensormap))...), vcat([[:O, :A, :K], [:K, :V, :B, :L], [:L, :U, :C, :M], [:M, :P, :D, :N], [:N, :J, :E]]...)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use inds.(tensors(tn))
or another way to test this.
Now it also modifies the indices of `a`
Summary
This PR resolves #177 by correctly fixing the reindex of the
site
indices. To do that, we modified thereplace!
function by returning the final index mapping. I believe this is the most efficient way to do this since we could also get the mapping by comparing the tensor before and after thereplace!
, but this seems to do unnecessary work.Example
Now the following code works fine: