@@ -3,6 +3,7 @@ using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata,
33                       get_systems, get_ps, getdefault, getname, readable_code,
44                       scalarize, symtype, VariableDescription, RegularConnector,
55                       get_unit
6+ using  SymbolicIndexingInterface
67using  URIs:  URI
78using  Distributions
89using  DynamicQuantities, OrdinaryDiffEq
245246    kval =  5 
246247    @named  model =  MockModel (; b2 =  [1 , 3 ], kval, cval =  1 , func =  identity)
247248
248-     @test  lastindex (parameters (model)) ==  31 
249+     @test  lastindex (parameters (model)) ==  21 
249250
250251    @test  all (getdescription .([model. e2... ]) .==  " e2" 
251252    @test  all (getdescription .([model. h2... ]) .==  " h2(t)" 
@@ -475,7 +476,7 @@ using ModelingToolkit: getdefault, scalarize
475476    @named  model_with_component_array =  ModelWithComponentArray ()
476477
477478    @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 
479480
480481    #  Test the constant `k`. Manually k's value should be kept in sync here
481482    #  and the ModelParsingPrecompile.
876877        end ),
877878        false )
878879end 
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