You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/named_systems2.jl
+6-4Lines changed: 6 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -25,18 +25,20 @@ function check_all_unique(s1, s2; throw=true)
25
25
end
26
26
27
27
functiongenerate_unique_x_names(systems...)
28
-
x_names =[s.x for s in systems]
28
+
x_names =reduce(vcat, s.x for s in systems)
29
29
uniq =check_unique(x_names, "x", throw =false)
30
30
if uniq
31
31
return x_names
32
32
else
33
33
# For each system, if it has a name, append the system name to the x names. If neither system has a name, append gensym names to both systems' x names.
34
34
systemnames = [s.name for s in systems]
35
-
x_names =ifany(isempty(s.name) for s in systems) ||length(unique(systemnames)) <length(systemnames)
36
-
# Any name is empty or more than one system has the same name
35
+
x_names =ifcount(isempty(s.name) for s in systems) >1||length(unique(systemnames)) <length(systemnames)
36
+
# More than one system has empty name or more than one system has the same name
37
+
# We can handle one of the names being empty, which is a common case when the plant has a name but a controller/filter is auto promoted to a named system.
37
38
[gensym(string(x)) for x in x_names]
38
39
else
39
-
reduce(vcat, [[Symbol(string(s.name)*string(x)) for x in s.x] for s in systems])
40
+
# reduce(vcat, [[Symbol(string(s.name)*string(x)) for x in s.x] for s in systems])
41
+
[Symbol(string(s.name)*string(x)) for s in systems for x in s.x]
0 commit comments