Skip to content
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

Incorrect replace! of a Tensor in a TensorNetwork with the same Tensor #225

Closed
jofrevalles opened this issue Oct 31, 2024 · 2 comments · Fixed by #227
Closed

Incorrect replace! of a Tensor in a TensorNetwork with the same Tensor #225

jofrevalles opened this issue Oct 31, 2024 · 2 comments · Fixed by #227
Assignees
Labels
bug Something isn't working

Comments

@jofrevalles
Copy link
Member

Summary

The replace! function for a Tensor in a TensorNetwork, where it is replaced with the same Tensor, leads to the deletion of that Tensor:

julia> using Tenet

julia> A = Tensor(rand(2, 2, 2), (:i, :j, :k))
2×2×2 Tensor{Float64, 3, Array{Float64, 3}}: ...

julia> B = Tensor(rand(Float32, 2, 2), (:k, :j))
2×2 Tensor{Float32, 2, Matrix{Float32}}: ...

julia> tn = TensorNetwork([A, B])
TensorNetwork (#tensors=2, #inds=3)

julia> replace!(tn, A => (A))
TensorNetwork (#tensors=1, #inds=2)

julia> tensors(tn) .|> inds
1-element Vector{Vector{Symbol}}:
 [:k, :j]

I think that there might be a conditional in the replace! function that checks whether it's the same Tensor, and this may be causing the problem.

@jofrevalles jofrevalles added the bug Something isn't working label Oct 31, 2024
@jofrevalles jofrevalles self-assigned this Oct 31, 2024
@jofrevalles
Copy link
Member Author

@bsc-quantic/software @starsfordummies @mofeing Also I noticed that quite a lot of the replace! tests for TensorNetworks are commented. This is not a good procedure and I think we should never do that. If a test fails we have to check why, and if we decide that the test is deprecated, we remove it.

@jofrevalles
Copy link
Member Author

I will merge this on monday @mofeing. Let's enjoy the weekend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant