Skip to content

Commit f445518

Browse files
committed
improve show for Qobj lists
1 parent 270d3f6 commit f445518

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/qobj/quantum_object.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,15 @@ function Base.show(
145145
},
146146
}
147147
op_data = QO.data
148-
println(io, "Quantum Object: type=", QO.type, " dims=", QO.dims, " size=", size(op_data))
148+
println(io, "\nQuantum Object: type=", QO.type, " dims=", QO.dims, " size=", size(op_data))
149149
return show(io, MIME("text/plain"), op_data)
150150
end
151151

152152
function Base.show(io::IO, QO::QuantumObject)
153153
op_data = QO.data
154154
println(
155155
io,
156-
"Quantum Object: type=",
156+
"\nQuantum Object: type=",
157157
QO.type,
158158
" dims=",
159159
QO.dims,

src/qobj/quantum_object_evo.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ function Base.show(io::IO, QO::QuantumObjectEvolution)
128128
op_data = QO.data
129129
println(
130130
io,
131-
"Quantum Object Evo.: type=",
131+
"\nQuantum Object Evo.: type=",
132132
QO.type,
133133
" dims=",
134134
QO.dims,

test/core-test/quantum_objects.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,42 +233,42 @@
233233
a_size = size(a)
234234
a_isherm = isherm(a)
235235
@test opstring ==
236-
"Quantum Object: type=Operator dims=$a_dims size=$a_size ishermitian=$a_isherm\n$datastring"
236+
"\nQuantum Object: type=Operator dims=$a_dims size=$a_size ishermitian=$a_isherm\n$datastring"
237237

238238
a = spre(a)
239239
opstring = sprint((t, s) -> show(t, "text/plain", s), a)
240240
datastring = sprint((t, s) -> show(t, "text/plain", s), a.data)
241241
a_dims = a.dims
242242
a_size = size(a)
243243
a_isherm = isherm(a)
244-
@test opstring == "Quantum Object: type=SuperOperator dims=$a_dims size=$a_size\n$datastring"
244+
@test opstring == "\nQuantum Object: type=SuperOperator dims=$a_dims size=$a_size\n$datastring"
245245

246246
opstring = sprint((t, s) -> show(t, "text/plain", s), ψ)
247247
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ.data)
248248
ψ_dims = ψ.dims
249249
ψ_size = size(ψ)
250-
@test opstring == "Quantum Object: type=Ket dims=$ψ_dims size=$ψ_size\n$datastring"
250+
@test opstring == "\nQuantum Object: type=Ket dims=$ψ_dims size=$ψ_size\n$datastring"
251251

252252
ψ = ψ'
253253
opstring = sprint((t, s) -> show(t, "text/plain", s), ψ)
254254
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ.data)
255255
ψ_dims = ψ.dims
256256
ψ_size = size(ψ)
257-
@test opstring == "Quantum Object: type=Bra dims=$ψ_dims size=$ψ_size\n$datastring"
257+
@test opstring == "\nQuantum Object: type=Bra dims=$ψ_dims size=$ψ_size\n$datastring"
258258

259259
ψ2 = Qobj(rand(ComplexF64, 4), type = OperatorKet)
260260
opstring = sprint((t, s) -> show(t, "text/plain", s), ψ2)
261261
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ2.data)
262262
ψ2_dims = ψ2.dims
263263
ψ2_size = size(ψ2)
264-
@test opstring == "Quantum Object: type=OperatorKet dims=$ψ2_dims size=$ψ2_size\n$datastring"
264+
@test opstring == "\nQuantum Object: type=OperatorKet dims=$ψ2_dims size=$ψ2_size\n$datastring"
265265

266266
ψ2 = ψ2'
267267
opstring = sprint((t, s) -> show(t, "text/plain", s), ψ2)
268268
datastring = sprint((t, s) -> show(t, "text/plain", s), ψ2.data)
269269
ψ2_dims = ψ2.dims
270270
ψ2_size = size(ψ2)
271-
@test opstring == "Quantum Object: type=OperatorBra dims=$ψ2_dims size=$ψ2_size\n$datastring"
271+
@test opstring == "\nQuantum Object: type=OperatorBra dims=$ψ2_dims size=$ψ2_size\n$datastring"
272272
end
273273

274274
@testset "matrix element" begin

test/core-test/quantum_objects_evo.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
H_isherm = isherm(H)
115115
H_isconst = isconstant(H)
116116
@test opstring ==
117-
"Quantum Object Evo.: type=Operator dims=$H_dims size=$H_size ishermitian=$H_isherm isconstant=$H_isconst\n$datastring"
117+
"\nQuantum Object Evo.: type=Operator dims=$H_dims size=$H_size ishermitian=$H_isherm isconstant=$H_isconst\n$datastring"
118118

119119
L = QobjEvo(spre(a))
120120
opstring = sprint((t, s) -> show(t, "text/plain", s), L)
@@ -124,7 +124,7 @@
124124
L_isherm = isherm(L)
125125
L_isconst = isconstant(L)
126126
@test opstring ==
127-
"Quantum Object Evo.: type=SuperOperator dims=$L_dims size=$L_size ishermitian=$L_isherm isconstant=$L_isconst\n$datastring"
127+
"\nQuantum Object Evo.: type=SuperOperator dims=$L_dims size=$L_size ishermitian=$L_isherm isconstant=$L_isconst\n$datastring"
128128
end
129129

130130
@testset "Type Inference (QobjEvo)" begin

0 commit comments

Comments
 (0)