From e9896fd6bbf516c7724c3c7e0ff52f5f3840da86 Mon Sep 17 00:00:00 2001 From: Abhishek Bhatt <46929125+Abhishek-1Bhatt@users.noreply.github.com> Date: Fri, 17 Nov 2023 13:03:32 -0500 Subject: [PATCH] Fixed doctests (#60) Co-authored-by: Stefan Krastanov Co-authored-by: Stefan Krastanov --- src/CircuitZoo/CircuitZoo.jl | 8 +++--- .../single_dual_rail_midswap.jl | 28 +++++++++++++------ src/StatesZoo/zalm_pair/zalm_pair.jl | 18 ++++++++---- src/quantumchannel.jl | 9 ++---- 4 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/CircuitZoo/CircuitZoo.jl b/src/CircuitZoo/CircuitZoo.jl index e470e663..198bd85b 100644 --- a/src/CircuitZoo/CircuitZoo.jl +++ b/src/CircuitZoo/CircuitZoo.jl @@ -864,11 +864,11 @@ to its corresponding Bell pair representation. It takes as argumes a single qubi Alice's half of the entangled Bell pair and the 2 bit message Alice intends to send to Bob. ```jldoctest -julia> regA = Register(1); regB = Register(2); +julia> regA = Register(1); regB = Register(1); julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2); -julia> message = [1, 1]; +julia> message = (1, 1); julia> SDEncode()(regA[1], message); ``` @@ -904,9 +904,9 @@ julia> regA = Register(1); regB = Register(1); julia> initialize!((regA[1], regB[1]), (L0⊗L0+L1⊗L1)/√2); -julia> message = [1, 1]; +julia> message = (1, 1); -julia> SDEncode()(regA, message); +julia> SDEncode()(regA[1], message); julia> SDDecode()(regA[1], regB[1]) (1, 1) diff --git a/src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl b/src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl index 10e5e1ac..ae6c76a5 100644 --- a/src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl +++ b/src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl @@ -45,11 +45,14 @@ It takes the following parameters: - Vis: Interferometer visibility for the midpoint swap' can be complex to account for phase instability ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: SingleRailMidSwapBellW -julia> initialize!(r[1:2], SingleRailMidSwapBellW(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)) +julia> r = Register(2); + +julia> initialize!(r[1:2], SingleRailMidSwapBellW(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)); julia> observable(r[1:2], Z⊗Z) +-0.202499993925 + 0.0im ``` """ @withmetadata struct SingleRailMidSwapBellW <: AbstractTwoQubitState @@ -80,11 +83,14 @@ It takes the following parameters: - Vis: Interferometer visibility for the midpoint swap' can be complex to account for phase instability ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: SingleRailMidSwapBell + +julia> r = Register(2); -julia> initialize!(r[1:2], SingleRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)) +julia> initialize!(r[1:2], SingleRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)); julia> observable(r[1:2], Z⊗Z) +-0.8181818000000001 + 0.0im ``` """ @withmetadata struct SingleRailMidSwapBell <: AbstractTwoQubitState @@ -117,11 +123,14 @@ from the normalized object `DualRailMidSwapBell`. - Vis: Interferometer visibility for the midpoint swap ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: DualRailMidSwapBellW -julia> initialize!(r[1:2], DualRailMidSwapBellW(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)) +julia> r = Register(2); + +julia> initialize!(r[1:2], DualRailMidSwapBellW(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)); julia> observable(r[1:2], Z⊗Z) +-0.10124999595000005 + 0.0im ``` """ @withmetadata struct DualRailMidSwapBellW <: AbstractTwoQubitState @@ -152,11 +161,14 @@ Generates the normalized spin-spin density matrix for linear photonic entangleme - Vis: Interferometer visibility for the midpoint swap ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: DualRailMidSwapBell + +julia> r = Register(2); -julia> initialize!(r[1:2], DualRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)) +julia> initialize!(r[1:2], DualRailMidSwapBell(0.9, 0.9, 0.5, 0.5, 1e-8, 0.99)); julia> observable(r[1:2], Z⊗Z) +-0.9999999911111113 + 0.0im ``` """ @withmetadata struct DualRailMidSwapBell <: AbstractTwoQubitState diff --git a/src/StatesZoo/zalm_pair/zalm_pair.jl b/src/StatesZoo/zalm_pair/zalm_pair.jl index 261b2553..08a95bd9 100644 --- a/src/StatesZoo/zalm_pair/zalm_pair.jl +++ b/src/StatesZoo/zalm_pair/zalm_pair.jl @@ -588,11 +588,14 @@ It takes the following parameters: - VisF: product of visibilities of all three interferometers (Allowed range: [0,1]) ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: ZALMSpinPairW -julia> initialize!(r[1:2], ZALMSpinPairW(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)) +julia> r = Register(2); -juilia> observable(r[1:2], Z⊗Z) +julia> initialize!(r[1:2], ZALMSpinPairW(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)); + +julia> observable(r[1:2], Z⊗Z) +-6.290288032211147e-9 + 0.0im ``` """ @withmetadata struct ZALMSpinPairW <: AbstractTwoQubitState @@ -639,11 +642,14 @@ It takes the following parameters: - VisF: product of visibilities of all three interferometers (Allowed range: [0,1]) ```jldoctest -julia> r = Register(2) +julia> using QuantumSavory.StatesZoo: ZALMSpinPair + +julia> r = Register(2); -julia> initialize!(r[1:2], ZALMSpinPair(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)) +julia> initialize!(r[1:2], ZALMSpinPair(1e-3, 0.5, 0.5, 1, 1, 1, 1, 0.9, 1e-8, 1e-8, 1e-8, 0.99)); -juilia> observable(r[1:2], Z⊗Z) +julia> observable(r[1:2], Z⊗Z) +-0.9999999911111112 + 0.0im ``` """ @withmetadata struct ZALMSpinPair <: AbstractTwoQubitState diff --git a/src/quantumchannel.jl b/src/quantumchannel.jl index dfb916a2..3d8f5f21 100644 --- a/src/quantumchannel.jl +++ b/src/quantumchannel.jl @@ -6,7 +6,7 @@ Delay and background noise processes are supported. The function `put!` is used to take the contents of a `RegRef` and put it in the channel. That state can can then be received by a register (after a delay) using the `take!` method. -```jldoctest; filter = r"(\\d{4})\\d+" => s"at some memory address" +```jldoctest julia> using QuantumSavory, ResumableFunctions, ConcurrentSim julia> regA = Register(1); regB = Register(1); @@ -16,7 +16,7 @@ julia> initialize!(regA[1], Z1); julia> sim = Simulation(); julia> qc = QuantumChannel(sim, 10.0) # a delay of 10 units -QuantumChannel(Qubit(), DelayQueue{Register}(QueueStore{Register, Int64}, 10.0), nothing) +QuantumChannel{Qubit}(Qubit(), DelayQueue{Register}(ConcurrentSim.QueueStore{Register, Int64}, 10.0), nothing) julia> @resumable function alice_node(env, qc) println("Putting Alice's qubit in the channel at ", now(env)) @@ -40,11 +40,6 @@ julia> regA Register with 1 slots: [ Qubit ] Slots: nothing - -julia> regB -Register with 1 slots: [ Qubit ] -Slots: - Subsystem 1 of QuantumOpticsBase.Ket 7474956998997307987 ``` """ struct QuantumChannel{T}