Skip to content

Commit 34f47ad

Browse files
committed
improve codecov
1 parent a5f6819 commit 34f47ad

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

test/core-test/quantum_objects.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,15 @@
6565
end
6666

6767
@testset "Operator and SuperOperator" begin
68+
N = 10
69+
A = Qobj(rand(ComplexF64, N, N))
70+
B = Qobj(rand(ComplexF64, N, N))
71+
ρ = rand_dm(N) # random density matrix
72+
@test mat2vec(A * ρ * B) spre(A) * spost(B) * mat2vec(ρ) sprepost(A, B) * mat2vec(ρ) # we must make sure this equality holds !
73+
6874
a = sprand(ComplexF64, 100, 100, 0.1)
6975
a2 = Qobj(a)
7076
a3 = Qobj(a, type = SuperOperator)
71-
7277
@test isket(a2) == false
7378
@test isbra(a2) == false
7479
@test isoper(a2) == true

test/core-test/quantum_objects_evo.jl

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,25 +160,37 @@
160160
# @test X_warn == X3
161161
# end
162162

163-
@testset "Time Dependent Operators" begin
163+
@testset "Time Dependent Operators and SuperOperators" begin
164164
N = 10
165165
a = destroy(N)
166166
coef1(p, t) = exp(-1im * p.ω1 * t)
167167
coef2(p, t) = sin(p.ω2 * t)
168-
169-
@test_throws MethodError QobjEvo([[a, coef1], a' * a, [a', coef2]])
170-
171-
op1 = QobjEvo(((a, coef1), a' * a, (a', coef2)))
172-
op1 = QobjEvo(((a, coef1), a' * a, (a', coef2)))
173-
174-
p = (ω1 = 1, ω2 = 2)
175-
@test op1(p, 0.1) coef1(p, 0.1) * a + a' * a + coef2(p, 0.1) * a'
176-
177-
ψ = fock(N, 1)
178-
@test op1(ψ, p, 0.1) (coef1(p, 0.1) * a + a' * a + coef2(p, 0.1) * a') * ψ
179-
168+
t = rand()
169+
p = (ω1 = rand(), ω2 = rand())
170+
171+
# Operator
172+
H_td = QobjEvo(((a, coef1), a' * a, (a', coef2)))
173+
H_ti = coef1(p, t) * a + a' * a + coef2(p, t) * a'
174+
ψ = rand_ket(N)
175+
@test H_td(p, t) H_ti
176+
@test H_td(ψ, p, t) H_ti * ψ
180177
@test isconstant(a) == true
181-
@test isconstant(op1) == false
178+
@test isconstant(H_td) == false
182179
@test isconstant(Qobj(a)) == true
180+
@test isoper(H_td) == true
181+
182+
# SuperOperator
183+
c_ops = [sqrt(rand()) * a]
184+
L_td = liouvillian(H_td, c_ops)
185+
L_td2 = -1im * spre(H_td) + 1im * spost(H_td) + lindblad_dissipator(c_ops[1])
186+
ρvec = mat2vec(rand_dm(N))
187+
@test L_td(p, t) L_td2(p, t)
188+
@test L_td(ρvec, p, t) L_td2(ρvec, p, t)
189+
@test isconstant(L_td) == false
190+
@test issuper(L_td) == true
191+
192+
@test_throws MethodError QobjEvo([[a, coef1], a' * a, [a', coef2]])
193+
@test_throws ArgumentError H_td(ρvec, p, t)
194+
@test_throws ArgumentError L_td(ψ, p, t)
183195
end
184196
end

0 commit comments

Comments
 (0)