Skip to content

Commit

Permalink
Add explicit test dependency on FiniteDiff
Browse files Browse the repository at this point in the history
It's generally better practice to do this since it means that stuff
doesn't break if NLSolversBase removes its dependency on FiniteDiff. In
this case it should also fix the failure on Julia 1.1.
  • Loading branch information
ararslan committed Jun 26, 2023
1 parent 8e4e68c commit 179315e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ StatsAPI = "1"
julia = "1.1"

[extras]
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "StableRNGs"]
test = ["Test", "StableRNGs", "FiniteDiff"]
6 changes: 3 additions & 3 deletions test/levenberg_marquardt.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LsqFit, Test, StableRNGs, NLSolversBase
using LsqFit, Test, StableRNGs, NLSolversBase, FiniteDiff
@testset "optimization" begin
function f_lm(x)
[x[1], 2.0 - x[2]]
Expand Down Expand Up @@ -62,7 +62,7 @@ using LsqFit, Test, StableRNGs, NLSolversBase
ydata = model(xdata, [1.0 2.0]) + 0.01 * randn(rng, _nobs)

f_lsq = p -> model(xdata, p) - ydata
g_lsq = p -> NLSolversBase.FiniteDiff.finite_difference_jacobian(f_lsq, p)
g_lsq = p -> FiniteDiff.finite_difference_jacobian(f_lsq, p)

R3 = OnceDifferentiable(f_lsq, g_lsq, zeros(2), zeros(_nobs); inplace = false)
results = LsqFit.levenberg_marquardt(R3, [0.5, 0.5])
Expand All @@ -81,7 +81,7 @@ using LsqFit, Test, StableRNGs, NLSolversBase
ydata = model(xdata, p_generate) + 0.1 * randn(rng, length(xdata))

f_lsq = p -> model(xdata, p) - ydata
g_lsq = p -> NLSolversBase.FiniteDiff.finite_difference_jacobian(f_lsq, p)
g_lsq = p -> FiniteDiff.finite_difference_jacobian(f_lsq, p)

R4 = OnceDifferentiable(
f_lsq,
Expand Down

0 comments on commit 179315e

Please sign in to comment.