Skip to content

Format for JuliaFormatter v2 #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ makedocs(;
"https://twitter.com/ChrisRackauckas/status/1544743542094020615",
"https://link.springer.com/article/10.1007/s40096-020-00339-4",
"https://dl.acm.org/doi/10.1145/210089.210111",
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156",
"https://www.sciencedirect.com/science/article/abs/pii/S0045782523007156"
],
checkdocs = :exports,
warnonly = [:missing_docs],
Expand Down
19 changes: 12 additions & 7 deletions docs/src/tutorials/large_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ function brusselator_2d_loop(du, u, p)
@inbounds for I in CartesianIndices((N, N))
i, j = Tuple(I)
x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
ip1, im1, jp1, jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
ip1, im1, jp1,
jm1 = limit(i + 1, N), limit(i - 1, N), limit(j + 1, N),
limit(j - 1, N)
du[i, j, 1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
4u[i, j, 1]) +
B +
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)
du[i, j, 2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
du[i,
j,
1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
4u[i, j, 1]) +
B +
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)
Comment on lines +81 to +85
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
j,
1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
4u[i, j, 1]) +
B +
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)
j,
1] = alpha * (u[im1, j, 1] + u[ip1, j, 1] + u[i, jp1, 1] + u[i, jm1, 1] -
4u[i, j, 1]) +
B +
u[i, j, 1]^2 * u[i, j, 2] - (A + 1) * u[i, j, 1] + brusselator_f(x, y)

du[i,
j,
2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
Comment on lines +87 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
j,
2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]
j,
2] = alpha * (u[im1, j, 2] + u[ip1, j, 2] + u[i, jp1, 2] + u[i, jm1, 2] -
4u[i, j, 2]) + A * u[i, j, 1] - u[i, j, 1]^2 * u[i, j, 2]

end
end
p = (3.4, 1.0, 10.0, step(xyd_brusselator))
Expand Down
13 changes: 7 additions & 6 deletions docs/src/tutorials/nonlinear_solve_gpus.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using the first form.
In this tutorial we will highlight both use cases in separate parts.

!!! note

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

Expand All @@ -58,7 +58,7 @@ f(u, p) = u .* u .- p
u0 = cu(ones(1000))
p = cu(collect(1:1000))
prob = NonlinearProblem(f, u0, p)
sol = solve(prob, NewtonRaphson(), abstol=1f-4)
sol = solve(prob, NewtonRaphson(), abstol = 1.0f-4)
```

Notice a few things here. One, nothing is different except the input array types. But
Expand Down Expand Up @@ -106,7 +106,7 @@ is saying, "for the ith call, get the i'th parameter set and solve with these pa
The ith result is then this solution".

!!! note

Because kernel code needs to be able to be compiled to a GPU kernel, it has very strict
specifications of what's allowed because GPU cores are not as flexible as CPU cores.
In general, this means that you need to avoid any runtime operations in kernel code,
Expand Down Expand Up @@ -137,16 +137,16 @@ Now let's build a nonlinear system to test it on.
out2 = sqrt(p[2]) * (x[3] - x[4])
out3 = (x[2] - p[3] * x[3])^2
out4 = sqrt(p[4]) * (x[1] - x[4]) * (x[1] - x[4])
SA[out1,out2,out3,out4]
SA[out1, out2, out3, out4]
end

p = @SVector [@SVector(rand(Float32, 4)) for _ in 1:1024]
u0 = SA[1f0, 2f0, 3f0, 4f0]
u0 = SA[1.0f0, 2.0f0, 3.0f0, 4.0f0]
prob = NonlinearSolveBase.ImmutableNonlinearProblem{false}(p2_f, u0, p)
```

!!! note

