Skip to content

Commit

Permalink
Merge branch 'nonclif' into fa/i418fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz authored Nov 8, 2024
2 parents d54a759 + f90a4ed commit 446d1f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/QuantumClifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,22 @@ function __init__()
BIG_INT_MINUS_ONE[] = BigInt(-1)
BIG_INT_TWO[] = BigInt(2)
BIG_INT_FOUR[] = BigInt(4)

# Register error hint for the `project!` method for GeneralizedStabilizer
if isdefined(Base.Experimental, :register_error_hint)
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
if exc.f === project! && argtypes[1] <: GeneralizedStabilizer
print(io, """
\nThe method `project!` is not appropriate for use with`GeneralizedStabilizer`.
You probably are looking for `projectrand!`.
`project!` in this library is a low-level "linear algebra" method to verify
whether a measurement operator commutes with a set of stabilizers, and to
potentially simplify the tableau and provide the index of the anticommuting
term in that tableau. This linear algebra operation is not defined for
`GeneralStabilizer` as there is no single tableau to provide an index into.""")
end
end
end
end

const NoZeroQubit = ArgumentError("Qubit indices have to be larger than zero, but you are attempting to create a gate acting on a qubit with a non-positive index. Ensure indexing always starts from 1.")
Expand Down
8 changes: 6 additions & 2 deletions src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ function _proj(sm::GeneralizedStabilizer, p::PauliOperator)
error("This functionality is not implemented yet")
end

function project!(s::GeneralizedStabilizer, p::PauliOperator)
throw(MethodError(project!, (s, p)))
end

nqubits(sm::GeneralizedStabilizer) = nqubits(sm.stab)

abstract type AbstractPauliChannel <: AbstractOperation end
Expand Down Expand Up @@ -425,7 +429,7 @@ of `χ`. It provides a measure of the state's complexity, with bounds
`Λ(χ) ≤ 4ⁿ`.
```jldoctest heuristic
julia> using QuantumClifford: invsparsity;
julia> using QuantumClifford: invsparsity; # hide
julia> sm = GeneralizedStabilizer(S"X")
A mixture ∑ ϕᵢⱼ Pᵢ ρ Pⱼ† where ρ is
Expand All @@ -441,7 +445,7 @@ julia> apply!(sm, pcT) |> invsparsity
```
Similarly, it calculates the number of non-zero elements in the density
matrix `ϕᵢⱼ` of a PauliChannel, providing a measure of the channel
matrix `ϕᵢⱼ` of a PauliChannel, providing a measure of the channel
complexity.
```jldoctest heuristic
Expand Down
1 change: 1 addition & 0 deletions test/test_nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ end
@test_throws ArgumentError PauliChannel(((P"X", P"Z"), (P"X", P"Z")), (1,))
@test_throws ArgumentError UnitaryPauliChannel((P"X", P"ZZ"), (1,2))
@test_throws ArgumentError UnitaryPauliChannel((P"X", P"Z"), (1,))
@test_throws MethodError project!(GeneralizedStabilizer(S"X"), P"X")

0 comments on commit 446d1f1

Please sign in to comment.