Skip to content

Commit d85ed68

Browse files
refactor: format
1 parent f79f997 commit d85ed68

File tree

6 files changed

+24
-15
lines changed

6 files changed

+24
-15
lines changed

src/systems/abstractsystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@ end
12801280
function is_array_of_symbolics(x)
12811281
symbolic_type(x) == ArraySymbolic() && return true
12821282
symbolic_type(x) == ScalarSymbolic() && return false
1283-
x isa AbstractArray && any(y -> symbolic_type(y) != NotSymbolic() || is_array_of_symbolics(y), x)
1283+
x isa AbstractArray &&
1284+
any(y -> symbolic_type(y) != NotSymbolic() || is_array_of_symbolics(y), x)
12841285
end
12851286

12861287
function namespace_expr(

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,13 +854,15 @@ function process_DEProblem(constructor, sys::AbstractODESystem, u0map, parammap;
854854
end
855855
end
856856
defs = defaults(sys)
857-
guesses = merge(ModelingToolkit.guesses(sys), isempty(guesses) ? Dict() : todict(guesses))
857+
guesses = merge(
858+
ModelingToolkit.guesses(sys), isempty(guesses) ? Dict() : todict(guesses))
858859
solvablepars = [p
859-
for p in parameters(sys)
860-
if is_parameter_solvable(p, parammap, defs, guesses)]
860+
for p in parameters(sys)
861+
if is_parameter_solvable(p, parammap, defs, guesses)]
861862
# ModelingToolkit.get_tearing_state(sys) !== nothing => Requires structural_simplify first
862863
if sys isa ODESystem && build_initializeprob &&
863-
(((implicit_dae || !isempty(missingvars) || !isempty(solvablepars) || !isempty(setobserved)) &&
864+
(((implicit_dae || !isempty(missingvars) || !isempty(solvablepars) ||
865+
!isempty(setobserved)) &&
864866
ModelingToolkit.get_tearing_state(sys) !== nothing) ||
865867
!isempty(initialization_equations(sys))) && t !== nothing
866868
if eltype(u0map) <: Number

src/systems/diffeqs/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ function ODESystem(deqs::AbstractVector{<:Equation}, iv, dvs, ps;
237237
"`default_u0` and `default_p` are deprecated. Use `defaults` instead.",
238238
:ODESystem, force = true)
239239
end
240-
defaults = Dict{Any,Any}(todict(defaults))
240+
defaults = Dict{Any, Any}(todict(defaults))
241241
var_to_name = Dict()
242242
process_variables!(var_to_name, defaults, dvs′)
243243
process_variables!(var_to_name, defaults, ps′)

src/systems/model_parsing.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,11 @@ function update_kwargs_and_metadata!(dict, kwargs, a, def, indices, type, var,
157157
if !isnothing(meta) && haskey(meta, VariableUnit)
158158
uvar = gensym()
159159
push!(where_types, uvar)
160-
push!(kwargs, Expr(:kw, :($a::Union{Nothing, Missing, $NoValue, $uvar}), NO_VALUE))
160+
push!(kwargs,
161+
Expr(:kw, :($a::Union{Nothing, Missing, $NoValue, $uvar}), NO_VALUE))
161162
else
162-
push!(kwargs, Expr(:kw, :($a::Union{Nothing, Missing, $NoValue, $type}), NO_VALUE))
163+
push!(kwargs,
164+
Expr(:kw, :($a::Union{Nothing, Missing, $NoValue, $type}), NO_VALUE))
163165
end
164166
dict[:kwargs][getname(var)] = Dict(:value => def, :type => type)
165167
else

src/systems/nonlinear/initializesystem.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function generate_initializesystem(sys::ODESystem;
124124
elseif check_defguess
125125
error("Invalid setup: parameter $(p) has no default value, initial value, or guess")
126126
end
127-
# `missing` passed to `ODEProblem`, and (either an equation using default or a guess)
127+
# `missing` passed to `ODEProblem`, and (either an equation using default or a guess)
128128
elseif _val1 === missing
129129
if _val2 !== nothing && _val2 !== missing
130130
push!(eqs_ics, varp ~ _val2)
@@ -134,8 +134,8 @@ function generate_initializesystem(sys::ODESystem;
134134
elseif check_defguess
135135
error("Invalid setup: parameter $(p) has no default value, initial value, or guess")
136136
end
137-
# No value passed to `ODEProblem`, but a default and a guess are present
138-
# _val2 !== missing is implied by it falling this far in the elseif chain
137+
# No value passed to `ODEProblem`, but a default and a guess are present
138+
# _val2 !== missing is implied by it falling this far in the elseif chain
139139
elseif _val1 === nothing && _val2 !== nothing && _val3 !== nothing
140140
push!(eqs_ics, varp ~ _val2)
141141
push!(u0, varp => _val3)
@@ -176,7 +176,8 @@ function is_parameter_solvable(p, pmap, defs, guesses)
176176
_val3 = get(guesses, p, nothing)
177177
# either (missing is a default or was passed to the ODEProblem) or (nothing was passed to
178178
# the ODEProblem and it has a default and a guess)
179-
return (_val1 === missing || _val2 === missing) || (_val1 === nothing && _val2 !== nothing && _val3 !== nothing)
179+
return (_val1 === missing || _val2 === missing) ||
180+
(_val1 === nothing && _val2 !== nothing && _val3 !== nothing)
180181
end
181182

182183
function SciMLBase.remake_initializeprob(sys::ODESystem, odefn, u0, t0, p)

test/initializationsystem.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
562562
@test solve(prob, Tsit5()).ps[sym] val
563563
end
564564
function test_initializesystem(sys, u0map, pmap, p, equation)
565-
isys = ModelingToolkit.generate_initializesystem(sys; u0map, pmap, guesses = ModelingToolkit.guesses(sys))
565+
isys = ModelingToolkit.generate_initializesystem(
566+
sys; u0map, pmap, guesses = ModelingToolkit.guesses(sys))
566567
@test is_variable(isys, p)
567568
@test equation in equations(isys) || (0 ~ -equation.rhs) in equations(isys)
568569
end
@@ -609,7 +610,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
609610
test_parameter(prob2, p, 2.0)
610611

611612
# No `missing`, default and guess
612-
@mtkbuild sys = ODESystem([D(x) ~ x * q, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 0.0])
613+
@mtkbuild sys = ODESystem(
614+
[D(x) ~ x * q, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 0.0])
613615
delete!(pmap, p)
614616
prob = ODEProblem(sys, u0map, (0.0, 1.0), pmap)
615617
test_parameter(prob, p, 2.0)
@@ -627,7 +629,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
627629
@test prob.ps[p] 3.0
628630
@test prob.f.initializeprob === nothing
629631
# Default overridden by ODEProblem, guess provided
630-
@mtkbuild sys = ODESystem([D(x) ~ q * x, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 1.0])
632+
@mtkbuild sys = ODESystem(
633+
[D(x) ~ q * x, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 1.0])
631634
prob = ODEProblem(sys, u0map, (0.0, 1.0), _pmap)
632635
@test prob.ps[p] 3.0
633636
@test prob.f.initializeprob === nothing

0 commit comments

Comments
 (0)