Skip to content

Commit 9394cea

Browse files
committed
Formatting.
1 parent 4b55b5b commit 9394cea

File tree

6 files changed

+12
-11
lines changed

6 files changed

+12
-11
lines changed

src/constants.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ struct MTKConstantCtx end
33

44
function isconstant(x)
55
x = unwrap(x)
6-
x isa Symbolic && getmetadata(x, MTKConstantCtx, false)
6+
x isa Symbolic && getmetadata(x, MTKConstantCtx, false)
77
end
88
isconstant(x::Num) = isconstant(unwrap(x))
99
"""
@@ -17,7 +17,8 @@ function toconstant(s)
1717
elseif s isa AbstractArray
1818
map(toconstant, s)
1919
else
20-
hasmetadata(s, Symbolics.VariableDefaultValue) || throw(ArgumentError("Constant `$(s)` must be assigned a default value."))
20+
hasmetadata(s, Symbolics.VariableDefaultValue) ||
21+
throw(ArgumentError("Constant `$(s)` must be assigned a default value."))
2122
setmetadata(s, MTKConstantCtx, true)
2223
end
2324
end

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ function generate_dae_jacobian(sys::AbstractODESystem, dvs = states(sys),
113113
@variables ˍ₋gamma
114114
jac = ˍ₋gamma * jac_du + jac_u
115115
pre = get_preprocess_constants(jac)
116-
return build_function(jac, derivatives, dvs, ps, ˍ₋gamma, get_iv(sys); postprocess_fbody = pre, kwargs...)
116+
return build_function(jac, derivatives, dvs, ps, ˍ₋gamma, get_iv(sys);
117+
postprocess_fbody = pre, kwargs...)
117118
end
118119

119120
function generate_function(sys::AbstractODESystem, dvs = states(sys), ps = parameters(sys);

src/systems/diffeqs/odesystem.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ function ODESystem(eqs, iv = nothing; kwargs...)
238238
collect(Iterators.flatten((diffvars, algevars))), ps; kwargs...)
239239
end
240240

241-
242241
# NOTE: equality does not check cached Jacobian
243242
function Base.:(==)(sys1::ODESystem, sys2::ODESystem)
244243
sys1 === sys2 && return true

src/systems/systemstructure.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ function TearingState(sys; quick_cancel = false, check = true)
266266
for var in vars
267267
_var, _ = var_from_nested_derivative(var)
268268
any(isequal(_var), ivs) && continue
269-
if isparameter(_var) || (istree(_var) && isparameter(operation(_var)) || isconstant(_var))
269+
if isparameter(_var) ||
270+
(istree(_var) && isparameter(operation(_var)) || isconstant(_var))
270271
continue
271272
end
272273
varidx = addvar!(var)

src/utils.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ function collect_constants(eqs::Vector{Equation}) #For get_substitutions_and_sol
513513
return constants
514514
end
515515

516-
function collect_constants(eqs::AbstractArray{T}) where T # For generate_tgrad / generate_jacobian / generate_difference_cb
516+
function collect_constants(eqs::AbstractArray{T}) where {T} # For generate_tgrad / generate_jacobian / generate_difference_cb
517517
constants = T[]
518518
for eq in eqs
519519
collect_constants!(constants, unwrap(eq))
@@ -542,7 +542,7 @@ end
542542
function get_preprocess_constants(eqs)
543543
cs = collect_constants(eqs)
544544
pre = ex -> Let(Assignment[Assignment(x, getdefault(x)) for x in cs],
545-
ex, false)
545+
ex, false)
546546
return pre
547547
end
548548

@@ -586,7 +586,7 @@ end
586586
function get_substitutions_and_solved_states(sys; no_postprocess = false)
587587
#Inject substitutions for constants => values
588588
cs = collect_constants([sys.eqs; sys.observed]) #ctrls? what else?
589-
if !empty_substitutions(sys)
589+
if !empty_substitutions(sys)
590590
cs = [cs; collect_constants(sys.substitutions.subs)]
591591
end
592592
# Swap constants for their values
@@ -598,7 +598,7 @@ function get_substitutions_and_solved_states(sys; no_postprocess = false)
598598
else # Have to do some work
599599
if !empty_substitutions(sys)
600600
@unpack subs = get_substitutions(sys)
601-
else
601+
else
602602
subs = []
603603
end
604604
subs = [cmap; subs] # The constants need to go first

test/constants.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ simp = structural_simplify(sys);
2121
@test isequal(equations(simp)[1], eqs[1])
2222
prob = ODEProblem(simp, [0, ], [0.0, 1.0], [])
2323
sol = solve(prob, Tsit5())
24-
@test sol[w][1] == 1
25-
24+
@test sol[w][1] == 1

0 commit comments

Comments
 (0)