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