Skip to content

Commit 7cefbbb

Browse files
SebastianM-Cclaude
andcommitted
style: apply runic formatting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6c7ccc1 commit 7cefbbb

7 files changed

Lines changed: 18 additions & 17 deletions

File tree

lib/OptimizationBase/src/utils.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function apply_sense(f::OptimizationFunction{iip}, sense) where {iip}
1919
elseif iip
2020
function (G, u, p)
2121
f.grad(G, u, p)
22-
G .*= -one(eltype(G))
22+
return G .*= -one(eltype(G))
2323
end
2424
else
2525
(u, p) -> -f.grad(u, p)
@@ -45,7 +45,7 @@ function apply_sense(f::OptimizationFunction{iip}, sense) where {iip}
4545
elseif iip
4646
function (H, u, p)
4747
f.hess(H, u, p)
48-
H .*= -one(eltype(H))
48+
return H .*= -one(eltype(H))
4949
end
5050
else
5151
(u, p) -> -f.hess(u, p)
@@ -72,7 +72,7 @@ function apply_sense(f::OptimizationFunction{iip}, sense) where {iip}
7272
elseif iip
7373
function (Hv, u, v, p)
7474
f.hv(Hv, u, v, p)
75-
Hv .*= -one(eltype(Hv))
75+
return Hv .*= -one(eltype(Hv))
7676
end
7777
else
7878
(u, v, p) -> -f.hv(u, v, p)

lib/OptimizationMadNLP/src/OptimizationMadNLP.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function SciMLBase.__solve(cache::OptimizationCache{O}) where {O <: MadNLPOptimi
206206
results = MadNLP.solve!(solver)
207207

208208
if cache.progress
209-
Base.@logmsg Base.LogLevel(-1) progress="done" _id = :OptimizationMadNLP
209+
Base.@logmsg Base.LogLevel(-1) progress = "done" _id = :OptimizationMadNLP
210210
end
211211

212212
stats = OptimizationBase.OptimizationStats(;

lib/OptimizationMadNLP/test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,11 +649,11 @@ end
649649
cb(opt_state, loss) = (@info "obj=$loss"; opt_state.original.cnt.k >= 3)
650650
prob = OptimizationProblem(optfunc, x0, _p)
651651

652-
sol = @test_logs (:info, "obj=1.0") match_mode=:any solve(prob, MadNLPOptimizer(); callback = cb)
652+
sol = @test_logs (:info, "obj=1.0") match_mode = :any solve(prob, MadNLPOptimizer(); callback = cb)
653653
@test sol.stats.iterations == 3
654654

655655
logs, _ = Test.collect_test_logs(min_level = Base.LogLevel(-1)) do
656-
solve(prob, MadNLPOptimizer(), progress = true, maxiters=10)
656+
solve(prob, MadNLPOptimizer(), progress = true, maxiters = 10)
657657
end
658658
@test !isempty(logs)
659659
m = first(logs)

lib/OptimizationOptimJL/test/runtests.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ end
3939

4040
prob_min = OptimizationProblem(optf, x0, nothing; lb = lb, ub = ub)
4141
sol_min = solve(prob_min, LBFGS(); x_abstol = 0.1)
42-
@test isapprox(sol_min.u, [0.0, 0.0]; atol = 1e-2)
43-
@test isapprox(sol_min.objective, 0.0; atol = 1e-2)
42+
@test isapprox(sol_min.u, [0.0, 0.0]; atol = 1.0e-2)
43+
@test isapprox(sol_min.objective, 0.0; atol = 1.0e-2)
4444

4545
prob_max = OptimizationProblem(
4646
optf, x0, nothing; lb = lb, ub = ub, sense = OptimizationBase.MaxSense
4747
)
4848
sol_max = solve(prob_max, LBFGS(); x_abstol = 0.1)
49-
@test isapprox(sol_max.u, [10.0, 10.0]; atol = 1e-2)
50-
@test isapprox(sol_max.objective, 20.0; atol = 1e-2)
49+
@test isapprox(sol_max.u, [10.0, 10.0]; atol = 1.0e-2)
50+
@test isapprox(sol_max.objective, 20.0; atol = 1.0e-2)
5151
end
5252

5353
@testset "MaxSense with IPNewton" begin
@@ -61,8 +61,8 @@ end
6161
optf, x0, nothing; lb = lb, ub = ub, sense = OptimizationBase.MaxSense
6262
)
6363
sol_max = solve(prob_max, Optim.IPNewton(); x_abstol = 0.1)
64-
@test isapprox(sol_max.u, [10.0, 10.0]; atol = 1e-2)
65-
@test isapprox(sol_max.objective, 20.0; atol = 1e-2)
64+
@test isapprox(sol_max.u, [10.0, 10.0]; atol = 1.0e-2)
65+
@test isapprox(sol_max.objective, 20.0; atol = 1.0e-2)
6666
end
6767

6868
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2

lib/OptimizationOptimisers/test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ using Lux, MLUtils, Random, ComponentArrays, Printf, MLDataDevices
1818
prob_max = OptimizationProblem(optf, x0, nothing; sense = OptimizationBase.MaxSense)
1919
cache = OptimizationBase.OptimizationCache(prob_max, Optimisers.Adam())
2020
G = zeros(2)
21-
@test isapprox(cache.f.f(x0, nothing), -10.0; atol = 1e-12)
21+
@test isapprox(cache.f.f(x0, nothing), -10.0; atol = 1.0e-12)
2222
cache.f.grad(G, x0, nothing)
23-
@test isapprox(G[1], -1.0; atol = 1e-12)
24-
@test isapprox(G[2], -1.0; atol = 1e-12)
23+
@test isapprox(G[1], -1.0; atol = 1.0e-12)
24+
@test isapprox(G[2], -1.0; atol = 1.0e-12)
2525
end
2626

2727
rosenbrock(x, p) = (p[1] - x[1])^2 + p[2] * (x[2] - x[1]^2)^2

lib/SimpleOptimization/src/SimpleOptimization.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function SciMLBase.__solve(cache::OptimizationCache{O}) where {O <: SimpleGradie
252252

253253
abstol = cache.solver_args.abstol
254254
if abstol === nothing
255-
abstol = 1e-8
255+
abstol = 1.0e-8
256256
end
257257

258258
f = Base.Fix2(cache.f.f, cache.p)

test/sense_tests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ const P0 = nothing
6060
H[2, 2] = 0.0
6161
end
6262

63-
optf = OptimizationFunction(obj;
63+
optf = OptimizationFunction(
64+
obj;
6465
grad = grad!, fg = fg!, hess = hess!,
6566
fgh = fgh!, hv = hv!, lag_h = lag_h!
6667
)

0 commit comments

Comments
 (0)