Skip to content

Commit

Permalink
Enhance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed Nov 21, 2024
1 parent 64c77ef commit 52b30c4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions test/MPS_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ using LinearAlgebra
end

@testset "normalize!" begin
using LinearAlgebra: normalize!
using LinearAlgebra: normalize, normalize!

@testset "NonCanonical" begin
ψ = MPS([rand(4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4)])
Expand All @@ -160,6 +160,10 @@ using LinearAlgebra
@testset "MixedCanonical" begin
ψ = rand(MPS; n=5, maxdim=16)

# Perturb the state to make it non-normalized
t = tensors(ψ; at=site"3")
replace!(ψ, t => Tensor(rand(size(t)...), inds(t)))

normalized = normalize(ψ)
@test norm(normalized) 1.0

Expand All @@ -168,13 +172,13 @@ using LinearAlgebra
end

@testset "Canonical" begin
ψ = rand(MPS; n=5, maxdim=16)
ψ = MPS([rand(4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4, 4), rand(4, 4)])
canonize!(ψ)

normalized = normalize(ψ)
@test norm(normalized) 1.0

normalize!(ψ, Site(3))
normalize!(ψ, (Site(3), Site(4)))
@test norm(ψ) 1.0
end
end
Expand Down

0 comments on commit 52b30c4

Please sign in to comment.