Skip to content

Commit 47135d7

Browse files
committed
add tests
1 parent c8bff51 commit 47135d7

File tree

7 files changed

+36
-4
lines changed

7 files changed

+36
-4
lines changed

docs/src/index.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ A repository for *quantum error correction* (QEC) codes.
77

88

99
## Quantum Code list
10-
1110
| Code name | Struct |
1211
| -------- | ------- |
1312
| Perfect 5-qubit code | [`Perfect5`](@ref) |

src/codes/classical/repetition.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ Bitflip3 is a quantum error correction code that corrects single-qubit bit-flip
2020
"""
2121
struct Bitflip3 <: AbstractQECC end
2222

23-
parity_matrix(c::Bitflip3) = hcat(zeros(Bool,3,3), parity_matrix(RepCode(3)))
23+
parity_matrix(c::Bitflip3) = hcat(zeros(Bool,2,3), parity_matrix(RepCode(3))[1:2,:])
2424

2525
"""Three-qubit phase-flip code.
2626
2727
Phaseflip3 is a quantum error correction code that corrects single-qubit phase-flip error and does not detect any bit-flip errors.
2828
"""
2929
struct Phaseflip3 <: AbstractQECC end
3030

31-
parity_matrix(c::Phaseflip3) = hcat(parity_matrix(RepCode(3)), zeros(Bool,3,3))
31+
parity_matrix(c::Phaseflip3) = hcat(parity_matrix(RepCode(3))[1:2,:], zeros(Bool,2,3))

test/codes/classical/repetition.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,16 @@ using QECC
1010
1 0 0 0 1]
1111
@test code_n(c) == 5
1212
@test code_s(c) == 5
13+
end
14+
15+
@testset "Bitflip3" begin
16+
c = Bitflip3()
17+
@test parity_matrix(c) == Bool[0 0 0 1 1 0;
18+
0 0 0 0 1 1]
19+
end
20+
21+
@testset "Phaseflip3" begin
22+
c = Phaseflip3()
23+
@test parity_matrix(c) == Bool[1 1 0 0 0 0;
24+
0 1 1 0 0 0]
1325
end

test/codes/css.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Test
2+
using QECC
3+
4+
@testset "CSS" begin
5+
h = QECC._steane_mat()
6+
c = CSS(h, h)
7+
@test parity_matrix(c) == parity_matrix(Steane7())
8+
@test parity_matrix_x(c) == h
9+
@test parity_matrix_z(c) == h
10+
end

test/codes/surfacecode.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ using QECC
77
0 1 0 1 1 0 0 0 0 0;
88
0 0 0 0 0 1 1 0 0 1;
99
0 0 0 0 0 0 0 1 1 1]
10+
@test parity_matrix_x(c) == Bool[1 0 1 0 1;
11+
0 1 0 1 1]
12+
@test parity_matrix_z(c) == Bool[1 1 0 0 1;
13+
0 0 1 1 1]
1014
@test distance(c) == 2
1115
@test code_n(c) == 5
1216
@test code_s(c) == 4

test/codes/toric.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ using QECC
33

44
@testset "Toric" begin
55
c = Toric(2,2)
6-
@test parity_matrix(c) == Bool[1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0;
6+
pm = Bool[1 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0;
77
0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0;
88
1 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0;
99
0 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0;
1010
0 0 0 0 0 0 0 0 1 1 0 0 0 1 0 1;
1111
0 0 0 0 0 0 0 0 0 0 1 1 1 0 1 0]
12+
@test parity_matrix(c) == pm
13+
@test parity_matrix_x(c) == pm[1:3,1:8]
14+
@test parity_matrix_z(c) == pm[4:6,9:end]
1215
@test distance(c) == 2
1316
@test code_n(c) == 8
1417
@test code_s(c) == 6

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ end
2727

2828
@testset "clevecode" begin
2929
include("codes/clevecode.jl")
30+
end
31+
32+
@testset "css" begin
33+
include("codes/css.jl")
3034
end

0 commit comments

Comments
 (0)