Skip to content

Commit

Permalink
Set low tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion committed Jul 29, 2019
1 parent bc84520 commit 849214f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/differentiation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ h(p, t) = [p[4]]
function test(p)
prob = DDEProblem(f, [p[5]], h, eltype(p).((0.0, 20.0)), copy(p);
constant_lags = [p[2]])
sol = solve(prob, MethodOfSteps(Tsit5()))
sol = solve(prob, MethodOfSteps(Tsit5()); abstol = 1e-14, reltol = 1e-14)
diff = @. sol[1, :] - 10 * exp(-sol.t)
dot(diff, diff)
end

p = [1.0, 1.0, 1.0, 0.0, 1.0]
findiff = Calculus.finite_difference(test, p)
fordiff = ForwardDiff.gradient(test, p)
fordiff = @test_logs (:warn, r"^dt <= dtmin") ForwardDiff.gradient(test, p)

@test_broken findiff fordiff
end
Expand All @@ -29,12 +29,12 @@ end
function test(p)
prob = DDEProblem(f, [p[5]], h, eltype(p).((0.0, 20.0)), copy(p);
constant_lags = [p[2]])
solve(prob, MethodOfSteps(Tsit5())).u[end]
solve(prob, MethodOfSteps(Tsit5()); abstol = 1e-14, reltol = 1e-14).u[end]
end

p = [1.0, 1.0, 1.0, 0.0, 1.0]
findiff = Calculus.finite_difference_jacobian(test, p)
fordiff = ForwardDiff.jacobian(test, p)
fordiff = @test_logs (:warn, r"^dt <= dtmin") ForwardDiff.jacobian(test, p)

@test_broken findiff fordiff
end
Expand All @@ -43,14 +43,14 @@ end
function test(p)
prob = DDEProblem(f, [p[5]], h, eltype(p).((0.0, 20.0)), copy(p);
constant_lags = [p[2]])
sol = solve(prob, MethodOfSteps(Tsit5()))
sol = solve(prob, MethodOfSteps(Tsit5()); abstol = 1e-14, reltol = 1e-14)
diff = @. sol[1, :] - 10 * exp(-sol.t)
dot(diff, diff)
end

p = [1.0, 1.0, 1.0, 0.0, 1.0]
findiff = Calculus.finite_difference_hessian(test, p)
fordiff = ForwardDiff.hessian(test, p)
fordiff = @test_logs (:warn, r"^dt <= dtmin") ForwardDiff.hessian(test, p)

@test_broken findiff fordiff
end

0 comments on commit 849214f

Please sign in to comment.