Skip to content

Commit

Permalink
fixes to Quantikz plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
Krastanov committed Jun 20, 2023
1 parent cd7e90d commit 9917f6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

# News

## v0.8.5 - dev
## v0.8.6 - 2023-06-20

- Fixes to Quantikz circuit plotting of empty circuits and `PauliOperator`

## v0.8.5 - 2023-06-13

- Internal helper method `mul_right!` is now available for right Pauli inplace multiplication.
- Implemented `sMRZ` to reset single qubits to the |0⟩ (and respectively `sMRX` and `sMRY`).
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 <[email protected]>"]
version = "0.8.5"
version = "0.8.6"

[deps]
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
Expand Down
10 changes: 8 additions & 2 deletions ext/QuantumCliffordQuantikzExt/QuantumCliffordQuantikzExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function Quantikz.QuantikzOp(op::SparseGate)
end
end
Quantikz.QuantikzOp(op::AbstractOperation) = Quantikz.MultiControlU(affectedqubits(op))
Quantikz.QuantikzOp(op::PauliOperator) = Quantikz.MultiControlU("\\begin{array}{c}$(lstring(op))\\end{array}", affectedqubits(op))
Quantikz.QuantikzOp(op::sId1) = Quantikz.Id(affectedqubits(op)...)
function Quantikz.QuantikzOp(op::AbstractSingleQubitOperator)
T = typeof(op)
Expand Down Expand Up @@ -83,8 +84,13 @@ function lstring(stab::Stabilizer)
v = join(("\\mathtt{$(replace(string(p),"_"=>"I"))}" for p in stab),"\\\\")
end

Base.show(io::IO, mime::MIME"image/png", circuit::AbstractVector{<:AbstractOperation}; scale=1, kw...) =
show(io, mime, [Quantikz.QuantikzOp(c) for c in circuit]; scale=scale, kw...)
function Base.show(io::IO, mime::MIME"image/png", circuit::AbstractVector{<:AbstractOperation}; scale=1, kw...)
if length(circuit)==0
show(io, mime, [Quantikz.Id(1)]; scale=scale, kw...)
else
show(io, mime, [Quantikz.QuantikzOp(c) for c in circuit]; scale=scale, kw...)
end
end
Base.show(io::IO, mime::MIME"image/png", gate::T; scale=1, kw...) where T<:AbstractOperation =
show(io, mime, Quantikz.QuantikzOp(gate); scale=scale, kw...)

Expand Down
1 change: 1 addition & 0 deletions src/affectedqubits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ affectedqubits(b::BellMeasurement) = [m.qubit for m in b.measurements]
affectedqubits(r::Reset) = r.indices
affectedqubits(n::NoiseOp) = n.indices
affectedqubits(g::PauliMeasurement) = 1:length(g.pauli)
affectedqubits(p::PauliOperator) = 1:length(p)
affectedqubits(m::AbstractMeasurement) = [m.qubit]

0 comments on commit 9917f6a

Please sign in to comment.