Skip to content

Commit 1f479c7

Browse files
author
SciML Bot
committed
Apply JuliaFormatter to fix code formatting
- Applied JuliaFormatter with SciML style guide - Formatted 29 files 🤖 Generated by OrgMaintenanceScripts.jl
1 parent e9e4166 commit 1f479c7

File tree

29 files changed

+220
-169
lines changed

29 files changed

+220
-169
lines changed

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ makedocs(;
5151
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156",
5252
"https://github.com/devernay/cminpack/blob/d1f5f5a273862ca1bbcf58394e4ac060d9e22c76/hybrd.c",
5353
"https://github.com/devernay/cminpack/blob/d1f5f5a273862ca1bbcf58394e4ac060d9e22c76/hybrj.c",
54-
"https://github.com/devernay/cminpack/blob/d1f5f5a273862ca1bbcf58394e4ac060d9e22c76/lmder.c",
54+
"https://github.com/devernay/cminpack/blob/d1f5f5a273862ca1bbcf58394e4ac060d9e22c76/lmder.c"
5555
],
5656
checkdocs = :exports,
5757
warnonly = [:missing_docs],

docs/src/api/scipy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ Note that using this package requires Python and SciPy to be available via Pytho
1919
NonlinearSolveSciPy.SciPyLeastSquares
2020
NonlinearSolveSciPy.SciPyRoot
2121
NonlinearSolveSciPy.SciPyRootScalar
22-
```
22+
```

docs/src/basics/diagnostics_api.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ cache.timer
7070
Let's try for some other solver:
7171

7272
```@example diagnostics_example
73-
cache = NLS.init(prob, NLS.DFSane(); show_trace = Val(true), trace_level = NLS.TraceMinimal(50));
73+
cache = NLS.init(
74+
prob, NLS.DFSane(); show_trace = Val(true), trace_level = NLS.TraceMinimal(50));
7475
NLS.solve!(cache)
7576
cache.timer
7677
```

docs/src/tutorials/large_systems.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ nothing # hide
144144
import SparseConnectivityTracer
145145
146146
prob_brusselator_2d_autosparse = NLS.NonlinearProblem(
147-
NLS.NonlinearFunction(brusselator_2d_loop; sparsity = SparseConnectivityTracer.TracerSparsityDetector()),
147+
NLS.NonlinearFunction(
148+
brusselator_2d_loop; sparsity = SparseConnectivityTracer.TracerSparsityDetector()),
148149
u0, p; abstol = 1e-10, reltol = 1e-10
149150
)
150151
@@ -185,7 +186,8 @@ import ADTypes
185186
186187
f! = (du, u) -> brusselator_2d_loop(du, u, p)
187188
du0 = similar(u0)
188-
jac_sparsity = ADTypes.jacobian_sparsity(f!, du0, u0, SparseConnectivityTracer.TracerSparsityDetector())
189+
jac_sparsity = ADTypes.jacobian_sparsity(
190+
f!, du0, u0, SparseConnectivityTracer.TracerSparsityDetector())
189191
```
190192

191193
Notice that Julia gives a nice print out of the sparsity pattern. That's neat, and would be
@@ -206,7 +208,8 @@ Now let's see how the version with sparsity compares to the version without:
206208
```@example ill_conditioned_nlprob
207209
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson());
208210
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson());
209-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse, NLS.NewtonRaphson(linsolve = LS.KLUFactorization()));
211+
BenchmarkTools.@btime NLS.solve(
212+
prob_brusselator_2d_sparse, NLS.NewtonRaphson(linsolve = LS.KLUFactorization()));
210213
nothing # hide
211214
```
212215

@@ -222,7 +225,8 @@ Krylov method. To swap the linear solver out, we use the `linsolve` command and
222225
GMRES linear solver.
223226

224227
```@example ill_conditioned_nlprob
225-
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d, NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES()));
228+
BenchmarkTools.@btime NLS.solve(
229+
prob_brusselator_2d, NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES()));
226230
nothing # hide
227231
```
228232

@@ -254,7 +258,8 @@ import IncompleteLU
254258
incompletelu(W, p = nothing) = IncompleteLU.ilu(W, τ = 50.0), LinearAlgebra.I
255259

256260
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse,
257-
NLS.NewtonRaphson(linsolve = LS.KrylovJL_GMRES(precs = incompletelu), concrete_jac = true)
261+
NLS.NewtonRaphson(
262+
linsolve = LS.KrylovJL_GMRES(precs = incompletelu), concrete_jac = true)
258263
);
259264
nothing # hide
260265
```
@@ -279,7 +284,9 @@ which is more automatic. The setup is very similar to before:
279284
import AlgebraicMultigrid
280285
281286
function algebraicmultigrid(W, p = nothing)
282-
return AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I
287+
return AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.ruge_stuben(convert(
288+
AbstractMatrix, W))),
289+
LinearAlgebra.I
283290
end
284291
285292
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse,
@@ -322,11 +329,13 @@ import DifferentiationInterface
322329
import SparseConnectivityTracer
323330
324331
prob_brusselator_2d_exact_tracer = NLS.NonlinearProblem(
325-
NLS.NonlinearFunction(brusselator_2d_loop; sparsity = SparseConnectivityTracer.TracerSparsityDetector()),
332+
NLS.NonlinearFunction(
333+
brusselator_2d_loop; sparsity = SparseConnectivityTracer.TracerSparsityDetector()),
326334
u0, p; abstol = 1e-10, reltol = 1e-10)
327335
prob_brusselator_2d_approx_di = NLS.NonlinearProblem(
328336
NLS.NonlinearFunction(brusselator_2d_loop;
329-
sparsity = DifferentiationInterface.DenseSparsityDetector(ADTypes.AutoForwardDiff(); atol = 1e-4)),
337+
sparsity = DifferentiationInterface.DenseSparsityDetector(
338+
ADTypes.AutoForwardDiff(); atol = 1e-4)),
330339
u0, p; abstol = 1e-10, reltol = 1e-10)
331340
332341
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_exact_tracer, NLS.NewtonRaphson());

