Skip to content

Commit

Permalink
fix to affectedbit for symbolic measurements (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov authored Nov 2, 2024
1 parent abfcd3c commit 4cc664e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

# News

## v0.9.14 - 2024-11-02

- **(fix)** `affectedqubits()` on `sMX`, `sMY`, and `sMR*`

## v0.9.13 - 2024-10-30

- New error-correction group theory tools:
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QuantumClifford"
uuid = "0525e862-1e90-11e9-3e4d-1b39d7109de1"
authors = ["Stefan Krastanov <stefan@krastanov.org> and QuantumSavory community members"]
version = "0.9.13"
version = "0.9.14"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
3 changes: 1 addition & 2 deletions src/affectedqubits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ affectedqubits(c::CliffordOperator) = 1:nqubits(c)
affectedqubits(c::ClassicalXOR) = ()

affectedbits(o) = ()
affectedbits(m::sMRZ) = (m.bit,)
affectedbits(m::sMZ) = (m.bit,)
affectedbits(m::Union{sMRZ,sMZ,sMRX,sMX,sMRY,sMY}) = m.bit==0 ? () : (m.bit,)
affectedbits(c::ClassicalXOR) = (c.bits..., c.store)
35 changes: 35 additions & 0 deletions test/test_symmeas.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@testitem "Symbolic Measurements" begin
using Random
using QuantumClifford
using Test
test_sizes = [10,63,64,65,127,128,129] # Including sizes that would test off-by-one errors in the bit encoding.

@testset "Symbolic Measurements" begin
for n in test_sizes
for i in [rand(1:n), 1, n, n÷2+1, n÷2-1, n÷2]
for T in [sMRZ,sMZ,sMRX,sMX] # TODO sMY sMRY
for _ in 1:10
apply!(PauliFrame(n,n,n), T(i,1))
end
end
end
for i in [rand(1:n), 1, n, n÷2+1, n÷2-1, n÷2]
for T in [sMRZ,sMZ,sMRX,sMX,sMY] # TODO sMRY
for _ in 1:10
s = random_stabilizer(n)
apply!(Register(copy(s),1), T(i,1))
end
end
end
end
@test_throws DimensionMismatch SingleQubitOperator(tCNOT,1)
@test_throws DimensionMismatch CliffordOperator(sHadamard(5),2)
@test_throws ArgumentError CliffordOperator(sHadamard(5),6,compact=true)
for T in [sMRZ,sMZ,sMRX,sMX,sMRY,sMY]
@test_throws ArgumentError T(-1)
@test_throws ArgumentError T(-1,0)
@test_throws ArgumentError T(-1,1)
@test T(1,0) == T(1)
end
end
end

0 comments on commit 4cc664e

Please sign in to comment.