Skip to content

Commit

Permalink
Changing example used in test. (#469)
Browse files Browse the repository at this point in the history
* changing example used in test

* cleaning up old lines of code

* updating tests

* fixing test
  • Loading branch information
weinbe58 authored Nov 22, 2022
1 parent 9334b4e commit 390efbe
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions lib/BloqadeKrylov/test/forwarddiff.jl
Original file line number Diff line number Diff line change
@@ -2,23 +2,38 @@ using Test
using ForwardDiff
using BloqadeExpr
using YaoArrayRegister
using BloqadeWaveforms
using BloqadeKrylov
using BloqadeLattices


ForwardDiff.derivative(2.0) do x
T = 0.1
dT = T / 10
reg = zero_state(Complex{typeof(x)}, 5)
atoms = [(i,) for i in 1:5]
h = rydberg_h(atoms; Ω = sin, Δ = x)
prob = KrylovEvolution(reg, 0:1e-3:0.1, h)
atoms = [(6.7 * i,) for i in 1:5]
h = rydberg_h(atoms; Ω = x, Δ = t -> -5 * cos* t / T))
prob = KrylovEvolution(reg, 0:dT:T, h)
emulate!(prob)
return abs2(statevec(reg)[1])
end

using ExponentialUtilities

ForwardDiff.derivative(2.0) do x
st = rand(2)
st = BloqadeKrylov.expmv(2.0, fill(x, (2, 2)), st)
return sum(st)

@testset "ForwardDiff broken" begin
# # failing function, doesn't seem to
# ForwardDiff.derivative(2.0) do x
# reg = zero_state(Complex{typeof(x)}, 5)
# atoms = [(6*i,) for i in 1:5]
# h = rydberg_h(atoms; Ω = sin ,Δ = x)
# prob = KrylovEvolution(reg, 0:1e-3:0.02, h)
# emulate!(prob)
# return abs2(statevec(reg)[1])
# end

@test isnan(ForwardDiff.derivative(2.0) do x
h = fill(zero(typeof(x)), (2, 2))
F = ExponentialUtilities.exponential!(im * h, ExpMethodGeneric())
return sum(F)
end)

end

2 comments on commit 390efbe

@Roger-luo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Released via Ion

@JuliaRegistrator register branch=master subdir=lib/BloqadeExpr

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/72674

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a BloqadeExpr-v0.1.9 -m "<description of version>" 390efbe4e1c9adceaa0939c2cf62313278813b7f
git push origin BloqadeExpr-v0.1.9

Please sign in to comment.