Skip to content

Commit

Permalink
🤖 Format .jl files (#254)
Browse files Browse the repository at this point in the history
Co-authored-by: amontoison <[email protected]>
  • Loading branch information
github-actions[bot] and amontoison authored Jun 22, 2024
1 parent 4f55b76 commit 07c6afb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/ad_api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ end

function get_residual_nnzh(
b::ADModelBackend{GB, HvB, JvB, JtvB, JB, HB, GHJ, HvBLS, JvBLS, JtvBLS, JBLS, HBLS},
nvar) where {GB, HvB, JvB, JtvB, JB, HB, GHJ, HvBLS, JvBLS, JtvBLS, JBLS, HBLS <: AbstractNLPModel}
nvar,
) where {GB, HvB, JvB, JtvB, JB, HB, GHJ, HvBLS, JvBLS, JtvBLS, JBLS, HBLS <: AbstractNLPModel}
nls = b.hessian_residual_backend
nls.nls_meta.nnzh
end
Expand Down
18 changes: 6 additions & 12 deletions src/nls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ function ADNLSModel!(
meta = NLPModelMeta{T, S}(nvar, x0 = x0, nnzh = nnzh, name = name, minimize = minimize)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, (cx, x) -> cx)
end

Expand Down Expand Up @@ -212,8 +211,7 @@ function ADNLSModel!(
)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, (cx, x) -> cx)
end

Expand Down Expand Up @@ -275,8 +273,7 @@ function ADNLSModel!(
)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, c!)
end

Expand Down Expand Up @@ -426,8 +423,7 @@ function ADNLSModel!(
)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, clinrows, clincols, clinvals, c!)
end

Expand Down Expand Up @@ -644,8 +640,7 @@ function ADNLSModel!(
)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, c!)
end

Expand Down Expand Up @@ -750,8 +745,7 @@ function ADNLSModel!(
)
nls_nnzj = get_residual_nnzj(adbackend, nvar, nequ)
nls_nnzh = get_residual_nnzh(adbackend, nvar)
nls_meta =
NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
nls_meta = NLSMeta{T, S}(nequ, nvar, nnzj = nls_nnzj, nnzh = nls_nnzh, lin = linequ)
return ADNLSModel(meta, nls_meta, NLSCounters(), adbackend, F!, clinrows, clincols, clinvals, c!)
end

Expand Down
9 changes: 5 additions & 4 deletions test/sparse_hessian.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
list_sparse_hess_backend =
((ADNLPModels.SparseADHessian, Dict()),
(ADNLPModels.SparseReverseADHessian, Dict()),
(ADNLPModels.ForwardDiffADHessian, Dict()))
list_sparse_hess_backend = (
(ADNLPModels.SparseADHessian, Dict()),
(ADNLPModels.SparseReverseADHessian, Dict()),
(ADNLPModels.ForwardDiffADHessian, Dict()),
)

dt = (Float32, Float64)

Expand Down
4 changes: 2 additions & 2 deletions test/sparse_hessian_nls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dt = (Float32, Float64)
hess_coord_residual!(nls, x, v, vals)
@test eltype(vals) == T
H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L)
@test H == [-20 * v[2] 0; 0 0]
@test H == [-20*v[2] 0; 0 0]

# Test also the implementation of the backends
b = nls.adbackend.hessian_residual_backend
Expand All @@ -37,7 +37,7 @@ dt = (Float32, Float64)
ADNLPModels.hess_coord_residual!(b, nls, x, v, vals)
@test eltype(vals) == T
H = Symmetric(sparse(rows, cols, vals, nvar, nvar), :L)
@test H == [-20 * v[2] 0; 0 0]
@test H == [-20*v[2] 0; 0 0]

nls = ADNLPModels.ADNLSModel!(F!, x0, 3, matrix_free = true; kw...)
@test nls.adbackend.hessian_backend isa ADNLPModels.EmptyADbackend
Expand Down
6 changes: 2 additions & 4 deletions test/sparse_jacobian.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
list_sparse_jac_backend = (
(ADNLPModels.SparseADJacobian, Dict()),
(ADNLPModels.ForwardDiffADJacobian, Dict()),
)
list_sparse_jac_backend =
((ADNLPModels.SparseADJacobian, Dict()), (ADNLPModels.ForwardDiffADJacobian, Dict()))

dt = (Float32, Float64)

Expand Down
6 changes: 2 additions & 4 deletions test/sparse_jacobian_nls.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
list_sparse_jac_backend = (
(ADNLPModels.SparseADJacobian, Dict()),
(ADNLPModels.ForwardDiffADJacobian, Dict()),
)
list_sparse_jac_backend =
((ADNLPModels.SparseADJacobian, Dict()), (ADNLPModels.ForwardDiffADJacobian, Dict()))

dt = (Float32, Float64)

Expand Down

0 comments on commit 07c6afb

Please sign in to comment.