Skip to content

Commit

Permalink
Add tensors test
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed Aug 1, 2023
1 parent 4dd2766 commit 18b9620
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/MatrixProductOperator_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@
only(select(ψ, last.interlayer)[3])).meta[:alias][:l]
end
end

@testset "tensors" begin
arrays = [rand(1, 2, 2), rand(1, 1, 2, 2), rand(1, 2, 2)]
ψ = MatrixProduct{Operator,Open}(arrays, order = (:l, :r, :i, :o))

@test tensors(ψ, 1) isa Tensor
@test size(tensors(ψ)) |> first == length(ψ) == 3
end
end

@testset "`Periodic` boundary" begin
Expand Down Expand Up @@ -131,6 +139,14 @@
@test only(select(ψ, first.interlayer)[3])).meta[:alias][:r] ===
only(select(ψ, first.interlayer)[1])).meta[:alias][:l]
end

@testset "tensors" begin
arrays = [rand(1, 1, 2, 2), rand(1, 1, 2, 2), rand(1, 1, 2, 2)]
ψ = MatrixProduct{Operator,Periodic}(arrays, order = (:l, :r, :i, :o))

@test tensors(ψ, 1) isa Tensor
@test size(tensors(ψ)) |> first == length(ψ) == 3
end
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions test/MatrixProductState_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
@test tensors(ψ, 1).meta[:alias][:r] === tensors(ψ, 2).meta[:alias][:l]
@test tensors(ψ, 2).meta[:alias][:r] === tensors(ψ, 3).meta[:alias][:l]
end

@testset "tensors" begin
arrays = [rand(1, 2), rand(1, 1, 2), rand(1, 2)]
ψ = MatrixProduct{State,Open}(arrays, order = (:l, :r, :o))

@test tensors(ψ, 1) isa Tensor
@test size(tensors(ψ)) |> first == length(ψ) == 3
end
end
end

Expand Down Expand Up @@ -128,6 +136,14 @@
@test tensors(ψ, 2).meta[:alias][:r] === tensors(ψ, 3).meta[:alias][:l]
@test tensors(ψ, 3).meta[:alias][:r] === tensors(ψ, 1).meta[:alias][:l]
end

@testset "tensors" begin
arrays = [rand(1, 1, 2), rand(1, 1, 2), rand(1, 1, 2)]
ψ = MatrixProduct{State,Periodic}(arrays, order = (:l, :r, :o))

@test tensors(ψ, 1) isa Tensor
@test size(tensors(ψ)) |> first == length(ψ) == 3
end
end
end
end
Expand Down

0 comments on commit 18b9620

Please sign in to comment.