Skip to content

Commit

Permalink
Merge branch 'nonclif' into project
Browse files Browse the repository at this point in the history
  • Loading branch information
Fe-r-oz authored Nov 9, 2024
2 parents 7ed7033 + f90a4ed commit e6e21fd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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
6 changes: 5 additions & 1 deletion src/nonclifford.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ function _proj(sm::GeneralizedStabilizer, p::PauliOperator)
return sm, res
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 @@ -430,7 +434,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 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 e6e21fd

Please sign in to comment.