Skip to content

Commit

Permalink
Fixed doctests (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Krastanov <[email protected]>
Co-authored-by: Stefan Krastanov <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent e33370e commit e9896fd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/CircuitZoo/CircuitZoo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```
Expand Down Expand Up @@ -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)
Expand Down
28 changes: 20 additions & 8 deletions src/StatesZoo/single_dual_rail_midswap/single_dual_rail_midswap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/StatesZoo/zalm_pair/zalm_pair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/quantumchannel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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))
Expand All @@ -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}
Expand Down

0 comments on commit e9896fd

Please sign in to comment.