Skip to content

Commit 5926cd8

Browse files
committed
fix errors
1 parent 692b660 commit 5926cd8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: lib/OptimizationOptimisers/src/OptimizationOptimisers.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ function SciMLBase.__solve(cache::OptimizationCache{
7171
maxiters = Optimization._check_and_convert_maxiters(maxiters)
7272

7373
# At this point, both of them should be fine; but, let's assert it.
74-
@assert (isnothing(epochs)||isnothing(maxiters) || (maxiters != epochs * length(data))) "The number of iterations must be specified with either the epochs or maxiters kwarg. Where maxiters = epochs * length(data)."
74+
@assert (!isnothing(epochs)&&!isnothing(maxiters) &&
75+
(maxiters == epochs * length(data))) "The number of iterations must be specified with either the epochs or maxiters kwarg. Where maxiters = epochs * length(data)."
7576

7677
opt = cache.opt
7778
θ = copy(cache.u0)

Diff for: lib/OptimizationOptimisers/test/runtests.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ using Lux, MLUtils, Random, ComponentArrays, Printf, MLDataDevices
3535
@testset "epochs & maxiters" begin
3636
optprob = SciMLBase.OptimizationFunction(
3737
(u, data) -> sum(u) + sum(data), Optimization.AutoZygote())
38-
prob = SciMLBase.OptimizationProblem(optprob, ones(2), ones(2))
38+
prob = SciMLBase.OptimizationProblem(
39+
optprob, ones(2), MLUtils.DataLoader(ones(2, 2)))
3940
@test_throws ArgumentError("The number of iterations must be specified with either the epochs or maxiters kwarg. Where maxiters = epochs * length(data).") solve(
4041
prob, Optimisers.Adam())
4142
@test_throws ArgumentError("Both maxiters and epochs were passed but maxiters != epochs * length(data).") solve(

0 commit comments

Comments
 (0)