Skip to content

Commit

Permalink
Made tests work again
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Wietek committed Feb 10, 2025
1 parent 275e7c1 commit 1031955
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 120 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Manifest.toml
*.cov
2 changes: 1 addition & 1 deletion test/algebra/algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
block = Spinhalf(N, N ÷ 2)
ops = OpSum()
for i in 1:N
ops += Op("HB", 1.0, [i, mod1(i+1, N)])
ops += Op("SdotS", [i, mod1(i+1, N)])
end
e0, psi = eig0(ops, block);

Expand Down
2 changes: 1 addition & 1 deletion test/algorithms/eigs_lanczos.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
block = Spinhalf(N, N ÷ 2)
ops = OpSum()
for i in 1:N
ops += Op("HB", 1.0, [i, mod1(i+1, N)])
ops += Op("SdotS", [i, mod1(i+1, N)])
end

res = eigs_lanczos(ops, block)
Expand Down
10 changes: 6 additions & 4 deletions test/blocks/blocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
p3 = Permutation([3, 4, 1, 2])
p4 = Permutation([4, 1, 2, 3])
group = PermutationGroup([p1, p2, p3, p4])
rep = Representation([1, -1, 1, -1])
rep = Representation(group, [1.0, -1.0, 1.0, -1.0])

block_sym = tJ(N, nup, ndn, group, rep)
@test isreal(rep)

block_sym = tJ(N, nup, ndn, rep)

# Iteration
idx = 1
Expand All @@ -20,7 +22,7 @@
end


block_sym = Electron(N, nup, ndn, group, rep)
block_sym = Electron(N, nup, ndn, rep)

# Iteration
idx = 1
Expand All @@ -30,7 +32,7 @@
idx += 1
end

block_sym = Spinhalf(N, nup, group, rep)
block_sym = Spinhalf(N, nup, rep)

# Iteration
idx = 1
Expand Down
42 changes: 0 additions & 42 deletions test/operators/coupling.jl

This file was deleted.

51 changes: 4 additions & 47 deletions test/operators/op.jl
Original file line number Diff line number Diff line change
@@ -1,59 +1,16 @@
@testset "Op" begin
op = Op("HOP", "T", [1, 2])
@test type(op) == "HOP"
@test convert(String, coupling(op)) == "T"
op = Op("Hop", [1, 2])
@test type(op) == "Hop"
@test size(op) == 2
@test op[1] == 1
@test op[2] == 2
@test sites(op) == [1, 2]
@test isexplicit(op) == false

c = 1.23
op = Op("HOP", c, [1, 2])
@test type(op) == "HOP"
@test convert(Float64, coupling(op)) == c
op = Op("Hop", [1, 2])
@test type(op) == "Hop"
@test size(op) == 2
@test op[1] == 1
@test op[2] == 2
@test sites(op) == [1, 2]
@test isreal(op) == true
@test ismatrix(op) == false
@test isexplicit(op) == true

c = 3.21 + 1.23im
op = Op("HOP", c, [1, 2])
@test type(op) == "HOP"
@test convert(ComplexF64, coupling(op)) == c
@test size(op) == 2
@test op[1] == 1
@test op[2] == 2
@test sites(op) == [1, 2]
@test isreal(op) == false
@test ismatrix(op) == false
@test isexplicit(op) == true

c = [0 1; 1 0]
op = Op("HOP", c, [1, 2])
@test type(op) == "HOP"
@test convert(Matrix{Float64}, coupling(op)) == convert(Matrix{Float64}, c)
@test size(op) == 2
@test op[1] == 1
@test op[2] == 2
@test sites(op) == [1, 2]
@test isreal(op) == true
@test ismatrix(op) == true
@test isexplicit(op) == true

c = [0 -im; im 0]
op = Op("HOP", c, [1, 2])
@test type(op) == "HOP"
@test convert(Matrix{ComplexF64}, coupling(op)) == convert(Matrix{ComplexF64}, c)
@test size(op) == 2
@test op[1] == 1
@test op[2] == 2
@test sites(op) == [1, 2]
@test isreal(op) == false
@test ismatrix(op) == true
@test isexplicit(op) == true

end
28 changes: 6 additions & 22 deletions test/operators/opsum.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
@testset "OpSum" begin
op1 = Op("HOP", "T", [1, 2])
op2 = Op("HOP", "T", [2, 3])
ops = OpSum([op1, op2])
@test size(ops) == 2
ops += Op("HOP", "T", [3, 4])
@test size(ops) == 3
# @test isexplicit(ops) == false

ops2 = OpSum()
ops2 += Op("HB", "J", [1, 2])
ops2 += Op("HB", "J", [2, 3])
ops2 += Op("HB", "J", [4, 5])
J = 1.23
ops2["J"] = J
@test convert(Float64, ops2["J"]) == J
@test size(ops2) == 3
@test isexplicit(ops2) == false

ops3 = OpSum()
ops3 += Op("HB", 1.23, [0, 1])
ops3 += Op("HB", 1.23, [1, 2])
@test isexplicit(ops3)
ops = OpSum()
ops += "T" * Op("Hop", [1, 2])
ops += "T" * Op("Hop", [2, 3])
ops += "T" * Op("Hop", [3, 4])
ops["T"] = 1.0
@test isapprox(ops, hc(ops))
end
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using XDiag
using Test

include("operators/coupling.jl")
include("operators/op.jl")
include("operators/opsum.jl")

Expand Down
4 changes: 2 additions & 2 deletions test/states/state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

psi2 = State(block, real=false, n_cols=3)
@test all(isapprox.(matrix(psi2), 0.0))
@test n_rows(psi2) == 4
@test n_cols(psi2) == 3
@test nrows(psi2) == 4
@test ncols(psi2) == 3
@test !isreal(psi2)

v = [1.0+4.0im, 2.0+3.0im, 3.0+2.0im, 4.0+1.0im]
Expand Down

0 comments on commit 1031955

Please sign in to comment.