Skip to content

Commit

Permalink
Refactor MPS test
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Jan 31, 2025
1 parent 5d0eba1 commit 9f298ae
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions test/unit/MPS_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,18 +353,17 @@ using LinearAlgebra
@testset "two sites" begin
mat = reshape(LinearAlgebra.I(4), 2, 2, 2, 2)
gate = Gate(mat, [site"2", site"3", site"2'", site"3'"])
ψ = MPS([rand(2, 2), rand(2, 2, 2), rand(2, 2, 2), rand(2, 2)])

@testset "NonCanonical" begin
let ϕ = deepcopy)
evolve!(ϕ, gate; threshold=1e-14)
@test length(tensors(ϕ)) == 5
@test issetequal(size.(tensors(ϕ)), [(2, 2), (2, 2, 2), (2,), (2, 2, 2), (2, 2, 2), (2, 2)])
@test isapprox(contract), contract(ψ))

evolved = evolve!(normalize(ψ), gate; maxdim=1, normalize=true)
@test norm(evolved) 1.0
end
ψ = MPS([rand(2, 2), rand(2, 2, 2), rand(2, 2, 2), rand(2, 2)])
ϕ = deepcopy)
evolve!(ϕ, gate; threshold=1e-14)
@test length(tensors(ϕ)) == 5
@test issetequal(size.(tensors(ϕ)), [(2, 2), (2, 2, 2), (2,), (2, 2, 2), (2, 2, 2), (2, 2)])
@test isapprox(contract(ϕ), contract(ψ))

evolved = evolve!(normalize(ψ), gate; maxdim=1, normalize=true)
@test norm(evolved) 1.0
end

@testset "Canonical" begin
Expand Down

0 comments on commit 9f298ae

Please sign in to comment.