Skip to content

Commit

Permalink
Merge pull request #3236 from AayushSabharwal/as/mtkmodel-nonnumeric-…
Browse files Browse the repository at this point in the history
…params

fix: fix nonnumeric parameters in `@mtkmodel`
  • Loading branch information
ChrisRackauckas authored Nov 25, 2024
2 parents ac39aab + d0748e6 commit a62fe60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/systems/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ function parse_variable_arg(dict, mod, arg, varclass, kwargs, where_types)
end

push!(varexpr.args, metadata_expr)
return vv isa Num ? name : :($name...), varexpr
return symbolic_type(vv) == ScalarSymbolic() ? name : :($name...), varexpr
else
return vv
end
Expand Down
11 changes: 11 additions & 0 deletions test/model_parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -979,3 +979,14 @@ end
@test MultipleExtend.structure[:extend][1] == [:inmodel, :b, :inmodel_b]
@test tosymbol.(parameters(multiple_extend)) == [:b, :inmodel_b₊p, :inmodel₊p]
end

struct CustomStruct end
@testset "Nonnumeric parameters" begin
@mtkmodel MyModel begin
@parameters begin
p::CustomStruct
end
end
@named sys = MyModel(p = CustomStruct())
@test ModelingToolkit.defaults(sys)[@nonamespace sys.p] == CustomStruct()
end

0 comments on commit a62fe60

Please sign in to comment.