Skip to content

Commit df4b7e5

Browse files
Merge pull request #2405 from isaacsas/fix_some_warnings
Fix some warnings
2 parents 23323bc + 55d95ae commit df4b7e5

File tree

7 files changed

+36
-29
lines changed

7 files changed

+36
-29
lines changed

ext/MTKBifurcationKitExt.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ struct ObservableRecordFromSolution{S, T}
3434
param_end_idxs = state_end_idxs + length(parameters(nsys))
3535

3636
bif_par_idx = state_end_idxs + bif_idx
37-
# Gets the (base) substitution values for states.
37+
# Gets the (base) substitution values for states.
3838
subs_vals_states = Pair.(states(nsys), u0_vals)
39-
# Gets the (base) substitution values for parameters.
39+
# Gets the (base) substitution values for parameters.
4040
subs_vals_params = Pair.(parameters(nsys), p_vals)
41-
# Gets the (base) substitution values for observables.
41+
# Gets the (base) substitution values for observables.
4242
subs_vals_obs = [obs.lhs => substitute(obs.rhs,
4343
[subs_vals_states; subs_vals_params]) for obs in observed(nsys)]
4444
# Sometimes observables depend on other observables, hence we make a second update to this vector.
@@ -136,7 +136,7 @@ function BifurcationKit.BifurcationProblem(osys::ODESystem, args...; kwargs...)
136136
nsys = NonlinearSystem([0 ~ eq.rhs for eq in equations(osys)],
137137
states(osys),
138138
parameters(osys);
139-
name = osys.name)
139+
name = nameof(osys))
140140
return BifurcationKit.BifurcationProblem(nsys, args...; kwargs...)
141141
end
142142

src/parameters.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function split_parameters_by_type(ps)
102102
split_ps = tighten_types.(Base.Fix1(getindex, ps).(split_idxs))
103103

104104
if ps isa StaticArray
105-
parrs = map(x-> SArray{Tuple{size(x)...}}(x), split_ps)
105+
parrs = map(x -> SArray{Tuple{size(x)...}}(x), split_ps)
106106
split_ps = SArray{Tuple{size(parrs)...}}(parrs)
107107
end
108108
if length(split_ps) == 1 #Tuple not needed, only 1 type

src/systems/abstractsystem.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ end
194194
function SymbolicIndexingInterface.is_variable(sys::AbstractSystem, sym::Symbol)
195195
return any(isequal(sym), getname.(variable_symbols(sys))) ||
196196
count('', string(sym)) == 1 &&
197-
count(isequal(sym), Symbol.(sys.name, :₊, getname.(variable_symbols(sys)))) == 1
197+
count(isequal(sym), Symbol.(nameof(sys), :₊, getname.(variable_symbols(sys)))) ==
198+
1
198199
end
199200

