Skip to content

Commit 93f058d

Browse files
authored
Format (#280)
* Format * add undersocres
1 parent 275cebc commit 93f058d

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

src/NonLinearProgram/NonLinearProgram.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ function Model()
294294
)
295295
end
296296

297-
objective_sense(form::Form) = form.sense
298-
objective_sense(model::Model) = objective_sense(model.model)
297+
_objective_sense(form::Form) = form.sense
298+
_objective_sense(model::Model) = _objective_sense(model.model)
299299

300300
function MOI.set(
301301
model::Model,

src/NonLinearProgram/nlp_utilities.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ function _compute_derivatives_no_relax(
445445
return ∂s, K, N
446446
end
447447

448-
_sense_mult(model::Model) = objective_sense(model) == MOI.MIN_SENSE ? 1.0 : -1.0
448+
function _sense_mult(model::Model)
449+
return _objective_sense(model) == MOI.MIN_SENSE ? 1.0 : -1.0
450+
end
449451

450452
"""
451453
_compute_sensitivity(model::Model; tol=1e-6)

src/moi_wrapper.jl

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,11 @@ function reverse_differentiate!(model::Optimizer)
521521
)
522522
end
523523
diff = _diff(model)
524-
MOI.set(diff, NonLinearKKTJacobianFactorization(), model.input_cache.factorization)
524+
MOI.set(
525+
diff,
526+
NonLinearKKTJacobianFactorization(),
527+
model.input_cache.factorization,
528+
)
525529
for (vi, value) in model.input_cache.dx
526530
MOI.set(diff, ReverseVariablePrimal(), model.index_map[vi], value)
527531
end
@@ -551,7 +555,11 @@ function forward_differentiate!(model::Optimizer)
551555
)
552556
end
553557
diff = _diff(model)
554-
MOI.set(diff, NonLinearKKTJacobianFactorization(), model.input_cache.factorization)
558+
MOI.set(
559+
diff,
560+
NonLinearKKTJacobianFactorization(),
561+
model.input_cache.factorization,
562+
)
555563
if model.input_cache.objective !== nothing
556564
MOI.set(
557565
diff,
@@ -746,7 +754,7 @@ function MOI.get(
746754
model::Optimizer,
747755
::ReverseVariablePrimal,
748756
vi::MOI.VariableIndex,
749-
)
757+
)
750758
return get(model.input_cache.dx, vi, 0.0)
751759
end
752760

@@ -857,12 +865,16 @@ end
857865
function MOI.supports(
858866
model::Optimizer,
859867
::NonLinearKKTJacobianFactorization,
860-
::Function
868+
::Function,
861869
)
862870
return true
863871
end
864872

865-
function MOI.set(model::Optimizer, ::NonLinearKKTJacobianFactorization, factorization)
873+
function MOI.set(
874+
model::Optimizer,
875+
::NonLinearKKTJacobianFactorization,
876+
factorization,
877+
)
866878
model.input_cache.factorization = factorization
867879
return
868880
end

test/nlp_program.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,15 +825,23 @@ function test_changing_factorization()
825825
)
826826

827827
# wrong type
828-
@test_throws MethodError MOI.set(m, DiffOpt.NonLinearKKTJacobianFactorization(), 2)
828+
@test_throws MethodError MOI.set(
829+
m,
830+
DiffOpt.NonLinearKKTJacobianFactorization(),
831+
2,
832+
)
829833

830834
# correct type but wrong number of arguments
831835
MOI.set(m, DiffOpt.NonLinearKKTJacobianFactorization(), SparseArrays.lu)
832836

833837
@test_throws MethodError DiffOpt.forward_differentiate!(m)
834838

835839
# correct type and correct number of arguments
836-
MOI.set(m, DiffOpt.NonLinearKKTJacobianFactorization(), (M, model) -> SparseArrays.lu(M))
840+
MOI.set(
841+
m,
842+
DiffOpt.NonLinearKKTJacobianFactorization(),
843+
(M, model) -> SparseArrays.lu(M),
844+
)
837845

838846
# Compute derivatives
839847
DiffOpt.forward_differentiate!(m)

0 commit comments

Comments
 (0)