File tree Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Expand file tree Collapse file tree 2 files changed +20
-12
lines changed Original file line number Diff line number Diff line change @@ -445,20 +445,10 @@ function build_explicit_observed_function(sys, ts;
445
445
end
446
446
447
447
allsyms = all_symbols (sys)
448
- function symbol_to_symbolic (sym)
449
- sym isa Symbol || return sym
450
- idx = findfirst (x -> (hasname (x) ? getname (x) : Symbol (x)) == sym, allsyms)
451
- idx === nothing && return sym
452
- sym = allsyms[idx]
453
- if iscall (sym) && operation (sym) == getindex
454
- sym = arguments (sym)[1 ]
455
- end
456
- return sym
457
- end
458
448
if symbolic_type (ts) == NotSymbolic () && ts isa AbstractArray
459
- ts = map (symbol_to_symbolic, ts)
449
+ ts = map (x -> symbol_to_symbolic (sys, x; allsyms) , ts)
460
450
else
461
- ts = symbol_to_symbolic (ts )
451
+ ts = symbol_to_symbolic (sys, ts; allsyms )
462
452
end
463
453
464
454
vs = ModelingToolkit. vars (ts; op)
Original file line number Diff line number Diff line change @@ -1249,3 +1249,21 @@ function process_equations(eqs, iv)
1249
1249
1250
1250
diffvars, allunknowns, ps, Equation[diffeq; algeeq; compressed_eqs]
1251
1251
end
1252
+
1253
+ """
1254
+ $(TYPEDSIGNATURES)
1255
+
1256
+ If `sym isa Symbol`, try and convert it to a symbolic by matching against symbolic
1257
+ variables in `allsyms`. If `sym` is not a `Symbol` or no match was found, return
1258
+ `sym` as-is.
1259
+ """
1260
+ function symbol_to_symbolic (sys:: AbstractSystem , sym; allsyms = all_symbols (sys))
1261
+ sym isa Symbol || return sym
1262
+ idx = findfirst (x -> (hasname (x) ? getname (x) : Symbol (x)) == sym, allsyms)
1263
+ idx === nothing && return sym
1264
+ sym = allsyms[idx]
1265
+ if iscall (sym) && operation (sym) == getindex
1266
+ sym = arguments (sym)[1 ]
1267
+ end
1268
+ return sym
1269
+ end
You can’t perform that action at this time.
0 commit comments