docs/src/tutorials/nonlinear_solve_gpus.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ using the first form.
3131
In this tutorial we will highlight both use cases in separate parts.
3232

3333
!!! note
34-
34+
3535
If you're looking for GPU-accelerated neural networks inside of nonlinear solvers,
3636
check out [DeepEquilibriumNetworks.jl](https://docs.sciml.ai/DeepEquilibriumNetworks/stable/).
3737

@@ -59,7 +59,7 @@ f(u, p) = u .* u .- p
5959
u0 = CUDA.cu(ones(1000))
6060
p = CUDA.cu(collect(1:1000))
6161
prob = NLS.NonlinearProblem(f, u0, p)
62-
sol = NLS.solve(prob, NLS.NewtonRaphson(), abstol=1f-4)
62+
sol = NLS.solve(prob, NLS.NewtonRaphson(), abstol = 1.0f-4)
6363
```
6464

6565
Notice a few things here. One, nothing is different except the input array types. But
@@ -95,7 +95,8 @@ import AMDGPU # For if you have an AMD GPU
9595
import Metal # For if you have a Mac M-series device and want to use the built-in GPU
9696
import OneAPI # For if you have an Intel GPU
9797

98-
@KernelAbstractions.kernel function parallel_nonlinearsolve_kernel!(result, @Const(prob), @Const(alg))
98+
KernelAbstractions.@kernel function parallel_nonlinearsolve_kernel!(
99+
result, @Const(prob), @Const(alg))
99100
i = @index(Global)
100101
prob_i = SciMLBase.remake(prob; p = prob.p[i])
101102
sol = NLS.solve(prob_i, alg)
@@ -109,7 +110,7 @@ is saying, "for the ith call, get the i'th parameter set and solve with these pa
109110
The ith result is then this solution".
110111

111112
!!! note
112-
113+
113114
Because kernel code needs to be able to be compiled to a GPU kernel, it has very strict
114115
specifications of what's allowed because GPU cores are not as flexible as CPU cores.
115116
In general, this means that you need to avoid any runtime operations in kernel code,
@@ -140,16 +141,16 @@ Now let's build a nonlinear system to test it on.
140141
out2 = sqrt(p[2]) * (x[3] - x[4])
141142
out3 = (x[2] - p[3] * x[3])^2
142143
out4 = sqrt(p[4]) * (x[1] - x[4]) * (x[1] - x[4])
143-
StaticArrays.SA[out1,out2,out3,out4]
144+
StaticArrays.SA[out1, out2, out3, out4]
144145
end
145146

146147
p = StaticArrays.@SVector [StaticArrays.@SVector(rand(Float32, 4)) for _ in 1:1024]
147-
u0 = StaticArrays.SA[1f0, 2f0, 3f0, 4f0]
148+
u0 = StaticArrays.SA[1.0f0, 2.0f0, 3.0f0, 4.0f0]
148149
prob = SciMLBase.ImmutableNonlinearProblem{false}(p2_f, u0, p)
149150
```
150151

151152
!!! note
152-
153+
153154
Because the custom kernel is going to need to embed the the code for our nonlinear
154155
problem into the kernel, it also must be written to be GPU compatible.
155156
In general, this means that you need to avoid any runtime operations in kernel code,
@@ -176,4 +177,5 @@ vectorized_solve(prob, NLS.SimpleNewtonRaphson(); backend = Metal.MetalBackend()
176177
```
177178

178179
!!! warn
180+
179181
The GPU-based calls will only work on your machine if you have a compatible GPU!

docs/src/tutorials/optimizing_parameterized_ode.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ end
4747
4848
p_init = zeros(4)
4949
50-
nlls_prob = NLS.NonlinearLeastSquaresProblem(loss_function, p_init, vec(reduce(hcat, sol.u)))
50+
nlls_prob = NLS.NonlinearLeastSquaresProblem(
51+
loss_function, p_init, vec(reduce(hcat, sol.u)))
5152
```
5253

5354
Now, we can use any NLLS solver to solve this problem.
5455

5556
```@example parameterized_ode
56-
res = NLS.solve(nlls_prob, NLS.LevenbergMarquardt(); maxiters = 1000, show_trace = Val(true),
57+
res = NLS.solve(
58+
nlls_prob, NLS.LevenbergMarquardt(); maxiters = 1000, show_trace = Val(true),
5759
trace_level = NLS.TraceWithJacobianConditionNumber(25))
5860
nothing # hide
5961
```

docs/src/tutorials/snes_ex2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ details.
3838

3939
```@example snes_ex2
4040
nlfunc_dense = NLS.NonlinearFunction(form_residual!)
41-
nlfunc_sparse = NLS.NonlinearFunction(form_residual!; sparsity = SparseConnectivityTracer.TracerSparsityDetector())
41+
nlfunc_sparse = NLS.NonlinearFunction(
42+
form_residual!; sparsity = SparseConnectivityTracer.TracerSparsityDetector())
4243
4344
nlprob_dense = NLS.NonlinearProblem(nlfunc_dense, u0)
4445
nlprob_sparse = NLS.NonlinearProblem(nlfunc_sparse, u0)

lib/BracketingNonlinearSolve/src/BracketingNonlinearSolve.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@ function CommonSolve.solve(prob::IntervalNonlinearProblem, nothing, args...; kwa
2929
return CommonSolve.solve(prob, ITP(), args...; kwargs...)
3030
end
3131

32-
function CommonSolve.solve(prob::IntervalNonlinearProblem,
32+
function CommonSolve.solve(prob::IntervalNonlinearProblem,
3333
alg::AbstractBracketingAlgorithm, args...; sensealg = nothing, kwargs...)
34-
return bracketingnonlinear_solve_up(prob::IntervalNonlinearProblem, sensealg, prob.p, alg, args...; kwargs...)
34+
return bracketingnonlinear_solve_up(
35+
prob::IntervalNonlinearProblem, sensealg, prob.p, alg, args...; kwargs...)
3536
end
3637

37-
38-
function bracketingnonlinear_solve_up(prob::IntervalNonlinearProblem, sensealg, p, alg, args...; kwargs...)
38+
function bracketingnonlinear_solve_up(
39+
prob::IntervalNonlinearProblem, sensealg, p, alg, args...; kwargs...)
3940
return SciMLBase.__solve(prob, alg, args...; kwargs...)
4041
end
4142

42-
4343
@setup_workload begin
4444
for T in (Float32, Float64)
4545
prob_brack = IntervalNonlinearProblem{false}(

lib/NonlinearSolveBase/src/NonlinearSolveBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ using EnzymeCore: EnzymeCore
1717
using MaybeInplace: @bb
1818
using RecursiveArrayTools: AbstractVectorOfArray, ArrayPartition
1919
using SciMLBase: SciMLBase, ReturnCode, AbstractODEIntegrator, AbstractNonlinearProblem,
20-
AbstractNonlinearAlgorithm,
20+
AbstractNonlinearAlgorithm,
2121
NonlinearProblem, NonlinearLeastSquaresProblem,
2222
NonlinearFunction, NLStats, LinearProblem,
2323
LinearAliasSpecifier, ImmutableNonlinearProblem

lib/NonlinearSolveBase/src/polyalg.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ end
162162
if !NonlinearSolveBase.not_terminated($(cache_syms[i]))
163163
# If a NonlinearLeastSquaresProblem StalledSuccess, try the next
164164
# solver to see if you get a lower residual
165-
if SciMLBase.successful_retcode($(cache_syms[i]).retcode) &&
166-
$(cache_syms[i]).retcode != ReturnCode.StalledSuccess
165+
if SciMLBase.successful_retcode($(cache_syms[i]).retcode) &&
166+
$(cache_syms[i]).retcode != ReturnCode.StalledSuccess
167167
cache.best = $(i)
168168
cache.force_stop = true
169169
cache.retcode = $(cache_syms[i]).retcode

0 commit comments

Comments
 (0)