bsc-quantic / Tenet.jl

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

Fix `rand` function for odd-length `MatrixProductState` #54

Closed jofrevalles closed 1 year ago

jofrevalles commented 1 year ago

This PR addresses the issue with the rand function for generating random MatrixProductStates (MPS) with an odd number of tensors. Previously, the function produced an error when the number of tensors in the argument was odd:

julia> ψ = rand(MatrixProductState{Open}, 7, 2, 32)
ERROR: DimensionMismatch: size(9edf0aa5-219f-4849-99d3-a85b569b6773)=16 but should be 8

Now, the rand function correctly handles cases where the number of tensors is odd. Also, we have added tests to ensure its correct behavior.

codecov[bot] commented 1 year ago

Codecov Report

Merging #54 (27b69c7) into master (0f7c7cd) will increase coverage by 3.30%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   79.64%   82.95%   +3.30%     
==========================================
  Files          12       12              
  Lines         614      610       -4     
==========================================
+ Hits          489      506      +17     
+ Misses        125      104      -21     
Impacted Files Coverage Δ
src/Tenet.jl 100.00% <ø> (ø)
src/Quantum/MatrixProductState.jl 91.56% <100.00%> (+19.61%) :arrow_up:

... and 1 file with indirect coverage changes

mofeing commented 1 year ago

Great! Thanks for catching this bug. Just a lil' change and I'm merging it!