-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor tests to use TestItems.jl (#142)
--------- Co-authored-by: Stefan Krastanov <[email protected]>
- Loading branch information
Showing
33 changed files
with
159 additions
and
171 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
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,59 +1,19 @@ | ||
using SafeTestsets | ||
using QuantumSavory | ||
|
||
function doset(descr) | ||
if length(ARGS) == 0 | ||
return true | ||
end | ||
for a in ARGS | ||
if occursin(lowercase(a), lowercase(descr)) | ||
return true | ||
end | ||
using TestItemRunner | ||
|
||
function testfilter(tags) | ||
exclude = Symbol[] | ||
# Only do the plotting tests if the ENV variable `QUANTUMSAVORY_PLOT_TEST` is set | ||
if get(ENV,"QUANTUMSAVORY_PLOT_TEST","")!="true" | ||
push!(exclude, :plotting_cairo) | ||
push!(exclude, :plotting_gl) | ||
push!(exclude, :doctests) | ||
end | ||
return false | ||
end | ||
|
||
macro doset(descr) | ||
quote | ||
if doset($descr) | ||
@safetestset $descr begin include("test_"*$descr*".jl") end | ||
end | ||
if get(ENV,"JET_TEST","")!="true" | ||
push!(exclude, :jet) | ||
end | ||
return all(!in(exclude), tags) | ||
end | ||
|
||
println("Starting tests with $(Threads.nthreads()) threads out of `Sys.CPU_THREADS = $(Sys.CPU_THREADS)`...") | ||
|
||
@doset "quantumchannel" | ||
@doset "register_interface" | ||
@doset "project_traceout" | ||
@doset "observable" | ||
@doset "noninstant_and_backgrounds_qubit" | ||
@doset "noninstant_and_backgrounds_qumode" | ||
@doset "messagebuffer" | ||
@doset "tags_and_queries" | ||
|
||
@doset "protocolzoo_entanglement_tracker" | ||
@doset "protocolzoo_entanglement_consumer" | ||
@doset "protocolzoo_entanglement_tracker_grid" | ||
@doset "protocolzoo_switch" | ||
@doset "protocolzoo_throws" | ||
@doset "protocolzoo_cutoffprot" | ||
|
||
@doset "circuitzoo_api" | ||
@doset "circuitzoo_ent_swap" | ||
@doset "circuitzoo_purification" | ||
@doset "circuitzoo_superdense" | ||
|
||
@doset "stateszoo_api" | ||
|
||
if get(ENV,"QUANTUMSAVORY_PLOT_TEST","")=="true" | ||
using Pkg | ||
Pkg.add("GLMakie") | ||
end | ||
@doset "examples" | ||
get(ENV,"QUANTUMSAVORY_PLOT_TEST","")=="true" && @doset "plotting_cairo" | ||
get(ENV,"QUANTUMSAVORY_PLOT_TEST","")=="true" && @doset "plotting_gl" | ||
get(ENV,"QUANTUMSAVORY_PLOT_TEST","")=="true" && VERSION >= v"1.9" && @doset "doctests" | ||
|
||
get(ENV,"JET_TEST","")=="true" && @doset "jet" | ||
@doset "aqua" | ||
@run_package_tests filter=ti->testfilter(ti.tags) verbose=true |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using QuantumSavory.CircuitZoo | ||
using QuantumSavory.CircuitZoo: EntanglementSwap, Purify2to1, Purify3to1, Purify3to1Node, Purify2to1Node, PurifyStringent, StringentHead, StringentBody, PurifyExpedient, PurifyStringentNode, PurifyExpedient | ||
|
||
const bell = StabilizerState("XX ZZ") | ||
export bell; | ||
# or equivalently `const bell = (Z₁⊗Z₁+Z₂⊗Z₂)/√2`, | ||
# however converting to stabilizer state for Clifford simulations | ||
# is not implemented (and can not be done efficiently). | ||
|
||
|
||
# QOptics repr | ||
const perfect_pair = (Z1⊗Z1 + Z2⊗Z2) / sqrt(2) | ||
const perfect_pair_dm = SProjector(perfect_pair) | ||
const mixed_dm = MixedState(perfect_pair_dm) | ||
noisy_pair_func(F) = F*perfect_pair_dm + (1-F)*mixed_dm # TODO make a depolarization helper | ||
|
||
|
||
# Qclifford repr | ||
const stab_perfect_pair = StabilizerState("XX ZZ") | ||
const stab_perfect_pair_dm = SProjector(stab_perfect_pair) | ||
const stab_mixed_dm = MixedState(stab_perfect_pair_dm) | ||
stab_noisy_pair_func(F) = F*stab_perfect_pair_dm + (1-F)*stab_mixed_dm |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
using Pkg | ||
Pkg.add("GLMakie") |
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
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
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
Oops, something went wrong.