Skip to content

Commit

Permalink
Fix typo in enumerate_cliffords and add tests
Browse files Browse the repository at this point in the history
Fixes #60

Signed-off-by: Stefan Krastanov <stefan@krastanov.org>
  • Loading branch information
Krastanov committed Jun 11, 2022
1 parent 92fc012 commit 3ac1bf2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# News

## v0.5.3 - 2022-06-11

- **(fix `#60`)** `enumerate_clifford` was broken due to an earlier refactor in `rowswap!`

## v0.5.2

- Implement the clipped gauge canonicalization `canonicalize_clip!` and related functions.
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>"]
version = "0.5.2"
version = "0.5.3"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
6 changes: 3 additions & 3 deletions src/enumeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ end
comm(basis, δn+start, i)==0x1 && return i
end
# the following hapens only if the input is P"X___..."
rowswap!(basis, δn+start, 2padded_n+1)
rowswap!(basis, δn+start, 2padded_n+1; phases=Val(false))
_findanticommGS(basis, start, n, padded_n, δn)
end

Expand Down Expand Up @@ -104,7 +104,7 @@ function symplecticGS(pauli::PauliOperator; padded_n=nqubits(pauli))
doneupto = 1
while doneupto <= n
i = _findanticommGS(basis, doneupto, n, padded_n, δn)
rowswap!(basis, padded_n+δn+doneupto, i; phases=false)
rowswap!(basis, padded_n+δn+doneupto, i; phases=Val(false))
_eliminateGS(basis, doneupto, n, padded_n, δn)
doneupto += 1
end
Expand Down Expand Up @@ -196,4 +196,4 @@ julia> length(collect(enumerate_phases(enumerate_cliffords(2))))
See also: [`enumerate_cliffords`](@ref), [`clifford_cardinality`](@ref)."""
function enumerate_phases(ops::Union{AbstractVector,Base.Generator})
Iterators.flatten(Iterators.map(enumerate_phases, ops))
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ doset("bitpack") && include("./test_bitpack.jl")
doset("graphs") && include("./test_graphs.jl")
doset("hash") && include("./test_hash.jl")
doset("entanglement") && include("./test_entanglement.jl")
doset("enumeration") && include("./test_enumerate.jl")
doset("doctests") && include("./doctests.jl")

using Aqua
Expand Down
11 changes: 11 additions & 0 deletions test/test_enumerate.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function test_enumeration()
@testset "Enumeration" begin
@test Set([copy(op) for op in enumerate_cliffords(1)]) == Set((random_clifford(1,phases=false) for i in 1:70))
@test Set([copy(op) for op in enumerate_phases(enumerate_cliffords(1))]) == Set((random_clifford(1,phases=true) for i in 1:300))
@test length(collect(enumerate_cliffords(2))) == length(collect(enumerate_phases(enumerate_cliffords(2))))/2^4 == 720
@test first(enumerate_cliffords(3)) == C"X__ __Z _Z_ Z__ __X _X_"
@test first(enumerate_cliffords(5)) == C"X____ ____Z ___Z_ __Z__ _Z___ Z____ ____X ___X_ __X__ _X___"
end
end

test_enumeration()

12 comments on commit 3ac1bf2

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator

Release Notes:

  • (fix #60) enumerate_clifford was broken due to an earlier refactor in rowswap!

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator

Release Notes:

  • (fix #60) enumerate_clifford was broken due to an earlier refactor in rowswap!

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator

Release Notes:

  • (fix #60) enumerate_clifford was broken due to an earlier refactor in rowswap!

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator

Release Notes:

  • (fix #60) enumerate_clifford was broken due to an earlier refactor in rowswap!

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unexpected error occurred during registration.

@Krastanov
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release Notes:

  • (fix #60) enumerate_clifford was broken due to an earlier refactor in rowswap!

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/62234

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.3 -m "<description of version>" 3ac1bf2bc3030a84487e0a199c01dc8a3f4115ae
git push origin v0.5.3

Please sign in to comment.