Because the custom kernel is going to need to embed the the code for our nonlinear
problem into the kernel, it also must be written to be GPU compatible.
In general, this means that you need to avoid any runtime operations in kernel code,
Expand All @@ -173,4 +173,5 @@ vectorized_solve(prob, SimpleNewtonRaphson(); backend = Metal.MetalBackend())
```

!!! warn

The GPU-based calls will only work on your machine if you have a compatible GPU!
9 changes: 6 additions & 3 deletions ext/NonlinearSolveFastLevenbergMarquardtExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function SciMLBase.__solve(
termination_condition, alg
)

f_wrapped, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
f_wrapped, u,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0, can_handle_oop = Val(prob.u0 isa SArray)
)
f = if prob.u0 isa SArray
Expand Down Expand Up @@ -49,7 +50,8 @@ function SciMLBase.__solve(
)

if prob.u0 isa SArray
res, fx, info, iter, nfev, njev = FastLM.lmsolve(
res, fx, info, iter, nfev,
njev = FastLM.lmsolve(
f, jac_fn, prob.u0; solver_kwargs...
)
LM, solver = nothing, nothing
Expand All @@ -68,7 +70,8 @@ function SciMLBase.__solve(

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

res, fx, info, iter, nfev, njev, LM, solver = FastLM.lmsolve!(
res, fx, info, iter, nfev, njev,
LM, solver = FastLM.lmsolve!(
f, jac_fn, LM; solver, solver_kwargs...
)
end
Expand Down
3 changes: 2 additions & 1 deletion ext/NonlinearSolveFixedPointAccelerationExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function SciMLBase.__solve(
termination_condition, alg
)

f, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
f, u0,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0, make_fixed_point = Val(true), force_oop = Val(true)
)

Expand Down
3 changes: 2 additions & 1 deletion ext/NonlinearSolveMINPACKExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ function SciMLBase.__solve(
termination_condition, alg
)

f_wrapped!, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
f_wrapped!, u0,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0
)
resid_size = size(resid)
Expand Down
3 changes: 2 additions & 1 deletion ext/NonlinearSolveNLSolversExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function SciMLBase.__solve(
prob.f, autodiff, prob.u0, Constant(prob.p)
)

fj_scalar = @closure (Jx, x) -> begin
fj_scalar = @closure (Jx,
x) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
x) -> begin
x) -> begin

return DifferentiationInterface.value_and_derivative(
prob.f, prep, autodiff, x, Constant(prob.p)
)
Expand Down
20 changes: 15 additions & 5 deletions ext/NonlinearSolvePETScExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ function SciMLBase.__solve(
termination_condition, alg; abs_norm_supported = false
)

f_wrapped!, u0, resid = NonlinearSolveBase.construct_extension_function_wrapper(
f_wrapped!, u0,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0
)
T = eltype(u0)
Expand All @@ -48,7 +49,9 @@ function SciMLBase.__solve(

nf = Ref{Int}(0)

f! = @closure (cfx, cx, user_ctx) -> begin
f! = @closure (cfx,
cx,
user_ctx) -> begin
Comment on lines +53 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
cx,
user_ctx) -> begin
cx,
user_ctx) -> begin

nf[] += 1
fx = cfx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cfx; read = false) : cfx
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
Expand Down Expand Up @@ -76,7 +79,8 @@ function SciMLBase.__solve(
)
J_init = zeros(T, 1, 1)
else
jac!, J_init = NonlinearSolveBase.construct_extension_jac(
jac!,
J_init = NonlinearSolveBase.construct_extension_jac(
prob, alg, u0, resid; autodiff, initial_jacobian = Val(true)
)
end
Expand All @@ -85,7 +89,10 @@ function SciMLBase.__solve(

if J_init isa AbstractSparseMatrix
PJ = PETSc.MatSeqAIJ(J_init)
jac_fn! = @closure (cx, J, _, user_ctx) -> begin
jac_fn! = @closure (cx,
J,
_,
user_ctx) -> begin
Comment on lines +93 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
J,
_,
user_ctx) -> begin
J,
_,
user_ctx) -> begin

njac[] += 1
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
if J isa PETSc.AbstractMat
Expand All @@ -102,7 +109,10 @@ function SciMLBase.__solve(
snes.user_ctx = (; jacobian = J_init)
else
PJ = PETSc.MatSeqDense(J_init)
jac_fn! = @closure (cx, J, _, user_ctx) -> begin
jac_fn! = @closure (cx,
J,
_,
user_ctx) -> begin
Comment on lines +113 to +115
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
J,
_,
user_ctx) -> begin
J,
_,
user_ctx) -> begin

njac[] += 1
x = cx isa Ptr{Nothing} ? PETSc.unsafe_localarray(T, cx; write = false) : cx
jac!(J, x)
Expand Down
6 changes: 4 additions & 2 deletions ext/NonlinearSolveSIAMFANLEquationsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ function SciMLBase.__solve(
elseif method == :secant
sol = secant(f, prob.u0; maxit = maxiters, atol, rtol, printerr)
elseif method == :anderson
f_aa, u, _ = NonlinearSolveBase.construct_extension_function_wrapper(
f_aa, u,
_ = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0, make_fixed_point = Val(true)
)
sol = aasol(
Expand All @@ -73,7 +74,8 @@ function SciMLBase.__solve(
)
end
else
f, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
f, u,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0, make_fixed_point = Val(method == :anderson)
)
N = length(u)
Expand Down
3 changes: 2 additions & 1 deletion ext/NonlinearSolveSpeedMappingExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ function SciMLBase.__solve(
termination_condition, alg
)

m!, u, resid = NonlinearSolveBase.construct_extension_function_wrapper(
m!, u,
resid = NonlinearSolveBase.construct_extension_function_wrapper(
prob; alias_u0, make_fixed_point = Val(true)
)
tol = NonlinearSolveBase.get_tolerance(abstol, eltype(u))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ using SciMLBase: SciMLBase, IntervalNonlinearProblem

using BracketingNonlinearSolve: Bisection, Brent, Alefeld, Falsi, ITP, Ridder

const DualIntervalNonlinearProblem{T, V, P} = IntervalNonlinearProblem{
const DualIntervalNonlinearProblem{T,
V,
P} = IntervalNonlinearProblem{
Comment on lines +11 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
V,
P} = IntervalNonlinearProblem{
V,
P} = IntervalNonlinearProblem{

uType, iip, <:Union{<:Dual{T, V, P}, <:AbstractArray{<:Dual{T, V, P}}}
} where {uType, iip}

Expand Down
3 changes: 2 additions & 1 deletion lib/BracketingNonlinearSolve/src/bisection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function CommonSolve.solve(
i += 1
end

sol, i, left, right, fl, fr = Impl.bisection(
sol, i, left, right,
fl, fr = Impl.bisection(
left, right, fl, fr, f, abstol, maxiters - i, prob, alg
)

Expand Down
3 changes: 2 additions & 1 deletion lib/BracketingNonlinearSolve/src/brent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ function CommonSolve.solve(
i += 1
end

sol, i, left, right, fl, fr = Impl.bisection(
sol, i, left, right,
fl, fr = Impl.bisection(
left, right, fl, fr, f, abstol, maxiters - i, prob, alg
)

Expand Down
3 changes: 2 additions & 1 deletion lib/BracketingNonlinearSolve/src/falsi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ function CommonSolve.solve(
i += 1
end

sol, i, left, right, fl, fr = Impl.bisection(
sol, i, left, right,
fl, fr = Impl.bisection(
left, right, fl, fr, f, abstol, maxiters - i, prob, alg
)

Expand Down
3 changes: 2 additions & 1 deletion lib/BracketingNonlinearSolve/src/ridder.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ function CommonSolve.solve(
i += 1
end

sol, i, left, right, fl, fr = Impl.bisection(
sol, i, left, right,
fl, fr = Impl.bisection(
left, right, fl, fr, f, abstol, maxiters - i, prob, alg
)

Expand Down
8 changes: 4 additions & 4 deletions lib/BracketingNonlinearSolve/test/rootfind_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ end

@testset for p in 1.1:0.1:100.0
@test g(p)≈sqrt(p) atol=1e-3 rtol=1e-3
@test ForwardDiff.derivative(g, p)≈1 / (2 * sqrt(p)) atol=1e-3 rtol=1e-3
@test ForwardDiff.derivative(g, p)≈1/(2*sqrt(p)) atol=1e-3 rtol=1e-3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@test ForwardDiff.derivative(g, p)1/(2*sqrt(p)) atol=1e-3 rtol=1e-3
@test ForwardDiff.derivative(g, p)1 / (2 * sqrt(p)) atol=1e-3 rtol=1e-3

end

t = (p) -> [sqrt(p[2] / p[1])]
Expand All @@ -30,7 +30,7 @@ end
return [sol.u]
end

@test g2(p)≈[sqrt(p[2] / p[1])] atol=1e-3 rtol=1e-3
@test g2(p)≈[sqrt(p[2]/p[1])] atol=1e-3 rtol=1e-3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
@test g2(p)[sqrt(p[2]/p[1])] atol=1e-3 rtol=1e-3
@test g2(p)[sqrt(p[2] / p[1])] atol=1e-3 rtol=1e-3

@test ForwardDiff.jacobian(g2, p)≈ForwardDiff.jacobian(t, p) atol=1e-3 rtol=1e-3

probB = IntervalNonlinearProblem{false}(quadratic_f, (1.0, 2.0), 2.0)
Expand All @@ -50,8 +50,8 @@ end
end

@testitem "Tolerance Tests Interval Methods" setup=[RootfindingTestSnippet] tags=[:core] begin
prob = IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
ϵ = eps(Float64) # least possible tol for all methods
prob=IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
ϵ=eps(Float64) # least possible tol for all methods
Comment on lines +53 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
prob=IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
ϵ=eps(Float64) # least possible tol for all methods
prob = IntervalNonlinearProblem(quadratic_f, (1.0, 20.0), 2.0)
ϵ = eps(Float64) # least possible tol for all methods


@testset for alg in (Bisection(), Falsi(), ITP(), Muller(), nothing)
@testset for abstol in [0.1, 0.01, 0.001, 0.0001, 1e-5, 1e-6]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ for algType in GENERAL_SOLVER_TYPES
@eval function SciMLBase.__solve(
prob::DualAbstractNonlinearProblem, alg::$(algType), args...; kwargs...
)
sol, partials = NonlinearSolveBase.nonlinearsolve_forwarddiff_solve(
sol,
partials = NonlinearSolveBase.nonlinearsolve_forwarddiff_solve(
prob, alg, args...; kwargs...
)
dual_soln = NonlinearSolveBase.nonlinearsolve_dual_solution(sol.u, partials, prob.p)
Expand Down
2 changes: 1 addition & 1 deletion lib/NonlinearSolveBase/src/NonlinearSolveBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ include("forward_diff.jl")
@compat(public, (construct_jacobian_cache,))
@compat(public,
(assert_extension_supported_termination_condition,
construct_extension_function_wrapper, construct_extension_jac))
construct_extension_function_wrapper, construct_extension_jac))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
construct_extension_function_wrapper, construct_extension_jac))
construct_extension_function_wrapper, construct_extension_jac))


export TraceMinimal, TraceWithJacobianConditionNumber, TraceAll

Expand Down
18 changes: 12 additions & 6 deletions lib/NonlinearSolveBase/src/autodiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,25 @@ function nlls_generate_vjp_function(prob::NonlinearLeastSquaresProblem, sol, uu)
# nested autodiff as the last resort
if SciMLBase.has_vjp(prob.f)
if SciMLBase.isinplace(prob)
return @closure (du, u, p) -> begin
return @closure (
du, u, p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
du, u, p) -> begin
du, u, p) -> begin

resid = Utils.safe_similar(du, length(sol.resid))
prob.f(resid, u, p)
prob.f.vjp(du, resid, u, p)
du .*= 2
return nothing
end
else
return @closure (u, p) -> begin
return @closure (
u, p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
u, p) -> begin
u, p) -> begin

resid = prob.f(u, p)
return reshape(2 .* prob.f.vjp(resid, u, p), size(u))
end
end
elseif SciMLBase.has_jac(prob.f)
if SciMLBase.isinplace(prob)
return @closure (du, u, p) -> begin
return @closure (
du, u, p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
du, u, p) -> begin
du, u, p) -> begin

J = Utils.safe_similar(du, length(sol.resid), length(u))
prob.f.jac(J, u, p)
resid = Utils.safe_similar(du, length(sol.resid))
Expand All @@ -142,7 +145,8 @@ function nlls_generate_vjp_function(prob::NonlinearLeastSquaresProblem, sol, uu)
return nothing
end
else
return @closure (u, p) -> begin
return @closure (u,
p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
p) -> begin
p) -> begin

return reshape(2 .* vec(prob.f(u, p))' * prob.f.jac(u, p), size(u))
end
end
Expand All @@ -152,7 +156,8 @@ function nlls_generate_vjp_function(prob::NonlinearLeastSquaresProblem, sol, uu)
select_reverse_mode_autodiff(prob, nothing) : AutoForwardDiff()

if SciMLBase.isinplace(prob)
return @closure (du, u, p) -> begin
return @closure (
du, u, p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
du, u, p) -> begin
du, u, p) -> begin

resid = Utils.safe_similar(du, length(sol.resid))
prob.f(resid, u, p)
# Using `Constant` lead to dual ordering issues
Expand All @@ -163,7 +168,8 @@ function nlls_generate_vjp_function(prob::NonlinearLeastSquaresProblem, sol, uu)
return nothing
end
else
return @closure (u, p) -> begin
return @closure (u,
p) -> begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
p) -> begin
p) -> begin

v = prob.f(u, p)
# Using `Constant` lead to dual ordering issues
res = only(DI.pullback(Base.Fix2(prob.f, p), autodiff, u, (v,)))
Expand Down
Loading
Loading