Skip to content

Commit 3542211

Browse files
fix: handle inputs and outputs in flatten(::System)
1 parent 4ea87f1 commit 3542211

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/systems/system.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
344344
continuous_events = SymbolicContinuousCallback[], discrete_events = SymbolicDiscreteCallback[],
345345
connector_type = nothing, assertions = Dict{BasicSymbolic, String}(),
346346
metadata = MetadataT(), gui_metadata = nothing,
347-
is_dde = nothing, tstops = [], tearing_state = nothing,
347+
is_dde = nothing, tstops = [], inputs = OrderedSet{BasicSymbolic}(),
348+
outputs = OrderedSet{BasicSymbolic}(), tearing_state = nothing,
348349
ignored_connections = nothing, parent = nothing,
349350
description = "", name = nothing, discover_from_metadata = true,
350351
initializesystem = nothing, is_initializesystem = false, is_discrete = false,
@@ -379,8 +380,8 @@ function System(eqs::Vector{Equation}, iv, dvs, ps, brownians = [];
379380

380381
defaults = anydict(defaults)
381382
guesses = anydict(guesses)
382-
inputs = OrderedSet{BasicSymbolic}()
383-
outputs = OrderedSet{BasicSymbolic}()
383+
inputs = OrderedSet{BasicSymbolic}(inputs)
384+
outputs = OrderedSet{BasicSymbolic}(outputs)
384385
for subsys in systems
385386
for var in ModelingToolkit.inputs(subsys)
386387
push!(inputs, renamespace(subsys, var))
@@ -764,6 +765,7 @@ function flatten(sys::System, noeqs = false)
764765
discrete_events = discrete_events(sys), assertions = assertions(sys),
765766
is_dde = is_dde(sys), tstops = symbolic_tstops(sys),
766767
initialization_eqs = initialization_equations(sys),
768+
inputs = inputs(sys), outputs = outputs(sys),
767769
# without this, any defaults/guesses obtained from metadata that were
768770
# later removed by the user will be re-added. Right now, we just want to
769771
# retain `defaults(sys)` as-is.

0 commit comments

Comments
 (0)