File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ using SymbolicUtils: issym
99using ForwardDiff
1010using ModelingToolkit: value
1111using ModelingToolkit: t_nounits as t, D_nounits as D
12+ using Symbolics: unwrap
1213
1314# Define some variables
1415@parameters σ ρ β
@@ -1730,3 +1731,26 @@ end
17301731 @test obsfn_expr_oop isa Expr
17311732 @test obsfn_expr_iip isa Expr
17321733end
1734+
1735+ @testset " `@named` always wraps in `ParentScope`" begin
1736+ function SysA (; name, var1)
1737+ @variables x (t)
1738+ scope = ModelingToolkit. getmetadata (unwrap (var1), ModelingToolkit. SymScope, nothing )
1739+ @test scope isa ParentScope
1740+ @test scope. parent isa ParentScope
1741+ @test scope. parent. parent isa LocalScope
1742+ return ODESystem (D (x) ~ var1, t; name)
1743+ end
1744+ function SysB (; name, var1)
1745+ @variables x (t)
1746+ @named subsys = SysA (; var1)
1747+ return ODESystem (D (x) ~ x, t; systems = [subsys], name)
1748+ end
1749+ function SysC (; name)
1750+ @variables x (t)
1751+ @named subsys = SysB (; var1 = x)
1752+ return ODESystem (D (x) ~ x, t; systems = [subsys], name)
1753+ end
1754+ @mtkbuild sys = SysC ()
1755+ @test length (unknowns (sys)) == 3
1756+ end
You can’t perform that action at this time.
0 commit comments