@@ -3,6 +3,7 @@ using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata,
3
3
get_systems, get_ps, getdefault, getname, readable_code,
4
4
scalarize, symtype, VariableDescription, RegularConnector,
5
5
get_unit
6
+ using SymbolicIndexingInterface
6
7
using URIs: URI
7
8
using Distributions
8
9
using DynamicQuantities, OrdinaryDiffEq
245
246
kval = 5
246
247
@named model = MockModel (; b2 = [1 , 3 ], kval, cval = 1 , func = identity)
247
248
248
- @test lastindex (parameters (model)) == 31
249
+ @test lastindex (parameters (model)) == 21
249
250
250
251
@test all (getdescription .([model. e2... ]) .== " e2" )
251
252
@test all (getdescription .([model. h2... ]) .== " h2(t)" )
@@ -475,7 +476,7 @@ using ModelingToolkit: getdefault, scalarize
475
476
@named model_with_component_array = ModelWithComponentArray ()
476
477
477
478
@test eval (ModelWithComponentArray. structure[:parameters ][:r ][:unit ]) == eval (u " Ω" )
478
- @test lastindex (parameters (model_with_component_array)) == 3
479
+ @test lastindex (parameters (model_with_component_array)) == 1
479
480
480
481
# Test the constant `k`. Manually k's value should be kept in sync here
481
482
# and the ModelParsingPrecompile.
876
877
end ),
877
878
false )
878
879
end
880
+
881
+ @testset " Array parameters and subcomponent defaults" begin
882
+ @mtkmodel Foo begin
883
+ @parameters begin
884
+ p[1 : 3 ]
885
+ end
886
+ end
887
+ @mtkmodel Bar begin
888
+ @parameters begin
889
+ q[1 : 3 ]
890
+ end
891
+ @components begin
892
+ foo = Foo (p = q)
893
+ end
894
+ end
895
+ @named model = Bar ()
896
+ model = complete (model)
897
+ # non-scalarized versions are parameters
898
+ @test is_parameter (model, model. q)
899
+ @test is_parameter (model, model. foo. p)
900
+ # default is correctly (not) namespaced
901
+ @test isequal (ModelingToolkit. defaults (model)[model. foo. p], model. q)
902
+ end
0 commit comments