Skip to content

Commit

Permalink
test: test @mtkmodel array variables, default namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Sep 20, 2024
1 parent ac88d49 commit ed71a6b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using ModelingToolkit: get_connector_type, get_defaults, get_gui_metadata,
get_systems, get_ps, getdefault, getname, readable_code,
scalarize, symtype, VariableDescription, RegularConnector,
get_unit
using SymbolicIndexingInterface
using URIs: URI
using Distributions
using DynamicQuantities, OrdinaryDiffEq
Expand Down Expand Up @@ -876,3 +877,26 @@ end
end),
false)
end

@testset "Array parameters and subcomponent defaults" begin
@mtkmodel Foo begin
@parameters begin
p[1:3]
end
end
@mtkmodel Bar begin
@parameters begin
q[1:3]
end
@components begin
foo = Foo(p = q)
end
end
@named model = Bar()
model = complete(model)
# non-scalarized versions are parameters
@test is_parameter(model, model.q)
@test is_parameter(model, model.foo.p)
# default is correctly (not) namespaced
@test ModelingToolkit.defaults(model)[model.foo.p] == model.q
end

0 comments on commit ed71a6b

Please sign in to comment.