@@ -93,18 +93,24 @@ function _collect_differentials!(found, ex)
93
93
end
94
94
95
95
"""
96
- getproperty_symbolic(sys, var)
96
+ getproperty_symbolic(sys, var; might_contain_toplevel_ns=true )
97
97
98
98
Like `getproperty` but works on a greater varaity of "var"
99
99
- var can be Num or Symbolic (resolved using genname)
100
- - strip namespace of sys if present
100
+ - strip namespace of sys if present (don't strip if `might_contain_top_level_ns=false`)
101
101
- for nested variables (foo₊bar₊baz) resolve them one by one
102
102
"""
103
- function getproperty_symbolic (sys, var)
103
+ function getproperty_symbolic (sys, var; might_contain_toplevel_ns = true )
104
104
ns = string (getname (sys))
105
105
varname = string (getname (var))
106
- varname_nons = replace (varname, r" ^" * ns* " ₊" => " " )
107
- parts = split (varname_nons, " ₊" )
106
+ # split of the toplevel namespace if necessary
107
+ if might_contain_toplevel_ns && startswith (varname, ns* " ₊" )
108
+ if getname (sys) ∈ getname .(ModelingToolkit. get_systems (sys))
109
+ @warn " Namespace :$ns appears multiple times, this might lead to unexpected, since it is not clear whether the namespace should be stripped or not."
110
+ end
111
+ varname = replace (varname, r" ^" * ns* " ₊" => " " )
112
+ end
113
+ parts = split (varname, " ₊" )
108
114
r = getproperty (sys, Symbol (parts[1 ]); namespace= false )
109
115
for part in parts[2 : end ]
110
116
r = getproperty (r, Symbol (part); namespace= true )
0 commit comments