Skip to content

Commit b11983c

Browse files
SciML BotChrisRackauckas
authored andcommitted
Apply JuliaFormatter to fix code formatting
- Applied JuliaFormatter with SciML style guide - Formatted 75 files 🤖 Generated by OrgMaintenanceScripts.jl
1 parent 54c5fcb commit b11983c

File tree

75 files changed

+593
-430
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+593
-430
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/tutorials/large_systems.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ function brusselator_2d_loop(du, u, p)
7878
@inbounds for I in CartesianIndices((N, N))
7979
i, j = Tuple(I)
8080
x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
81-
ip1, im1, jp1, jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
81+
ip1, im1, jp1,
82+
jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
8283
limit(j - 1, N)
8384
du[i, j, 1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
8485
4u[i, j, 1]) +
@@ -279,7 +280,8 @@ which is more automatic. The setup is very similar to before:
279280
import AlgebraicMultigrid
280281
281282
function algebraicmultigrid(W, p = nothing)
282-
return AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.ruge_stuben(convert(AbstractMatrix, W))), LinearAlgebra.I
283+
return AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.ruge_stuben(convert(AbstractMatrix, W))),
284+
LinearAlgebra.I
283285
end
284286
285287
BenchmarkTools.@btime NLS.solve(prob_brusselator_2d_sparse,

docs/src/tutorials/nonlinear_solve_gpus.md

Lines changed: 8 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,7 @@ 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!(result, @Const(prob), @Const(alg))
9999
i = @index(Global)
100100
prob_i = SciMLBase.remake(prob; p = prob.p[i])
101101
sol = NLS.solve(prob_i, alg)
@@ -109,7 +109,7 @@ is saying, "for the ith call, get the i'th parameter set and solve with these pa
109109
The ith result is then this solution".
110110

111111
!!! note
112-
112+
113113
Because kernel code needs to be able to be compiled to a GPU kernel, it has very strict
114114
specifications of what's allowed because GPU cores are not as flexible as CPU cores.
115115
In general, this means that you need to avoid any runtime operations in kernel code,
@@ -140,16 +140,16 @@ Now let's build a nonlinear system to test it on.
140140
out2 = sqrt(p[2]) * (x[3] - x[4])
141141
out3 = (x[2] - p[3] * x[3])^2
142142
out4 = sqrt(p[4]) * (x[1] - x[4]) * (x[1] - x[4])
143-
StaticArrays.SA[out1,out2,out3,out4]
143+
StaticArrays.SA[out1, out2, out3, out4]
144144
end
145145

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

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

178178
!!! warn
179+
179180
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ nlls_prob = NLS.NonlinearLeastSquaresProblem(loss_function, p_init, vec(reduce(h
5353
Now, we can use any NLLS solver to solve this problem.
5454

5555
```@example parameterized_ode
56-
res = NLS.solve(nlls_prob, NLS.LevenbergMarquardt(); maxiters = 1000, show_trace = Val(true),
56+
res = NLS.solve(
57+
nlls_prob, NLS.LevenbergMarquardt(); maxiters = 1000, show_trace = Val(true),
5758
trace_level = NLS.TraceWithJacobianConditionNumber(25))
5859
nothing # hide
5960
```

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)

ext/NonlinearSolveFastLevenbergMarquardtExt.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function SciMLBase.__solve(
2121
termination_condition, alg
2222
)
2323

24-
f_wrapped, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
24+
f_wrapped, u,
25+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2526
prob; alias_u0, can_handle_oop = Val(prob.u0 isa SArray)
2627
)
2728
f = if prob.u0 isa SArray
@@ -49,7 +50,8 @@ function SciMLBase.__solve(
4950
)
5051

5152
if prob.u0 isa SArray
52-
res, fx, info, iter, nfev, njev = FastLM.lmsolve(
53+
res, fx, info, iter, nfev,
54+
njev = FastLM.lmsolve(
5355
f, jac_fn, prob.u0; solver_kwargs...
5456
)
5557
LM, solver = nothing, nothing
@@ -68,7 +70,8 @@ function SciMLBase.__solve(
6870

6971
LM = FastLM.LMWorkspace(u, resid, J)
7072

71-
res, fx, info, iter, nfev, njev, LM, solver = FastLM.lmsolve!(
73+
res, fx, info, iter, nfev, njev,
74+
LM, solver = FastLM.lmsolve!(
7275
f, jac_fn, LM; solver, solver_kwargs...
7376
)
7477
end

ext/NonlinearSolveFixedPointAccelerationExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ function SciMLBase.__solve(
1515
termination_condition, alg
1616
)
1717

18-
f, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
18+
f, u0,
19+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
1920
prob; alias_u0, make_fixed_point = Val(true), force_oop = Val(true)
2021
)
2122

ext/NonlinearSolveMINPACKExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ function SciMLBase.__solve(
1717
termination_condition, alg
1818
)
1919

20-
f_wrapped!, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
20+
f_wrapped!, u0,
21+
resid = NonlinearSolveBase.construct_extension_function_wrapper(
2122
prob; alias_u0
2223
)
2324
resid_size = size(resid)

ext/NonlinearSolveNLSolversExt.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function SciMLBase.__solve(
3333
prob.f, autodiff, prob.u0, Constant(prob.p)
3434
)
3535

36-
fj_scalar = @closure (Jx, x) -> begin
36+
fj_scalar = @closure (Jx,
37+
x) -> begin
3738
return DifferentiationInterface.value_and_derivative(
3839
prob.f, prep, autodiff, x, Constant(prob.p)
3940
)

0 commit comments

Comments
 (0)