Skip to content

Commit

Permalink
Don't demand identity in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
amilsted authored Jul 26, 2023
1 parent da721c5 commit 95a1743
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/test_time_dependent_operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ using LinearAlgebra, Random

# function-call interface
@test QOB.static_operator(o_t(t)).factors == [1.0im, t*3.0 + 0.0im]
@test all(QOB.static_operator(o_t(t)).operators .=== (a, n))
@test all(QOB.static_operator(o_t(t)).operators .== (a, n))

o_t_tup = TimeDependentSum(Tuple, o_t)
@test QOB.static_operator(o_t_tup(t)).factors == [1.0im, t*3.0 + 0.0im]
@test all(QOB.static_operator(o_t_tup(t)).operators .=== (a, n))
@test all(QOB.static_operator(o_t_tup(t)).operators .== (a, n))
@test (@allocated set_time!(o_t_tup, t)) == 0

o_t2 = TimeDependentSum(f1=>a, f2=>n)
Expand All @@ -125,44 +125,44 @@ using LinearAlgebra, Random
o_res = o_t(0.0) + o2_t(0.0)
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == ComplexF64[1.0im, t*3.0, cos(t), t/3.0]
@test all(QOB.suboperators(o_res) .=== (a, n, b, n))
@test all(QOB.suboperators(o_res) .== (a, n, b, n))

o_res = o_t - o2_t
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == ComplexF64[1.0im, t*3.0, -cos(t), -t/3.0]
@test all(QOB.suboperators(o_res) .=== (a, n, b, n))
@test all(QOB.suboperators(o_res) .== (a, n, b, n))

o_res = -o_t
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == [-1.0im, -t*3.0]
@test all(QOB.suboperators(o_res) .=== (a, n))
@test all(QOB.suboperators(o_res) .== (a, n))

o_res = a + o2_t
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == ComplexF64[1.0, cos(t), t/3.0]
@test all(QOB.suboperators(o_res) .=== (a, b, n))
@test all(QOB.suboperators(o_res) .== (a, b, n))

o_res = a - o2_t
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == ComplexF64[1.0, -cos(t), -t/3.0]
@test all(QOB.suboperators(o_res) .=== (a, b, n))
@test all(QOB.suboperators(o_res) .== (a, b, n))

o_res = LazySum(a, n) + o2_t
@test isa(o_res, TimeDependentSum)
@test QOB.eval_coefficients(o_res, t) == ComplexF64[1.0, 1.0, cos(t), t/3.0]
@test all(QOB.suboperators(o_res) .=== (a, n, b, n))
@test all(QOB.suboperators(o_res) .== (a, n, b, n))

fac = randn(ComplexF64)
o_res = fac * o2_t
@test isa(o_res, TimeDependentSum)
@test [QOB.eval_coefficients(o_res, t)...] [fac*cos(t), fac*t/3.0] rtol=1e-10
@test all(QOB.suboperators(o_res) .=== (b, n))
@test all(QOB.suboperators(o_res) .== (b, n))

fac = randn(ComplexF64)
o_res = o2_t / fac
@test isa(o_res, TimeDependentSum)
@test [QOB.eval_coefficients(o_res, t)...] [cos(t)/fac, t/3.0/fac] rtol=1e-10
@test all(QOB.suboperators(o_res) .=== (b, n))
@test all(QOB.suboperators(o_res) .== (b, n))

o_res = o_t * o2_t
@test isa(o_res, TimeDependentSum)
Expand Down

0 comments on commit 95a1743

Please sign in to comment.