Skip to content

Commit

Permalink
Use NaNMath in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Oct 24, 2023
1 parent 8e8fc82 commit 4e78736
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
LeastSquaresOptim = "0fc2ff8b-aaa3-5acd-a817-1944a5e08891"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -76,4 +77,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt"]
test = ["Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt", "NaNMath"]
7 changes: 4 additions & 3 deletions test/polyalgs.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using NonlinearSolve, Test
using NonlinearSolve, Test, NaNMath

f(u, p) = u .* u .- 2
u0 = [1.0, 1.0]
Expand Down Expand Up @@ -38,7 +38,8 @@ sol = solve(prob)
@test SciMLBase.successful_retcode(sol)

# https://github.com/SciML/NonlinearSolve.jl/issues/187
ff(u, p) = 0.5 / 1.5 * log.(u ./ (1.0 .- u)) .- 2.0 * u .+ 1.0
# If we use a General Nonlinear Solver the solution might go out of the domain!
ff(u, p) = 0.5 / 1.5 * NaNMath.log.(u ./ (1.0 .- u)) .- 2.0 * u .+ 1.0

uspan = (0.02, 0.1)
prob = IntervalNonlinearProblem(ff, uspan)
Expand All @@ -48,5 +49,5 @@ sol = solve(prob)
u0 = 0.06
p = 2.0
prob = NonlinearProblem(ff, u0, p)
solver = solve(prob)
sol = solve(prob)
@test SciMLBase.successful_retcode(sol)

0 comments on commit 4e78736

Please sign in to comment.