Skip to content

Commit f0bcf77

Browse files
refactor: format
1 parent 6c9d5e6 commit f0bcf77

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
@@ -1318,7 +1318,8 @@ end
13181318
function is_array_of_symbolics(x)
13191319
symbolic_type(x) == ArraySymbolic() && return true
13201320
symbolic_type(x) == ScalarSymbolic() && return false
1321-
x isa AbstractArray && any(y -> symbolic_type(y) != NotSymbolic() || is_array_of_symbolics(y), x)
1321+
x isa AbstractArray &&
1322+
any(y -> symbolic_type(y) != NotSymbolic() || is_array_of_symbolics(y), x)
13221323
end
13231324

13241325
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
@@ -123,7 +123,7 @@ function generate_initializesystem(sys::ODESystem;
123123
elseif check_defguess
124124
error("Invalid setup: parameter $(p) has no default value, initial value, or guess")
125125
end
126-
# `missing` passed to `ODEProblem`, and (either an equation using default or a guess)
126+
# `missing` passed to `ODEProblem`, and (either an equation using default or a guess)
127127
elseif _val1 === missing
128128
if _val2 !== nothing && _val2 !== missing
129129
push!(eqs_ics, varp ~ _val2)
@@ -133,8 +133,8 @@ function generate_initializesystem(sys::ODESystem;
133133
elseif check_defguess
134134
error("Invalid setup: parameter $(p) has no default value, initial value, or guess")
135135
end
136-
# No value passed to `ODEProblem`, but a default and a guess are present
137-
# _val2 !== missing is implied by it falling this far in the elseif chain
136+
# No value passed to `ODEProblem`, but a default and a guess are present
137+
# _val2 !== missing is implied by it falling this far in the elseif chain
138138
elseif _val1 === nothing && _val2 !== nothing && _val3 !== nothing
139139
push!(eqs_ics, varp ~ _val2)
140140
push!(u0, varp => _val3)
@@ -175,7 +175,8 @@ function is_parameter_solvable(p, pmap, defs, guesses)
175175
_val3 = get(guesses, p, nothing)
176176
# either (missing is a default or was passed to the ODEProblem) or (nothing was passed to
177177
# the ODEProblem and it has a default and a guess)
178-
return (_val1 === missing || _val2 === missing) || (_val1 === nothing && _val2 !== nothing && _val3 !== nothing)
178+
return (_val1 === missing || _val2 === missing) ||
179+
(_val1 === nothing && _val2 !== nothing && _val3 !== nothing)
179180
end
180181

181182
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
@@ -576,7 +576,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
576576
@test solve(prob, Tsit5()).ps[sym] val
577577
end
578578
function test_initializesystem(sys, u0map, pmap, p, equation)
579-
isys = ModelingToolkit.generate_initializesystem(sys; u0map, pmap, guesses = ModelingToolkit.guesses(sys))
579+
isys = ModelingToolkit.generate_initializesystem(
580+
sys; u0map, pmap, guesses = ModelingToolkit.guesses(sys))
580581
@test is_variable(isys, p)
581582
@test equation in equations(isys) || (0 ~ -equation.rhs) in equations(isys)
582583
end
@@ -623,7 +624,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
623624
test_parameter(prob2, p, 2.0)
624625

625626
# No `missing`, default and guess
626-
@mtkbuild sys = ODESystem([D(x) ~ x * q, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 0.0])
627+
@mtkbuild sys = ODESystem(
628+
[D(x) ~ x * q, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 0.0])
627629
delete!(pmap, p)
628630
prob = ODEProblem(sys, u0map, (0.0, 1.0), pmap)
629631
test_parameter(prob, p, 2.0)
@@ -641,7 +643,8 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
641643
@test prob.ps[p] 3.0
642644
@test prob.f.initializeprob === nothing
643645
# Default overridden by ODEProblem, guess provided
644-
@mtkbuild sys = ODESystem([D(x) ~ q * x, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 1.0])
646+
@mtkbuild sys = ODESystem(
647+
[D(x) ~ q * x, D(y) ~ y * p], t; defaults = [p => 2q], guesses = [p => 1.0])
645648
prob = ODEProblem(sys, u0map, (0.0, 1.0), _pmap)
646649
@test prob.ps[p] 3.0
647650
@test prob.f.initializeprob === nothing

0 commit comments

Comments
 (0)