diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7f55b79b..ec3613aa 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,43 +1,20 @@ -name: CI +name: Tests + on: push: - branches: - - 'master' + branches: [main] tags: '*' pull_request: workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} jobs: - test: - name: Julia ${{ matrix.version }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - version: - - 'min' - - '1' - os: - - ubuntu-latest - - macOS-latest - - windows-latest - steps: - - uses: actions/checkout@v6 - - uses: julia-actions/setup-julia@v3 - with: - version: ${{ matrix.version }} - - uses: julia-actions/cache@v3 - - uses: julia-actions/julia-buildpkg@latest - - uses: julia-actions/julia-runtest@latest - env: - JULIA_NUM_THREADS: 4 - - uses: julia-actions/julia-processcoverage@v1 - - uses: codecov/codecov-action@v6 - with: - files: lcov.info - token: "${{ secrets.CODECOV_TOKEN }}" - + tests: + uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/TestGroups.yml@main" + with: + fast: ${{ github.event.pull_request.draft == true }} + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/Project.toml b/Project.toml index 43b06e83..9540fee1 100644 --- a/Project.toml +++ b/Project.toml @@ -37,8 +37,8 @@ Zygote = "0.7.7" julia = "1.11" [extras] -QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" +ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Test", "QuadGK"] +test = ["Test", "ParallelTestRunner"] diff --git a/test/algebras.jl b/test/algebras/algebras.jl similarity index 85% rename from test/algebras.jl rename to test/algebras/algebras.jl index 8e7853e5..523642fa 100644 --- a/test/algebras.jl +++ b/test/algebras/algebras.jl @@ -1,3 +1,8 @@ +using Test +using TNRKit +using TensorKit +using TensorKitSectors + @testset "Q-system property of FunZN ∈ Rep[DN]" begin for N in 2:7 FunZN, m = TNRKit.FunZN_Dihedral(N) diff --git a/test/entropies.jl b/test/entropies/entropies.jl similarity index 97% rename from test/entropies.jl rename to test/entropies/entropies.jl index 87a9d621..e7d9e645 100644 --- a/test/entropies.jl +++ b/test/entropies/entropies.jl @@ -1,3 +1,7 @@ +using Test +using TNRKit +using TensorKit + println("-----------------------") println(" Testing all entropies ") println("-----------------------") diff --git a/test/fermions.jl b/test/fermions/fermions.jl similarity index 98% rename from test/fermions.jl rename to test/fermions/fermions.jl index 6908ad09..f434c503 100644 --- a/test/fermions.jl +++ b/test/fermions/fermions.jl @@ -1,3 +1,7 @@ +using Test +using TNRKit +using TensorKit + f_bench = -1.4515448845652446 T = gross_neveu_start(0, 0, 0) diff --git a/test/models.jl b/test/models/models.jl similarity index 99% rename from test/models.jl rename to test/models/models.jl index 3f9e3c5e..c38ec200 100644 --- a/test/models.jl +++ b/test/models/models.jl @@ -1,3 +1,8 @@ +using Test +using TNRKit +using TensorKit +using TensorKitSectors + println("--------------------") println(" Testing all models ") println("--------------------") diff --git a/test/runtests.jl b/test/runtests.jl index 5fdbe6f9..16bc5bd6 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,14 +1,6 @@ -using Test using TNRKit -using TensorKit -using TensorKitSectors -using QuadGK +using ParallelTestRunner -include("spaces.jl") # do they give spacemismatches? -include("schemes.jl") # do they give the correct results (with the expected accuracy)? -include("schemes_triangular.jl") # do they give the correct results (with the expected accuracy)? -include("schemes_honeycomb.jl") # do they give the correct results (with the expected accuracy)? -include("models.jl") # do they give the correct results (with the expected accuracy)? -include("fermions.jl") # do they give the correct results (with the expected accuracy)? -include("entropies.jl") # do they work? -include("algebras.jl") +testsuite = find_tests(@__DIR__) +args = parse_args(ARGS) +ParallelTestRunner.runtests(TNRKit, args) diff --git a/test/schemes.jl b/test/schemes/schemes.jl similarity index 79% rename from test/schemes.jl rename to test/schemes/schemes.jl index 2bfe4240..dd4b7a54 100644 --- a/test/schemes.jl +++ b/test/schemes/schemes.jl @@ -1,5 +1,8 @@ -# This tests every scheme in the library on the Z2 symmetric Ising model. +using Test +using TNRKit +using TensorKit +# This tests every scheme in the library on the Z2 symmetric Ising model. println("---------------------") println(" Testing all schemes ") println("---------------------") @@ -530,3 +533,110 @@ end lowT = norm(@tensor scheme.Timp_final[1 2; 2 1]) / norm(@tensor scheme.Tpure[1 2; 2 1]) @test lowT ≈ 1 rtol = 1.0e-4 end + +# c6vCTM_triangular +@testset "c6vCTM_triangular - Ising Model" begin + for sym in [Trivial, Z2Irrep] + for projectors in [:twothirds :full] + for conditioning in [true false] + T_flipped = classical_ising_triangular(sym, ising_βc_triangular) + + scheme = c6vCTM_triangular(T_flipped) + lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning) + + fs = lz * -1 / ising_βc_triangular + @test fs ≈ f_onsager_triangular rtol = 1.0e-4 + end + end + end +end + +# CTM_triangular +@testset "CTM_triangular - Ising Model" begin + for sym in [Trivial, Z2Irrep] + for projectors in [:twothirds :full] + for conditioning in [true false] + T_flipped = classical_ising_triangular(sym, ising_βc_triangular) + + scheme = CTM_triangular(T_flipped) + lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning) + + fs = lz * -1 / ising_βc_triangular + @test fs ≈ f_onsager_triangular rtol = 1.0e-4 + end + end + end +end + +using StableRNGs +@testset "Honeycomb schemes - Ising Model" begin + for sym in [Trivial, Z2Irrep] + for alg in [:CTM_honeycomb, :c3vCTM_honeycomb] + T_flipped = classical_ising_honeycomb(sym, ising_βc_honeycomb; T = ComplexF64) + scheme = eval(alg)(T_flipped) + lz = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) + + fs = lz * -1 / ising_βc_honeycomb + @test fs ≈ f_onsager_honeycomb rtol = 1.0e-2 + end + end +end + +# Test honeycomb CTM by converting it to CTM on a square lattice +@testset "Honeycomb CTM C3 - Random Model" begin + rng = StableRNG(1234) + for sym in [Trivial, Z2Irrep] + for alg in [:CTM_honeycomb, :c3vCTM_honeycomb] + A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2) + A.data .= rand(rng, length(A.data)) + A /= norm(A) + + if alg == :c3vCTM_honeycomb + scheme = eval(alg)(A; symmetrize = true) + else + scheme = eval(alg)(A) + end + lz_honeycomb = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) + + @tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(A, [1 2 3])[-3 -4 1] + scheme_square = CTM(pf_square) + lz_square = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) + + @test lz_square ≈ lz_honeycomb rtol = 1.0e-3 + end + end +end + +# Test CTM_honeycomb for A ≠ B by converting it to CTM on a square lattice +@testset "Honeycomb CTM - Random Model" begin + rng = StableRNG(1234) + for sym in [Trivial, Z2Irrep] + A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4) + B = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4) + A.data .= rand(rng, length(A.data)) + B.data .= rand(rng, length(B.data)) + A /= norm(A) + B /= norm(B) + + @test_throws ArgumentError c3vCTM_honeycomb(A) + scheme = CTM_honeycomb(A; B) + lz_honeycomb = run!(scheme, truncrank(40), convcrit(-Inf, (steps, data) -> data) & maxiter(500); verbosity = 1) + + @tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(B, [1 2 3])[-3 -4 1] + scheme_square = CTM(pf_square) + lz_square = run!(scheme, truncrank(40), convcrit(1.0e-14, (steps, data) -> data) & maxiter(500); verbosity = 1) + + @test lz_square ≈ lz_honeycomb rtol = 1.0e-2 + end +end + +@testset "Rotations for honeycomb lattice" begin + rng = StableRNG(1234) + A_flipped = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2) + A = permute(flip(A_flipped, [1 2]; inv = true), ((), (3, 2, 1))) + A.data .= rand(rng, length(A.data)) + + @test TNRKit.rotl120_pf_honeycomb(A, 3) ≈ A + @test TNRKit.rotl120_pf_honeycomb(A, 1) ≈ TNRKit.rotl120_pf_honeycomb(A) + @test TNRKit.is_C3_symmetric(TNRKit.symmetrize_C3_honeycomb(A)) +end diff --git a/test/schemes_honeycomb.jl b/test/schemes_honeycomb.jl deleted file mode 100644 index 54135659..00000000 --- a/test/schemes_honeycomb.jl +++ /dev/null @@ -1,72 +0,0 @@ -using StableRNGs -@testset "Honeycomb schemes - Ising Model" begin - for sym in [Trivial, Z2Irrep] - for alg in [:CTM_honeycomb, :c3vCTM_honeycomb] - T_flipped = classical_ising_honeycomb(sym, ising_βc_honeycomb; T = ComplexF64) - scheme = eval(alg)(T_flipped) - lz = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) - - fs = lz * -1 / ising_βc_honeycomb - @test fs ≈ f_onsager_honeycomb rtol = 1.0e-2 - end - end -end - -# Test honeycomb CTM by converting it to CTM on a square lattice -@testset "Honeycomb CTM C3 - Random Model" begin - rng = StableRNG(1234) - for sym in [Trivial, Z2Irrep] - for alg in [:CTM_honeycomb, :c3vCTM_honeycomb] - A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2) - A.data .= rand(rng, length(A.data)) - A /= norm(A) - - if alg == :c3vCTM_honeycomb - scheme = eval(alg)(A; symmetrize = true) - else - scheme = eval(alg)(A) - end - lz_honeycomb = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) - - @tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(A, [1 2 3])[-3 -4 1] - scheme_square = CTM(pf_square) - lz_square = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1) - - @test lz_square ≈ lz_honeycomb rtol = 1.0e-3 - end - end -end - -# Test CTM_honeycomb for A ≠ B by converting it to CTM on a square lattice -@testset "Honeycomb CTM - Random Model" begin - rng = StableRNG(1234) - for sym in [Trivial, Z2Irrep] - A = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4) - B = zeros(ComplexF64, ℂ^2 ⊗ ℂ^3, ℂ^4) - A.data .= rand(rng, length(A.data)) - B.data .= rand(rng, length(B.data)) - A /= norm(A) - B /= norm(B) - - @test_throws ArgumentError c3vCTM_honeycomb(A) - scheme = CTM_honeycomb(A; B) - lz_honeycomb = run!(scheme, truncrank(40), convcrit(-Inf, (steps, data) -> data) & maxiter(500); verbosity = 1) - - @tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(B, [1 2 3])[-3 -4 1] - scheme_square = CTM(pf_square) - lz_square = run!(scheme, truncrank(40), convcrit(1.0e-14, (steps, data) -> data) & maxiter(500); verbosity = 1) - - @test lz_square ≈ lz_honeycomb rtol = 1.0e-2 - end -end - -@testset "Rotations for honeycomb lattice" begin - rng = StableRNG(1234) - A_flipped = zeros(ComplexF64, ℂ^2 ⊗ ℂ^2, ℂ^2) - A = permute(flip(A_flipped, [1 2]; inv = true), ((), (3, 2, 1))) - A.data .= rand(rng, length(A.data)) - - @test TNRKit.rotl120_pf_honeycomb(A, 3) ≈ A - @test TNRKit.rotl120_pf_honeycomb(A, 1) ≈ TNRKit.rotl120_pf_honeycomb(A) - @test TNRKit.is_C3_symmetric(TNRKit.symmetrize_C3_honeycomb(A)) -end diff --git a/test/schemes_triangular.jl b/test/schemes_triangular.jl deleted file mode 100644 index 679ff8d2..00000000 --- a/test/schemes_triangular.jl +++ /dev/null @@ -1,33 +0,0 @@ -# c6vCTM_triangular -@testset "c6vCTM_triangular - Ising Model" begin - for sym in [Trivial, Z2Irrep] - for projectors in [:twothirds :full] - for conditioning in [true false] - T_flipped = classical_ising_triangular(sym, ising_βc_triangular) - - scheme = c6vCTM_triangular(T_flipped) - lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning) - - fs = lz * -1 / ising_βc_triangular - @test fs ≈ f_onsager_triangular rtol = 1.0e-4 - end - end - end -end - -# CTM_triangular -@testset "CTM_triangular - Ising Model" begin - for sym in [Trivial, Z2Irrep] - for projectors in [:twothirds :full] - for conditioning in [true false] - T_flipped = classical_ising_triangular(sym, ising_βc_triangular) - - scheme = CTM_triangular(T_flipped) - lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning) - - fs = lz * -1 / ising_βc_triangular - @test fs ≈ f_onsager_triangular rtol = 1.0e-4 - end - end - end -end diff --git a/test/spaces.jl b/test/spaces/spaces.jl similarity index 94% rename from test/spaces.jl rename to test/spaces/spaces.jl index 99e142b1..b92f39a0 100644 --- a/test/spaces.jl +++ b/test/spaces/spaces.jl @@ -1,3 +1,7 @@ +using Test +using TNRKit +using TensorKit + println("--------") println(" spaces ") println("--------")