200201
function SymbolicIndexingInterface.variable_index(sys::AbstractSystem, sym)
@@ -213,7 +214,8 @@ function SymbolicIndexingInterface.variable_index(sys::AbstractSystem, sym::Symb
213214
if idx !== nothing
214215
return idx
215216
elseif count('', string(sym)) == 1
216-
return findfirst(isequal(sym), Symbol.(sys.name, :₊, getname.(variable_symbols(sys))))
217+
return findfirst(isequal(sym),
218+
Symbol.(nameof(sys), :₊, getname.(variable_symbols(sys))))
217219
end
218220
return nothing
219221
end
@@ -236,7 +238,8 @@ end
236238
function SymbolicIndexingInterface.is_parameter(sys::AbstractSystem, sym::Symbol)
237239
return any(isequal(sym), getname.(parameter_symbols(sys))) ||
238240
count('', string(sym)) == 1 &&
239-
count(isequal(sym), Symbol.(sys.name, :₊, getname.(parameter_symbols(sys)))) == 1
241+
count(isequal(sym),
242+
Symbol.(nameof(sys), :₊, getname.(parameter_symbols(sys)))) == 1
240243
end
241244

242245
function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym)
@@ -255,7 +258,8 @@ function SymbolicIndexingInterface.parameter_index(sys::AbstractSystem, sym::Sym
255258
if idx !== nothing
256259
return idx
257260
elseif count('', string(sym)) == 1
258-
return findfirst(isequal(sym), Symbol.(sys.name, :₊, getname.(parameter_symbols(sys))))
261+
return findfirst(isequal(sym),
262+
Symbol.(nameof(sys), :₊, getname.(parameter_symbols(sys))))
259263
end
260264
return nothing
261265
end
@@ -656,7 +660,7 @@ function states(sys::AbstractSystem)
656660
end
657661
isempty(nonunique_states) && return nonunique_states
658662
# `Vector{Any}` is incompatible with the `SymbolicIndexingInterface`, which uses
659-
# `elsymtype = symbolic_type(eltype(_arg))`
663+
# `elsymtype = symbolic_type(eltype(_arg))`
660664
# which inappropriately returns `NotSymbolic()`
661665
if nonunique_states isa Vector{Any}
662666
nonunique_states = _nonum.(nonunique_states)

src/systems/diffeqs/abstractodesystem.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,10 @@ function DiffEqBase.ODEProblem(sys::AbstractODESystem, args...; kwargs...)
912912
ODEProblem{true}(sys, args...; kwargs...)
913913
end
914914

915-
function DiffEqBase.ODEProblem(sys::AbstractODESystem, u0map::StaticArray, args...; kwargs...)
915+
function DiffEqBase.ODEProblem(sys::AbstractODESystem,
916+
u0map::StaticArray,
917+
args...;
918+
kwargs...)
916919
ODEProblem{false, SciMLBase.FullSpecialize}(sys, u0map, args...; kwargs...)
917920
end
918921

src/variables.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ function varmap_to_vars(varmap, varlist; defaults = Dict(), check = true,
8484
container_type = Array
8585
end
8686

87-
@show container_type
88-
8987
vals = if eltype(varmap) <: Pair # `varmap` is a dict or an array of pairs
9088
varmap = todict(varmap)
9189
_varmap_to_vars(varmap, varlist; defaults = defaults, check = check,

test/inversemodel.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ sol = solve(prob, Rodas5P())
145145
# plot(sol, idxs=[model.tank.xc, model.tank.xT, model.controller.ctr_output.u], layout=3, sp=[1 2 3])
146146
# hline!([prob[cm.ref.k]], label="ref", sp=1)
147147

148-
@test sol(tspan[2], idxs = cm.tank.xc) getp(prob, cm.ref.k)(prob) atol=1e-2 # Test that the inverse model led to the correct reference
148+
@test sol(tspan[2], idxs = cm.tank.xc)getp(prob, cm.ref.k)(prob) atol=1e-2 # Test that the inverse model led to the correct reference
149149

150150
Sf, simplified_sys = Blocks.get_sensitivity_function(model, :y) # This should work without providing an operating opint containing a dummy derivative
151151
x, p = ModelingToolkit.get_u0_p(simplified_sys, op)

test/symbolic_indexing_interface.jl

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ eqs = [D(x) ~ a * y + t, D(y) ~ b * t]
88

99
@test all(is_variable.((odesys,), [x, y, 1, 2, :x, :y]))
1010
@test all(.!is_variable.((odesys,), [a, b, t, 3, 0, :a, :b]))
11-
@test variable_index.((odesys,), [x, y, a, b, t, 1, 2, :x, :y, :a, :b]) == [1, 2, nothing, nothing, nothing, 1, 2, 1, 2, nothing, nothing]
11+
@test variable_index.((odesys,), [x, y, a, b, t, 1, 2, :x, :y, :a, :b]) ==
12+
[1, 2, nothing, nothing, nothing, 1, 2, 1, 2, nothing, nothing]
1213
@test isequal(variable_symbols(odesys), [x, y])
1314
@test all(is_parameter.((odesys,), [a, b, 1, 2, :a, :b]))
1415
@test all(.!is_parameter.((odesys,), [x, y, t, 3, 0, :x, :y]))
15-
@test parameter_index.((odesys,), [x, y, a, b, t, 1, 2, :x, :y, :a, :b]) == [nothing, nothing, 1, 2, nothing, 1, 2, nothing, nothing, 1, 2]
16+
@test parameter_index.((odesys,), [x, y, a, b, t, 1, 2, :x, :y, :a, :b]) ==
17+
[nothing, nothing, 1, 2, nothing, 1, 2, nothing, nothing, 1, 2]
1618
@test isequal(parameter_symbols(odesys), [a, b])
1719
@test all(is_independent_variable.((odesys,), [t, :t]))
1820
@test all(.!is_independent_variable.((odesys,), [x, y, a, :x, :y, :a]))
@@ -23,10 +25,10 @@ eqs = [D(x) ~ a * y + t, D(y) ~ b * t]
2325
@variables x y z
2426
@parameters σ ρ β
2527

26-
eqs = [0 ~ σ*(y-x),
27-
0 ~ x*-z)-y,
28-
0 ~ x*y - β*z]
29-
@named ns = NonlinearSystem(eqs, [x,y,z],[σ,ρ,β])
28+
eqs = [0 ~ σ * (y - x),
29+
0 ~ x *- z) - y,
30+
0 ~ x * y - β * z]
31+
@named ns = NonlinearSystem(eqs, [x, y, z], [σ, ρ, β])
3032

3133
@test !is_time_dependent(ns)
3234

@@ -37,20 +39,20 @@ Dtt = Differential(t)^2
3739
Dt = Differential(t)
3840

3941
#2D PDE
40-
C=1
41-
eq = Dtt(u(t,x)) ~ C^2*Dxx(u(t,x))
42+
C = 1
43+
eq = Dtt(u(t, x)) ~ C^2 * Dxx(u(t, x))
4244

4345
# Initial and boundary conditions
44-
bcs = [u(t,0) ~ 0.,# for all t > 0
45-
u(t,1) ~ 0.,# for all t > 0
46-
u(0,x) ~ x*(1. - x), #for all 0 < x < 1
47-
Dt(u(0,x)) ~ 0. ] #for all 0 < x < 1]
46+
bcs = [u(t, 0) ~ 0.0,# for all t > 0
47+
u(t, 1) ~ 0.0,# for all t > 0
48+
u(0, x) ~ x * (1.0 - x), #for all 0 < x < 1
49+
Dt(u(0, x)) ~ 0.0] #for all 0 < x < 1]
4850

4951
# Space and time domains
50-
domains = [t (0.0,1.0),
51-
x (0.0,1.0)]
52+
domains = [t (0.0, 1.0),
53+
x (0.0, 1.0)]
5254

53-
@named pde_system = PDESystem(eq,bcs,domains,[t,x],[u])
55+
@named pde_system = PDESystem(eq, bcs, domains, [t, x], [u])
5456

5557
@test pde_system.ps == SciMLBase.NullParameters()
5658
@test parameter_symbols(pde_system) == []

0 commit comments

Comments
 (0)