Skip to content

Commit

Permalink
more grid points on findiff tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thore Kockerols authored and Thore Kockerols committed Nov 29, 2024
1 parent 6f10676 commit 8a0a4fc
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand All @@ -229,7 +229,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1, max_range = 1e-4),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1, max_range = 1e-4),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand All @@ -249,7 +249,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand All @@ -269,7 +269,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand All @@ -290,7 +290,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand All @@ -312,7 +312,7 @@ if test_set == "plots"

back_grad = Zygote.gradient(x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(3,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)
fin_grad = FiniteDifferences.grad(FiniteDifferences.central_fdm(4,1),x-> get_loglikelihood(m, simulated_data(observables, :, :simulate), x), m.parameter_values)

@test isapprox(back_grad[1], fin_grad[1], rtol = 1e-6)
end
Expand Down

0 comments on commit 8a0a4fc

Please sign in to comment.