Skip to content

Commit 456f00f

Browse files
authored
Merge pull request #1412 from rikhuijzer/kwarg-syntax
Use newer keyword arg syntax
2 parents 887ad82 + 601ba46 commit 456f00f

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

docs/src/basics/Composition.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ function UnitMassWithFriction(k; name)
279279
D(x) ~ v
280280
D(v) ~ sin(t) - k*sign(v) # f = ma, sinusoidal force acting on the mass, and Coulomb friction opposing the movement
281281
]
282-
ODESystem(eqs, t, continuous_events=[v ~ 0], name=name) # when v = 0 there is a discontinuity
282+
ODESystem(eqs, t; continuous_events=[v ~ 0], name) # when v = 0 there is a discontinuity
283283
end
284284
@named m = UnitMassWithFriction(0.7)
285285
prob = ODEProblem(m, Pair[], (0, 10pi))
@@ -300,7 +300,7 @@ affect = [v ~ -v] # the effect is that the velocity changes sign
300300
@named ball = ODESystem([
301301
D(x) ~ v
302302
D(v) ~ -9.8
303-
], t, continuous_events = root_eqs => affect) # equation => affect
303+
], t; continuous_events = root_eqs => affect) # equation => affect
304304

305305
ball = structural_simplify(ball)
306306

@@ -327,7 +327,7 @@ continuous_events = [ # This time we have a vector of pairs
327327
D(y) ~ vy,
328328
D(vx) ~ -9.8-0.1vx, # gravity + some small air resistance
329329
D(vy) ~ -0.1vy,
330-
], t, continuous_events = continuous_events)
330+
], t; continuous_events)
331331

332332

333333
ball = structural_simplify(ball)

src/systems/validation.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,20 @@ function validate(jump::ModelingToolkit.MassActionJump, t::Symbolic; info::Strin
173173
left_symbols = [x[1] for x in jump.reactant_stoch] #vector of pairs of symbol,int -> vector symbols
174174
net_symbols = [x[1] for x in jump.net_stoch]
175175
all_symbols = vcat(left_symbols,net_symbols)
176-
allgood = _validate(all_symbols, string.(all_symbols), info = info)
176+
allgood = _validate(all_symbols, string.(all_symbols); info)
177177
n = sum(x->x[2],jump.reactant_stoch,init = 0)
178178
base_unitful = all_symbols[1] #all same, get first
179-
allgood && _validate([jump.scaled_rates, 1/(t*base_unitful^n)], ["scaled_rates", "1/(t*reactants^$n))"], info = info)
179+
allgood && _validate([jump.scaled_rates, 1/(t*base_unitful^n)], ["scaled_rates", "1/(t*reactants^$n))"]; info)
180180
end
181181

182182
function validate(jumps::ArrayPartition{<:Union{Any, Vector{<:JumpType}}}, t::Symbolic)
183183
labels = ["in Mass Action Jumps,", "in Constant Rate Jumps,", "in Variable Rate Jumps,"]
184184
all([validate(jumps.x[idx], t, info = labels[idx]) for idx in 1:3])
185185
end
186186

187-
validate(eq::ModelingToolkit.Equation; info::String = "") = _validate([eq.lhs, eq.rhs], ["left", "right"], info = info)
188-
validate(eq::ModelingToolkit.Equation, term::Union{Symbolic,Unitful.Quantity,Num}; info::String = "") = _validate([eq.lhs, eq.rhs, term], ["left","right","noise"], info = info)
189-
validate(eq::ModelingToolkit.Equation, terms::Vector; info::String = "") = _validate(vcat([eq.lhs, eq.rhs], terms), vcat(["left", "right"], "noise #".*string.(1:length(terms))), info = info)
187+
validate(eq::ModelingToolkit.Equation; info::String = "") = _validate([eq.lhs, eq.rhs], ["left", "right"]; info)
188+
validate(eq::ModelingToolkit.Equation, term::Union{Symbolic,Unitful.Quantity,Num}; info::String = "") = _validate([eq.lhs, eq.rhs, term], ["left","right","noise"]; info)
189+
validate(eq::ModelingToolkit.Equation, terms::Vector; info::String = "") = _validate(vcat([eq.lhs, eq.rhs], terms), vcat(["left", "right"], "noise #".*string.(1:length(terms))); info)
190190

191191
"Returns true iff units of equations are valid."
192192
validate(eqs::Vector; info::String = "") = all([validate(eqs[idx], info = info*" in eq. #$idx") for idx in 1:length(eqs)])

test/nonlinearsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ np = NonlinearProblem(ns, [0,0,0], [1,2,3], jac=true, sparse=true)
126126
@parameters a
127127
@variables x f
128128

129-
NonlinearSystem([0 ~ -a * x + f], [x,f], [a], name = name)
129+
NonlinearSystem([0 ~ -a * x + f], [x,f], [a]; name)
130130
end
131131

132132
function issue819()

test/odesystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ eq = D(x) ~ r*x
298298
@variables x(t) f(t)
299299
D = Differential(t)
300300

301-
ODESystem([D(x) ~ -a*x + f], name = name)
301+
ODESystem([D(x) ~ -a*x + f]; name)
302302
end
303303

304304
function issue808()

test/root_equations.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ continuous_events = [
232232
D(y) ~ vy
233233
D(vx) ~ -9.8
234234
D(vy) ~ -0.01vy # there is some small air resistance
235-
], t, continuous_events = continuous_events)
235+
], t; continuous_events)
236236

237237

238238

@@ -274,7 +274,7 @@ continuous_events = [
274274
D(y) ~ vy
275275
D(vx) ~ -1
276276
D(vy) ~ 0
277-
], t, continuous_events = continuous_events)
277+
], t; continuous_events)
278278

279279
ball = structural_simplify(ball)
280280

@@ -304,4 +304,4 @@ sys = structural_simplify(sys)
304304
prob = ODAEProblem(sys, zeros(2), (0.0, 5.1))
305305
sol = solve(prob, Tsit5())
306306
@test all(minimum((0:0.1:5) .- sol.t', dims=2) .< 0.0001) # test that the solver stepped every 0.1s as dictated by event
307-
@test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property
307+
@test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property

0 commit comments

Comments
 (0)