bsc-quantic / Tenet.jl

Composable Tensor Network library in Julia
https://bsc-quantic.github.io/Tenet.jl/
Apache License 2.0
17 stars 1 forks source link

Fix label permutation on `MatrixProductState` #36

Closed jofrevalles closed 1 year ago

jofrevalles commented 1 year ago

Summary

In MatrixProductState, we first have the labels sorted in (:l, :r, :i, :o) and then we want to have it in order, but the permutator permutes from order to (:l, :r, :i, :o), so instead of permute! we need invpermute!. This didn't fail in tests because in the case we considered the permutation was the same as the inverse permutation.

Example

This code failed without this PR, and now works properly.

julia> using Tenet; using Test
julia> @test begin
           arrays = [rand(3, 1), rand(3, 1, 3), rand(1, 3)]
           MatrixProductState{Open}(arrays, order = (:r, :p, :l)) isa TensorNetwork{MatrixProductState{Open}}
       end
Test Passed
mofeing commented 1 year ago

Thanks! Can you add some tests for this?

codecov[bot] commented 1 year ago

Codecov Report

Merging #36 (7939161) into master (2e4efca) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master      #36   +/-   ##
=======================================
  Coverage   61.42%   61.42%           
=======================================
  Files          11       11           
  Lines         617      617           
=======================================
  Hits          379      379           
  Misses        238      238           
Impacted Files Coverage Δ
src/MatrixProductState.jl 71.60% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.