From 9f298aec4f4a2b5384673a2051bb88c4aeebd07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Fri, 31 Jan 2025 18:29:02 +0100 Subject: [PATCH] Refactor MPS test --- test/unit/MPS_test.jl | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test/unit/MPS_test.jl b/test/unit/MPS_test.jl index 16e58fd3b..ad3e6bb37 100644 --- a/test/unit/MPS_test.jl +++ b/test/unit/MPS_test.jl @@ -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