Skip to content

Commit 28302c8

Browse files
committed
add tests
1 parent 075bc0f commit 28302c8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/OptimizationOptimisers/test/runtests.jl

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ using Lux, MLUtils, Random, ComponentArrays, Printf, MLDataDevices
3232
@test sol.stats.fevals == 1000
3333
@test sol.stats.gevals == 1000
3434

35+
@testset "epochs & maxiters" begin
36+
optprob = SciMLBase.OptimizationFunction(
37+
(u, data) -> sum(u) + sum(data), Optimization.AutoZygote())
38+
prob = SciMLBase.OptimizationProblem(optprob, ones(2), ones(2))
39+
@test_throws ArgumentError solve(prob, Optimisers.Adam())
40+
@test_throws ArgumentError solve(
41+
prob, Optimisers.Adam(), epochs = 2, maxiters = 2)
42+
@test solve(prob, Optimisers.Adam(), epochs = 2)
43+
@test solve(prob, Optimisers.Adam(), maxiters = 2)
44+
@test solve(prob, Optimisers.Adam(), epochs = 2, maxiters = 4)
45+
@test_throws AssertionError solve(prob, Optimisers.Adam(), maxiters = 3)
46+
end
47+
3548
@testset "cache" begin
3649
objective(x, p) = (p[1] - x[1])^2
3750
x0 = zeros(1)

0 commit comments

Comments
 (0)