Skip to content

Commit 46af08d

Browse files
refactor: format
1 parent 19a4362 commit 46af08d

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

src/systems/abstractsystem.jl

+10-9
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,9 @@ function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym)
352352
return sym in 1:length(variable_symbols(sys))
353353
end
354354
if has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
355-
return is_variable(ic, sym) || istree(sym) && operation(sym) === getindex &&
356-
is_variable(ic, first(arguments(sym)))
355+
return is_variable(ic, sym) ||
356+
istree(sym) && operation(sym) === getindex &&
357+
is_variable(ic, first(arguments(sym)))
357358
end
358359
return any(isequal(sym), variable_symbols(sys)) ||
359360
hasname(sym) && is_variable(sys, getname(sym))
@@ -379,8 +380,8 @@ function SymbolicIndexingInterface.variable_index(sys::AbstractSystem, sym)
379380
return if (idx = variable_index(ic, sym)) !== nothing
380381
idx
381382
elseif istree(sym) && operation(sym) === getindex &&
382-
(idx = variable_index(ic, first(arguments(sym)))) !== nothing
383-
idx[arguments(sym)[begin + 1:end]...]
383+
(idx = variable_index(ic, first(arguments(sym)))) !== nothing
384+
idx[arguments(sym)[(begin + 1):end]...]
384385
else
385386
nothing
386387
end
@@ -415,8 +416,9 @@ end
415416
function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym)
416417
sym = unwrap(sym)
417418
if has_index_cache(sys) && (ic = get_index_cache(sys)) !== nothing
418-
return is_parameter(ic, sym) || istree(sym) && operation(sym) === getindex &&
419-
is_parameter(ic, first(arguments(sym)))
419+
return is_parameter(ic, sym) ||
420+
istree(sym) && operation(sym) === getindex &&
421+
is_parameter(ic, first(arguments(sym)))
420422
end
421423
if unwrap(sym) isa Int
422424
return unwrap(sym) in 1:length(parameter_symbols(sys))
@@ -441,8 +443,8 @@ function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym)
441443
return if (idx = parameter_index(ic, sym)) !== nothing
442444
idx
443445
elseif istree(sym) && operation(sym) === getindex &&
444-
(idx = parameter_index(ic, first(arguments(sym)))) !== nothing
445-
ParameterIndex(idx.portion, (idx.idx..., arguments(sym)[begin+1:end]...))
446+
(idx = parameter_index(ic, first(arguments(sym)))) !== nothing
447+
ParameterIndex(idx.portion, (idx.idx..., arguments(sym)[(begin + 1):end]...))
446448
else
447449
nothing
448450
end
@@ -1701,7 +1703,6 @@ function linearization_function(sys::AbstractSystem, inputs,
17011703
u0, _p, _ = get_u0_p(sys, x0, p; use_union = false, tofloat = true)
17021704
ps = parameters(sys)
17031705
if has_index_cache(sys) && get_index_cache(sys) !== nothing
1704-
@show p full_parameters(sys)
17051706
p = MTKParameters(sys, p)
17061707
else
17071708
p = _p

src/systems/index_cache.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ end
160160

161161
function SymbolicIndexingInterface.is_parameter(ic::IndexCache, sym)
162162
return check_index_map(ic.tunable_idx, sym) !== nothing ||
163-
check_index_map(ic.discrete_idx, sym) !== nothing ||
164-
check_index_map(ic.constant_idx, sym) !== nothing ||
165-
check_index_map(ic.nonnumeric_idx, sym) !== nothing ||
166-
check_index_map(ic.dependent_idx, sym) !== nothing
163+
check_index_map(ic.discrete_idx, sym) !== nothing ||
164+
check_index_map(ic.constant_idx, sym) !== nothing ||
165+
check_index_map(ic.nonnumeric_idx, sym) !== nothing ||
166+
check_index_map(ic.dependent_idx, sym) !== nothing
167167
end
168168

169169
function SymbolicIndexingInterface.parameter_index(ic::IndexCache, sym)

src/systems/optimization/constraints_system.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ function calculate_hessian(sys::ConstraintsSystem; sparse = false, simplify = fa
182182
return hess
183183
end
184184

185-
function generate_hessian(sys::ConstraintsSystem, vs = unknowns(sys), ps = full_parameters(sys);
185+
function generate_hessian(
186+
sys::ConstraintsSystem, vs = unknowns(sys), ps = full_parameters(sys);
186187
sparse = false, simplify = false, kwargs...)
187188
hess = calculate_hessian(sys, sparse = sparse, simplify = simplify)
188189
p = reorder_parameters(sys, ps)

src/systems/parameter_buffer.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function MTKParameters(sys::AbstractSystem, p; tofloat = false, use_union = fals
3838

3939
for (sym, _) in p
4040
if istree(sym) && operation(sym) === getindex &&
41-
first(arguments(sym)) in all_ps
41+
first(arguments(sym)) in all_ps
4242
error("Scalarized parameter values ($sym) are not supported. Instead of `[p[1] => 1.0, p[2] => 2.0]` use `[p => [1.0, 2.0]]`")
4343
end
4444
end

test/initializationsystem.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,4 @@ sol = solve(prob, Tsit5())
429429
@test sol.u[1] == [0.0, 1.0]
430430

431431
# This should warn, but logging tests can't be marked as broken
432-
@test_logs prob=ODEProblem(simpsys, [], tspan, guesses = [x => 2.0])
432+
@test_logs prob = ODEProblem(simpsys, [], tspan, guesses = [x => 2.0])

0 commit comments

Comments
 (0)