Skip to content

Commit 283b34f

Browse files
Merge pull request #3803 from AayushSabharwal/as/fmt
refactor: format
2 parents 68c1d76 + dfdf491 commit 283b34f

File tree

5 files changed

+120
-57
lines changed

5 files changed

+120
-57
lines changed

docs/src/basics/Events.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ The basic purely symbolic continuous event interface to encode *one* continuous
9292
event is
9393

9494
```julia
95-
AbstractSystem(eqs, ...; continuous_events::Vector{Equation})
96-
AbstractSystem(eqs, ...; continuous_events::Pair{Vector{Equation}, Vector{Equation}})
95+
AbstractSystem(eqs, _...; continuous_events::Vector{Equation})
96+
AbstractSystem(eqs, _...; continuous_events::Pair{Vector{Equation}, Vector{Equation}})
9797
```
9898

9999
In the former, equations that evaluate to 0 will represent conditions that should
@@ -272,7 +272,7 @@ In addition to continuous events, discrete events are also supported. The
272272
general interface to represent a collection of discrete events is
273273

274274
```julia
275-
AbstractSystem(eqs, ...; discrete_events = [condition1 => affect1, condition2 => affect2])
275+
AbstractSystem(eqs, _...; discrete_events = [condition1 => affect1, condition2 => affect2])
276276
```
277277

278278
where conditions are symbolic expressions that should evaluate to `true` when an
@@ -497,7 +497,8 @@ so far we aren't using anything that's not possible with the implicit interface.
497497
You can also write
498498

499499
```julia
500-
[temp ~ furnace_off_threshold] => ModelingToolkit.ImperativeAffect(modified = (;
500+
[temp ~
501+
furnace_off_threshold] => ModelingToolkit.ImperativeAffect(modified = (;
501502
furnace_on)) do x, o, i, c
502503
@set! x.furnace_on = false
503504
end

docs/src/basics/FAQ.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ The same principle applies to any parameter type that is not `Float64`.
6363
@parameters p1::Int # integer-valued
6464
@parameters p2::Bool # boolean-valued
6565
@parameters p3::MyCustomStructType # non-numeric
66-
@parameters p4::ComponentArray{...} # non-standard array
66+
@parameters p4::ComponentArray{_...} # non-standard array
6767
```
6868

6969
## Getting the index for a symbol

docs/src/tutorials/linear_analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ This is signified by the name being the middle argument to `connect`.
3939
Of the above mentioned functions, all except for [`open_loop`](@ref) return the output of [`ModelingToolkit.linearize`](@ref), which is
4040

4141
```julia
42-
matrices, simplified_sys = linearize(...)
42+
matrices, simplified_sys = linearize(_...)
4343
# matrices = (; A, B, C, D)
4444
```
4545

src/systems/diffeqs/basic_transformations.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,25 @@ new_sol = solve(new_prob, Tsit5())
9494
9595
"""
9696
function change_of_variables(
97-
sys::System, iv, forward_subs, backward_subs;
98-
simplify=true, t0=missing, isSDE=false
97+
sys::System, iv, forward_subs, backward_subs;
98+
simplify = true, t0 = missing, isSDE = false
9999
)
100100
t = iv
101101

102102
old_vars = first.(backward_subs)
103103
new_vars = last.(forward_subs)
104-
104+
105105
# use: f = Y(t, X)
106106
# use: dY = (∂f/∂t + μ∂f/∂x + (1/2)*σ^2*∂2f/∂x2)dt + σ∂f/∂xdW
107107
old_eqs = equations(sys)
108108
neqs = get_noise_eqs(sys)
109109
brownvars = brownians(sys)
110-
111-
110+
112111
if neqs === nothing && length(brownvars) === 0
113112
neqs = ones(1, length(old_eqs))
114113
elseif neqs !== nothing
115114
isSDE = true
116-
neqs = [neqs[i,:] for i in 1:size(neqs,1)]
115+
neqs = [neqs[i, :] for i in 1:size(neqs, 1)]
117116

118117
brownvars = map([Symbol(:B, :_, i) for i in 1:length(neqs[1])]) do name
119118
unwrap(only(@brownians $name))
@@ -135,9 +134,10 @@ function change_of_variables(
135134
end
136135

137136
# df/dt = ∂f/∂x dx/dt + ∂f/∂t
138-
dfdt = Symbolics.derivative( first.(forward_subs), t )
139-
∂f∂x = [Symbolics.derivative( first(f_sub), old_var ) for (f_sub, old_var) in zip(forward_subs, old_vars)]
140-
∂2f∂x2 = Symbolics.derivative.( ∂f∂x, old_vars )
137+
dfdt = Symbolics.derivative(first.(forward_subs), t)
138+
∂f∂x = [Symbolics.derivative(first(f_sub), old_var)
139+
for (f_sub, old_var) in zip(forward_subs, old_vars)]
140+
∂2f∂x2 = Symbolics.derivative.(∂f∂x, old_vars)
141141
new_eqs = Equation[]
142142

143143
for (new_var, ex, first, second) in zip(new_vars, dfdt, ∂f∂x, ∂2f∂x2)
@@ -154,7 +154,7 @@ function change_of_variables(
154154
ex = substitute(ex, Dict(forward_subs))
155155
ex = substitute(ex, Dict(backward_subs))
156156
if simplify
157-
ex = Symbolics.simplify(ex, expand=true)
157+
ex = Symbolics.simplify(ex, expand = true)
158158
end
159159
push!(new_eqs, Differential(t)(new_var) ~ ex)
160160
end
@@ -174,10 +174,11 @@ function change_of_variables(
174174
end
175175
end
176176

177-
@named new_sys = System(vcat(new_eqs, first.(backward_subs) .~ last.(backward_subs)), t;
178-
defaults=new_defs,
179-
observed=observed(sys)
180-
)
177+
@named new_sys = System(
178+
vcat(new_eqs, first.(backward_subs) .~ last.(backward_subs)), t;
179+
defaults = new_defs,
180+
observed = observed(sys)
181+
)
181182
if simplify
182183
return mtkcompile(new_sys)
183184
end
@@ -570,7 +571,8 @@ All accumulation variables have a default of zero.
570571
function add_accumulations(sys::System, vars::Vector{<:Pair})
571572
eqs = get_eqs(sys)
572573
avars = map(first, vars)
573-
if (ints = intersect(avars, unknowns(sys)); !isempty(ints))
574+
ints = intersect(avars, unknowns(sys))
575+
if !isempty(ints)
574576
error("$ints already exist in the system!")
575577
end
576578
D = Differential(get_iv(sys))

0 commit comments

Comments
 (0)