Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qobj/quantum_object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Base.show(
return show(io, MIME("text/plain"), op_data)
end

function Base.show(io::IO, QO::AbstractQuantumObject)
function Base.show(io::IO, QO::QuantumObject)
op_data = QO.data
println(
io,
Expand Down
18 changes: 18 additions & 0 deletions src/qobj/quantum_object_evo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ struct QuantumObjectEvolution{
end
end

function Base.show(io::IO, QO::QuantumObjectEvolution)
op_data = QO.data
println(
io,
"Quantum Object Evo.: type=",
QO.type,
" dims=",
QO.dims,
" size=",
size(op_data),
" ishermitian=",
ishermitian(op_data),
" isconstant=",
isconstant(op_data),
)
return show(io, MIME("text/plain"), op_data)
end

function QuantumObjectEvolution(data::AbstractSciMLOperator, type::QuantumObjectType, dims::Integer)
return QuantumObjectEvolution(data, type, SVector{1,Int}(dims))
end
Expand Down
46 changes: 25 additions & 21 deletions test/core-test/quantum_objects_evo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,27 +93,31 @@
@test issymmetric(Z) == true
end

# TODO: Implement a new show method for QuantumObjectEvolution
# @testset "REPL show" begin
# N = 10
# a = QobjEvo(destroy(N))

# opstring = sprint((t, s) -> show(t, "text/plain", s), a)
# datastring = sprint((t, s) -> show(t, "text/plain", s), a.data)
# a_dims = a.dims
# a_size = size(a)
# a_isherm = isherm(a)
# @test opstring ==
# "Quantum Object: type=Operator dims=$a_dims size=$a_size ishermitian=$a_isherm\n$datastring"

# a = spre(a)
# opstring = sprint((t, s) -> show(t, "text/plain", s), a)
# datastring = sprint((t, s) -> show(t, "text/plain", s), a.data)
# a_dims = a.dims
# a_size = size(a)
# a_isherm = isherm(a)
# @test opstring == "Quantum Object: type=SuperOperator dims=$a_dims size=$a_size\n$datastring"
# end
@testset "REPL show" begin
N = 10
a = destroy(N)
coef(p, t) = exp(-1im * t)
H = QobjEvo((a' * a, (a, coef)))

opstring = sprint((t, s) -> show(t, "text/plain", s), H)
datastring = sprint((t, s) -> show(t, "text/plain", s), H.data)
H_dims = H.dims
H_size = size(H)
H_isherm = isherm(H)
H_isconst = isconstant(H)
@test opstring ==
"Quantum Object Evo.: type=Operator dims=$H_dims size=$H_size ishermitian=$H_isherm isconstant=$H_isconst\n$datastring"

L = QobjEvo(spre(a))
opstring = sprint((t, s) -> show(t, "text/plain", s), L)
datastring = sprint((t, s) -> show(t, "text/plain", s), L.data)
L_dims = L.dims
L_size = size(L)
L_isherm = isherm(L)
L_isconst = isconstant(L)
@test opstring ==
"Quantum Object Evo.: type=SuperOperator dims=$L_dims size=$L_size ishermitian=$L_isherm isconstant=$L_isconst\n$datastring"
end

@testset "Type Inference (QuantumObject)" begin
for T in [ComplexF32, ComplexF64]
Expand Down