-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automate many of the ECC tests to avoid skipping new codes (#250)
- Loading branch information
Showing
9 changed files
with
87 additions
and
104 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Test | ||
using QuantumClifford | ||
using QuantumClifford.ECC | ||
using InteractiveUtils | ||
|
||
# generate instances of all implemented codes to make sure nothing skips being checked | ||
|
||
const code_instance_args = Dict( | ||
Toric => [(3,3), (4,4), (3,6), (4,3), (5,5)], | ||
Surface => [(3,3), (4,4), (3,6), (4,3), (5,5)], | ||
Gottesman => [3, 4, 5], | ||
CSS => (c -> (parity_checks_x(c), parity_checks_z(c))).([Shor9(), Steane7(), Toric(4,4)]) | ||
) | ||
|
||
function all_testablable_code_instances(;maxn=nothing) | ||
codeinstances = [] | ||
for t in subtypes(QuantumClifford.ECC.AbstractECC) | ||
for c in get(code_instance_args, t, []) | ||
codeinstance = t(c...) | ||
!isnothing(maxn) && nqubits(codeinstance) > maxn && continue | ||
push!(codeinstances, codeinstance) | ||
end | ||
end | ||
return codeinstances | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Test | ||
using QuantumClifford | ||
using QuantumClifford.ECC | ||
using QuantumClifford.ECC: AbstractECC | ||
|
||
include("test_ecc_base.jl") | ||
|
||
function is_css_matrix(H) | ||
nrows, ncols = size(H) | ||
for i in 1:nrows | ||
has_x = false | ||
has_z = false | ||
for j in 1:ncols | ||
has_x |= H[i,j][1] | ||
has_z |= H[i,j][2] | ||
has_x && has_z && return false | ||
end | ||
end | ||
return true | ||
end | ||
|
||
@testset "is CSS" begin | ||
for code in all_testablable_code_instances() | ||
H = parity_checks(code) | ||
@test iscss(code) == is_css_matrix(H) | ||
end | ||
end | ||
|
||
@testset "code tableau consistency" begin | ||
for code in all_testablable_code_instances() | ||
H = parity_checks(code) | ||
@test nqubits(code) == size(H, 2) == code_n(code) | ||
@test size(H, 1) == code_s(code) | ||
@test code_s(code) + code_k(code) == code_n(code) | ||
@test size(H, 1) < size(H, 2) | ||
_, _, rank = canonicalize!(copy(H), ranks=true) | ||
@test rank == size(H, 1) # TODO maybe weaken this if we want to permit codes with redundancies | ||
@test QuantumClifford.stab_looks_good(copy(H)) | ||
end | ||
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
This file was deleted.
Oops, something went wrong.
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,6 +1,7 @@ | ||
using Test | ||
using QuantumClifford | ||
using QuantumClifford.ECC | ||
using QuantumClifford.ECC: ReedMuller | ||
|
||
@test_throws ArgumentError ReedMuller(-1, 3) | ||
@test_throws ArgumentError ReedMuller(1, 0) | ||
@test_throws ArgumentError ReedMuller(1, 0) |