Skip to content

Commit 4d605b9

Browse files
committed
Use stable RNG for tests
1 parent 9c25656 commit 4d605b9

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ SciMLOperators = "0.3"
7575
SimpleNonlinearSolve = "0.1.23"
7676
SparseArrays = "<0.0.1, 1"
7777
SparseDiffTools = "2.14"
78+
StableRNGs = "1"
7879
StaticArrays = "1"
7980
Symbolics = "5"
8081
Test = "1"
@@ -98,11 +99,12 @@ NonlinearProblemLibrary = "b7050fa9-e91f-4b37-bcee-a89a063da141"
9899
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
99100
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
100101
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
102+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
101103
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
102104
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
103105
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
104106
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
105107
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
106108

107109
[targets]
108-
test = ["Aqua", "Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt", "NaNMath", "BandedMatrices", "DiffEqBase"]
110+
test = ["Aqua", "Enzyme", "BenchmarkTools", "SafeTestsets", "Pkg", "Test", "ForwardDiff", "StaticArrays", "Symbolics", "LinearSolve", "Random", "LinearAlgebra", "Zygote", "SparseDiffTools", "NonlinearProblemLibrary", "LeastSquaresOptim", "FastLevenbergMarquardt", "NaNMath", "BandedMatrices", "DiffEqBase", "StableRNGs"]

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ NonlinearSolve = "1, 2"
3030
NonlinearSolveMINPACK = "0.1"
3131
SciMLBase = "2.4"
3232
SciMLNLSolve = "0.1"
33-
SimpleNonlinearSolve = "0.1.5"
33+
SimpleNonlinearSolve = "0.1.5, 1"
3434
StaticArrays = "1"
3535
SteadyStateDiffEq = "1.10, 2"
3636
Sundials = "4.11"

test/nonlinear_least_squares.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using NonlinearSolve, LinearSolve, LinearAlgebra, Test, Random, ForwardDiff, Zygote
1+
using NonlinearSolve,
2+
LinearSolve, LinearAlgebra, Test, StableRNGs, Random, ForwardDiff, Zygote
23
import FastLevenbergMarquardt, LeastSquaresOptim
34

45
true_function(x, θ) = @. θ[1] * exp(θ[2] * x) * cos(θ[3] * x + θ[4])
@@ -21,7 +22,7 @@ function loss_function(resid, θ, p)
2122
return resid
2223
end
2324

24-
θ_init = θ_true .+ randn!(similar(θ_true)) * 0.1
25+
θ_init = θ_true .+ randn!(StableRNG(0), similar(θ_true)) * 0.1
2526
prob_oop = NonlinearLeastSquaresProblem{false}(loss_function, θ_init, x)
2627
prob_iip = NonlinearLeastSquaresProblem(NonlinearFunction(loss_function;
2728
resid_prototype = zero(y_target)), θ_init, x)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ end
1414
@time begin
1515
if GROUP == "All" || GROUP == "Core"
1616
@time @safetestset "Quality Assurance" include("qa.jl")
17+
@time @safetestset "Nonlinear Least Squares" include("nonlinear_least_squares.jl")
1718
@time @safetestset "Basic Tests + Some AD" include("basictests.jl")
1819
@time @safetestset "Sparsity Tests" include("sparse.jl")
1920
@time @safetestset "Polyalgs" include("polyalgs.jl")
2021
@time @safetestset "Matrix Resizing" include("matrix_resizing.jl")
21-
@time @safetestset "Nonlinear Least Squares" include("nonlinear_least_squares.jl")
2222
@time @safetestset "Infeasible Problems" include("infeasible.jl")
2323
end
2424

0 commit comments

Comments
 (0)