Skip to content

Commit

Permalink
Merge pull request #67 from ytdHuang/fix/Qobj-strings
Browse files Browse the repository at this point in the history
Modify `QuantumObject` strings in `show()`
  • Loading branch information
albertomercurio authored Apr 9, 2024
2 parents 49f96f6 + 82b7bb2 commit 1f95c29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/quantum_object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,12 @@ function _check_QuantumObject(type::SuperOperatorQuantumObject, prod_dims::Int,
end

function _check_QuantumObject(type::OperatorKetQuantumObject, prod_dims::Int, m::Int, n::Int)
(n != 1) ? throw(DomainError((m, n), "The dimension of the array is not compatible with Operator-Ket type")) : nothing
(n != 1) ? throw(DomainError((m, n), "The dimension of the array is not compatible with OperatorKet type")) : nothing
prod_dims != sqrt(m) ? throw(DimensionMismatch("The dims parameter does not fit the dimension of the Array.")) : nothing
end

function _check_QuantumObject(type::OperatorBraQuantumObject, prod_dims::Int, m::Int, n::Int)
(m != 1) ? throw(DomainError((m, n), "The dimension of the array is not compatible with Operator-Bra type")) : nothing
(m != 1) ? throw(DomainError((m, n), "The dimension of the array is not compatible with OperatorBra type")) : nothing
prod_dims != sqrt(n) ? throw(DimensionMismatch("The dims parameter does not fit the dimension of the Array.")) : nothing
end

Expand Down Expand Up @@ -336,9 +336,9 @@ function Base.show(io::IO, ::MIME"text/plain", QO::QuantumObject{<:AbstractArray
elseif op_type isa BraQuantumObject
op_type = "Bra"
elseif op_type isa OperatorKetQuantumObject
op_type = "Operator-Ket"
op_type = "OperatorKet"
elseif op_type isa OperatorBraQuantumObject
op_type = "Operator-Bra"
op_type = "OperatorBra"
else
op_type = "SuperOperator"
end
Expand Down
4 changes: 2 additions & 2 deletions test/quantum_objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ2.data)
ψ2_dims = ψ2.dims
ψ2_size = size(ψ2)
@test opstring == "Quantum Object: type=Operator-Ket dims=$ψ2_dims size=$ψ2_size\n$datastring"
@test opstring == "Quantum Object: type=OperatorKet dims=$ψ2_dims size=$ψ2_size\n$datastring"

ψ2 = ψ2'
opstring = sprint((t, s) -> show(t, "text/plain", s), ψ2)
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ2.data)
ψ2_dims = ψ2.dims
ψ2_size = size(ψ2)
@test opstring == "Quantum Object: type=Operator-Bra dims=$ψ2_dims size=$ψ2_size\n$datastring"
@test opstring == "Quantum Object: type=OperatorBra dims=$ψ2_dims size=$ψ2_size\n$datastring"

ψ = coherent(30, 3)
α, δψ = get_coherence(ψ)
Expand Down

0 comments on commit 1f95c29

Please sign in to comment.