Skip to content

Commit c75471b

Browse files
Implement new testing CI (#179)
* Attempt to use new testing method * does this work? * rename test files * fix deps for tests * using TNRKit in runtests.jl * use tensorkitsectors in models test * lower test crits on 0 central charges * reduce amount of testfiles, get rid of spaces tests
1 parent e78607a commit c75471b

11 files changed

Lines changed: 155 additions & 190 deletions

File tree

.github/workflows/CI.yml

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,20 @@
1-
name: CI
1+
name: Tests
2+
23
on:
34
push:
4-
branches:
5-
- 'master'
5+
branches: [main]
66
tags: '*'
77
pull_request:
88
workflow_dispatch:
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
12-
cancel-in-progress: true
12+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1313

1414
jobs:
15-
test:
16-
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
17-
runs-on: ${{ matrix.os }}
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
version:
22-
- 'min'
23-
- '1'
24-
os:
25-
- ubuntu-latest
26-
- macOS-latest
27-
- windows-latest
28-
steps:
29-
- uses: actions/checkout@v6
30-
- uses: julia-actions/setup-julia@v3
31-
with:
32-
version: ${{ matrix.version }}
33-
- uses: julia-actions/cache@v3
34-
- uses: julia-actions/julia-buildpkg@latest
35-
- uses: julia-actions/julia-runtest@latest
36-
env:
37-
JULIA_NUM_THREADS: 4
38-
- uses: julia-actions/julia-processcoverage@v1
39-
- uses: codecov/codecov-action@v6
40-
with:
41-
files: lcov.info
42-
token: "${{ secrets.CODECOV_TOKEN }}"
43-
15+
tests:
16+
uses: "QuantumKitHub/QuantumKitHubActions/.github/workflows/TestGroups.yml@main"
17+
with:
18+
fast: ${{ github.event.pull_request.draft == true }}
19+
secrets:
20+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Zygote = "0.7.7"
3737
julia = "1.11"
3838

3939
[extras]
40-
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
40+
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
4141
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4242

4343
[targets]
44-
test = ["Test", "QuadGK"]
44+
test = ["Test", "ParallelTestRunner"]

test/algebras.jl

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
using Test
2+
using TNRKit
3+
using TensorKit
4+
15
f_bench = -1.4515448845652446
26
T = gross_neveu_start(0, 0, 0)
37

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
using Test
2+
using TNRKit
3+
using TensorKit
4+
using TensorKitSectors
5+
6+
@testset "Q-system property of FunZN ∈ Rep[DN]" begin
7+
for N in 2:7
8+
FunZN, m = TNRKit.FunZN_Dihedral(N)
9+
@tensor AA_A[1; 2 3 4] := m[middle; 2 3] * m[1; middle 4]
10+
@tensor A_AA[1; 2 3 4] := m[middle; 3 4] * m[1; 2 middle]
11+
12+
@test AA_A A_AA # Associativity is satisfied
13+
14+
@test m * m' id(FunZN) # Isometry is satisfied
15+
end
16+
end
17+
118
println("-----------------------")
219
println(" Testing all entropies ")
320
println("-----------------------")

test/models.jl renamed to test/models/models.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
using Test
2+
using TNRKit
3+
using TensorKit
4+
using TensorKitSectors
5+
16
println("--------------------")
27
println(" Testing all models ")
38
println("--------------------")
@@ -55,7 +60,7 @@ end
5560
data = run!(scheme, truncrank(16), maxiter(20))
5661
cft = CFTData(scheme)
5762
central_charge = cft.central_charge
58-
@test central_charge 0.0 atol = 1.0e-13
63+
@test central_charge 0.0 atol = 1.0e-12
5964
@info "Obtained central charge:\n$central_charge."
6065

6166
@info "Central charge of KT phase with O(2) symmetry"
@@ -73,7 +78,7 @@ end
7378
data = run!(scheme, truncrank(16), maxiter(20))
7479
cft = CFTData(scheme)
7580
central_charge = cft.central_charge
76-
@test central_charge 0.0 atol = 1.0e-13
81+
@test central_charge 0.0 atol = 1.0e-12
7782
@info "Obtained central charge:\n$central_charge."
7883
end
7984

test/runtests.jl

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
using Test
21
using TNRKit
3-
using TensorKit
4-
using TensorKitSectors
5-
using QuadGK
2+
using ParallelTestRunner
63

7-
include("spaces.jl") # do they give spacemismatches?
8-
include("schemes.jl") # do they give the correct results (with the expected accuracy)?
9-
include("schemes_triangular.jl") # do they give the correct results (with the expected accuracy)?
10-
include("schemes_honeycomb.jl") # do they give the correct results (with the expected accuracy)?
11-
include("models.jl") # do they give the correct results (with the expected accuracy)?
12-
include("fermions.jl") # do they give the correct results (with the expected accuracy)?
13-
include("entropies.jl") # do they work?
14-
include("algebras.jl")
4+
testsuite = find_tests(@__DIR__)
5+
args = parse_args(ARGS)
6+
ParallelTestRunner.runtests(TNRKit, args)

test/schemes.jl renamed to test/schemes/schemes.jl

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
# This tests every scheme in the library on the Z2 symmetric Ising model.
1+
using Test
2+
using TNRKit
3+
using TensorKit
24

5+
# This tests every scheme in the library on the Z2 symmetric Ising model.
36
println("---------------------")
47
println(" Testing all schemes ")
58
println("---------------------")
@@ -530,3 +533,110 @@ end
530533
lowT = norm(@tensor scheme.Timp_final[1 2; 2 1]) / norm(@tensor scheme.Tpure[1 2; 2 1])
531534
@test lowT 1 rtol = 1.0e-4
532535
end
536+
537+
# c6vCTM_triangular
538+
@testset "c6vCTM_triangular - Ising Model" begin
539+
for sym in [Trivial, Z2Irrep]
540+
for projectors in [:twothirds :full]
541+
for conditioning in [true false]
542+
T_flipped = classical_ising_triangular(sym, ising_βc_triangular)
543+
544+
scheme = c6vCTM_triangular(T_flipped)
545+
lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning)
546+
547+
fs = lz * -1 / ising_βc_triangular
548+
@test fs f_onsager_triangular rtol = 1.0e-4
549+
end
550+
end
551+
end
552+
end
553+
554+
# CTM_triangular
555+
@testset "CTM_triangular - Ising Model" begin
556+
for sym in [Trivial, Z2Irrep]
557+
for projectors in [:twothirds :full]
558+
for conditioning in [true false]
559+
T_flipped = classical_ising_triangular(sym, ising_βc_triangular)
560+
561+
scheme = CTM_triangular(T_flipped)
562+
lz = run!(scheme, truncrank(20), maxiter(100); projectors, conditioning)
563+
564+
fs = lz * -1 / ising_βc_triangular
565+
@test fs f_onsager_triangular rtol = 1.0e-4
566+
end
567+
end
568+
end
569+
end
570+
571+
using StableRNGs
572+
@testset "Honeycomb schemes - Ising Model" begin
573+
for sym in [Trivial, Z2Irrep]
574+
for alg in [:CTM_honeycomb, :c3vCTM_honeycomb]
575+
T_flipped = classical_ising_honeycomb(sym, ising_βc_honeycomb; T = ComplexF64)
576+
scheme = eval(alg)(T_flipped)
577+
lz = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)
578+
579+
fs = lz * -1 / ising_βc_honeycomb
580+
@test fs f_onsager_honeycomb rtol = 1.0e-2
581+
end
582+
end
583+
end
584+
585+
# Test honeycomb CTM by converting it to CTM on a square lattice
586+
@testset "Honeycomb CTM C3 - Random Model" begin
587+
rng = StableRNG(1234)
588+
for sym in [Trivial, Z2Irrep]
589+
for alg in [:CTM_honeycomb, :c3vCTM_honeycomb]
590+
A = zeros(ComplexF64, ℂ^2 ^2, ℂ^2)
591+
A.data .= rand(rng, length(A.data))
592+
A /= norm(A)
593+
594+
if alg == :c3vCTM_honeycomb
595+
scheme = eval(alg)(A; symmetrize = true)
596+
else
597+
scheme = eval(alg)(A)
598+
end
599+
lz_honeycomb = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)
600+
601+
@tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(A, [1 2 3])[-3 -4 1]
602+
scheme_square = CTM(pf_square)
603+
lz_square = run!(scheme, truncrank(20), convcrit(1.0e-4, (steps, data) -> data) & maxiter(300); verbosity = 1)
604+
605+
@test lz_square lz_honeycomb rtol = 1.0e-3
606+
end
607+
end
608+
end
609+
610+
# Test CTM_honeycomb for A ≠ B by converting it to CTM on a square lattice
611+
@testset "Honeycomb CTM - Random Model" begin
612+
rng = StableRNG(1234)
613+
for sym in [Trivial, Z2Irrep]
614+
A = zeros(ComplexF64, ℂ^2 ^3, ℂ^4)
615+
B = zeros(ComplexF64, ℂ^2 ^3, ℂ^4)
616+
A.data .= rand(rng, length(A.data))
617+
B.data .= rand(rng, length(B.data))
618+
A /= norm(A)
619+
B /= norm(B)
620+
621+
@test_throws ArgumentError c3vCTM_honeycomb(A)
622+
scheme = CTM_honeycomb(A; B)
623+
lz_honeycomb = run!(scheme, truncrank(40), convcrit(-Inf, (steps, data) -> data) & maxiter(500); verbosity = 1)
624+
625+
@tensor pf_square[-4 -3; -1 -2] := A[-1 -2 1] * flip(B, [1 2 3])[-3 -4 1]
626+
scheme_square = CTM(pf_square)
627+
lz_square = run!(scheme, truncrank(40), convcrit(1.0e-14, (steps, data) -> data) & maxiter(500); verbosity = 1)
628+
629+
@test lz_square lz_honeycomb rtol = 1.0e-2
630+
end
631+
end
632+
633+
@testset "Rotations for honeycomb lattice" begin
634+
rng = StableRNG(1234)
635+
A_flipped = zeros(ComplexF64, ℂ^2 ^2, ℂ^2)
636+
A = permute(flip(A_flipped, [1 2]; inv = true), ((), (3, 2, 1)))
637+
A.data .= rand(rng, length(A.data))
638+
639+
@test TNRKit.rotl120_pf_honeycomb(A, 3) A
640+
@test TNRKit.rotl120_pf_honeycomb(A, 1) TNRKit.rotl120_pf_honeycomb(A)
641+
@test TNRKit.is_C3_symmetric(TNRKit.symmetrize_C3_honeycomb(A))
642+
end

test/schemes_honeycomb.jl

Lines changed: 0 additions & 72 deletions
This file was deleted.

test/schemes_triangular.jl

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)