forked from QuantumSavory/QuantumClifford.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the test runner to use TestItems.jl (QuantumSavory#329)
Co-authored-by: Stefan Krastanov <[email protected]>
- Loading branch information
Showing
45 changed files
with
1,761 additions
and
1,853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,28 @@ | ||
using SafeTestsets | ||
using QuantumClifford | ||
using TestItemRunner | ||
|
||
function doset(descr) | ||
if length(ARGS) == 0 | ||
return true | ||
end | ||
for a in ARGS | ||
if occursin(lowercase(a), lowercase(descr)) | ||
return true | ||
end | ||
end | ||
return false | ||
end | ||
|
||
macro doset(descr) | ||
quote | ||
if doset($descr) | ||
@safetestset $descr begin | ||
include("test_"*$descr*".jl") | ||
end | ||
end | ||
end | ||
if get(ENV, "GPU_TESTS", "") != "true" | ||
println("skipping gpu tests (set GPU_TESTS=true to test gpu)") | ||
end | ||
|
||
println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...") | ||
# filter for the test | ||
testfilter = ti -> begin | ||
exclude = Symbol[] | ||
if get(ENV,"JET_TEST","")!="true" | ||
push!(exclude, :jet) | ||
end | ||
if !(VERSION >= v"1.10") | ||
push!(exclude, :doctests) | ||
push!(exclude, :aqua) | ||
end | ||
|
||
if get(ENV, "GPU_TESTS", "")!="true" | ||
push!(exclude, :gpu) | ||
end | ||
|
||
# in order to run the gpu tests automatically set GPU_TESTS to true in the .env file | ||
if get(ENV, "GPU_TESTS", "") == "true" | ||
@doset "gpu" | ||
else | ||
println("skipping gpu tests (set GPU_TESTS=true to test gpu)") | ||
return all(!in(exclude), ti.tags) | ||
end | ||
|
||
@doset "throws" | ||
@doset "paulis" | ||
@doset "stabs" | ||
@doset "stabcanon" | ||
@doset "mul_leftright" | ||
@doset "inner" | ||
@doset "embed" | ||
@doset "gf2" | ||
@doset "projections" | ||
@doset "expect" | ||
@doset "trace" | ||
@doset "cliff" | ||
@doset "symcliff" | ||
@doset "symcontrolled" | ||
@doset "classicalreg" | ||
@doset "random" | ||
@doset "noisycircuits" | ||
@doset "syndromemeas" | ||
@doset "bitpack" | ||
@doset "memorylayout" | ||
@doset "graphs" | ||
@doset "hash" | ||
@doset "entanglement" | ||
@doset "enumerate" | ||
@doset "quantumoptics" | ||
@doset "ecc" | ||
@doset "ecc_codeproperties" | ||
@doset "ecc_decoder_all_setups" | ||
@doset "ecc_encoding" | ||
@doset "ecc_gottesman" | ||
@doset "ecc_reedmuller" | ||
@doset "ecc_bch" | ||
@doset "ecc_syndromes" | ||
@doset "ecc_throws" | ||
@doset "precompile" | ||
@doset "pauliframe" | ||
@doset "sumtypecompactification" | ||
@doset "allocations" | ||
VERSION >= v"1.10" && @doset "doctests" | ||
get(ENV,"JET_TEST","")=="true" && @doset "jet" | ||
VERSION >= v"1.10" && @doset "aqua" | ||
println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...") | ||
|
||
@run_package_tests filter=testfilter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using Aqua | ||
using QuantumClifford | ||
Aqua.test_all(QuantumClifford) | ||
@testitem "Aqua" tags=[:aqua] begin | ||
using Aqua | ||
Aqua.test_all(QuantumClifford) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
using Random | ||
using QuantumClifford | ||
@testitem "Classical" begin | ||
using Random | ||
using QuantumClifford: stab_looks_good, destab_looks_good, mixed_stab_looks_good, mixed_destab_looks_good | ||
|
||
using QuantumClifford: stab_looks_good, destab_looks_good, mixed_stab_looks_good, mixed_destab_looks_good | ||
|
||
n=5 | ||
stab = random_stabilizer(n) | ||
mdstab = MixedDestabilizer(stab) | ||
_ = Register(stab) | ||
reg = Register(stab, [0,0,0,0]) | ||
regmd = Register(mdstab, [0,0,0,0]) | ||
@test reg==regmd | ||
@test stabilizerview(reg) == stabilizerview(mdstab) | ||
@test destabilizerview(reg) == destabilizerview(mdstab) | ||
@test logicalxview(reg) == logicalxview(mdstab) | ||
@test logicalzview(reg) == logicalzview(mdstab) | ||
@test bitview(reg) == bitview(regmd) | ||
@test quantumstate(reg) == mdstab | ||
for state in [mdstab,reg,regmd] | ||
for op in [sMX(1,1),sMY(2,2),sMZ(3,3),PauliMeasurement(P"XYZZZ",4),sCNOT(1,2),sCPHASE(2,3),sCNOT(3,4),NoiseOpAll(UnbiasedUncorrelatedNoise(0.1))] | ||
apply!(state,op) | ||
end | ||
for (i,proj) in enumerate([projectXrand!, projectYrand!, projectZrand!]) | ||
proj(state, i) | ||
n=5 | ||
stab = random_stabilizer(n) | ||
mdstab = MixedDestabilizer(stab) | ||
_ = Register(stab) | ||
reg = Register(stab, [0,0,0,0]) | ||
regmd = Register(mdstab, [0,0,0,0]) | ||
@test reg==regmd | ||
@test stabilizerview(reg) == stabilizerview(mdstab) | ||
@test destabilizerview(reg) == destabilizerview(mdstab) | ||
@test logicalxview(reg) == logicalxview(mdstab) | ||
@test logicalzview(reg) == logicalzview(mdstab) | ||
@test bitview(reg) == bitview(regmd) | ||
@test quantumstate(reg) == mdstab | ||
for state in [mdstab,reg,regmd] | ||
for op in [sMX(1,1),sMY(2,2),sMZ(3,3),PauliMeasurement(P"XYZZZ",4),sCNOT(1,2),sCPHASE(2,3),sCNOT(3,4),NoiseOpAll(UnbiasedUncorrelatedNoise(0.1))] | ||
apply!(state,op) | ||
end | ||
for (i,proj) in enumerate([projectXrand!, projectYrand!, projectZrand!]) | ||
proj(state, i) | ||
end | ||
end | ||
@test tab(canonicalize!(stabilizerview(reg))).xzs == tab(canonicalize!(stabilizerview(mdstab))).xzs | ||
end | ||
@test tab(canonicalize!(stabilizerview(reg))).xzs == tab(canonicalize!(stabilizerview(mdstab))).xzs |
Oops, something went wrong.