Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix nonnumeric parameters in @mtkmodel #3236

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading