Skip to content

Commit 692b660

Browse files
committed
add messages to the error types in tests
1 parent 243f848 commit 692b660

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

lib/OptimizationOptimisers/test/runtests.jl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ using Lux, MLUtils, Random, ComponentArrays, Printf, MLDataDevices
3636
optprob = SciMLBase.OptimizationFunction(
3737
(u, data) -> sum(u) + sum(data), Optimization.AutoZygote())
3838
prob = SciMLBase.OptimizationProblem(optprob, ones(2), ones(2))
39-
@test_throws ArgumentError solve(prob, Optimisers.Adam())
40-
@test_throws ArgumentError solve(
39+
@test_throws ArgumentError("The number of iterations must be specified with either the epochs or maxiters kwarg. Where maxiters = epochs * length(data).") solve(
40+
prob, Optimisers.Adam())
41+
@test_throws ArgumentError("Both maxiters and epochs were passed but maxiters != epochs * length(data).") solve(
4142
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)
43+
sol = solve(prob, Optimisers.Adam(), epochs = 2)
44+
@test sol.stats.iterations == 4
45+
sol = solve(prob, Optimisers.Adam(), maxiters = 2)
46+
@test sol.stats.iterations == 2
47+
sol = solve(prob, Optimisers.Adam(), epochs = 2, maxiters = 4)
48+
@test sol.stats.iterations == 4
49+
@test_throws AssertionError("The number of iterations must be specified with either the epochs or maxiters kwarg. Where maxiters = epochs * length(data).") solve(
50+
prob, Optimisers.Adam(), maxiters = 3)
4651
end
4752

4853
@testset "cache" begin

0 commit comments

Comments
 (0)