Skip to content

Commit

Permalink
modify QuantumObject strings in show()
Browse files Browse the repository at this point in the history
  • Loading branch information
ytdHuang committed Apr 9, 2024
1 parent ed5d355 commit 82b7bb2
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

Check warning on line 184 in src/quantum_object.jl

View check run for this annotation

Codecov / codecov/patch

src/quantum_object.jl#L184

Added line #L184 was not covered by tests
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

Check warning on line 189 in src/quantum_object.jl

View check run for this annotation

Codecov / codecov/patch

src/quantum_object.jl#L189

Added line #L189 was not covered by tests
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"

Check warning on line 339 in src/quantum_object.jl

View check run for this annotation

Codecov / codecov/patch

src/quantum_object.jl#L339

Added line #L339 was not covered by tests
elseif op_type isa OperatorBraQuantumObject
op_type = "Operator-Bra"
op_type = "OperatorBra"

Check warning on line 341 in src/quantum_object.jl

View check run for this annotation

Codecov / codecov/patch

src/quantum_object.jl#L341

Added line #L341 was not covered by tests
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 82b7bb2

Please sign in to comment.