We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug 🐞
@parameters p3::MyCustomStructType works OK standalone, but fails with iteration error inside of @mtkmodel
@parameters p3::MyCustomStructType
@mtkmodel
Expected behavior
@parameters should work inside of @mtkmodel.
@parameters
Minimal Reproducible Example 👇
The docs claim that the line @parameters p3::MyCustomStructType # non-numeric should work. It seems to work stand-alone.
@parameters p3::MyCustomStructType # non-numeric
julia> struct MyCustomStructType end julia> @parameters p3::MyCustomStructType 1-element Vector{SymbolicUtils.BasicSymbolic{MyCustomStructType}}: p3
but fails inside of @mtkmodel
julia> @mtkmodel MyModel begin @parameters begin p3::MyCustomStructType end end ModelingToolkit.Model{typeof(__MyModel__), Dict{Symbol, Any}}(__MyModel__, Dict{Symbol, Any}(:kwargs => Dict{Symbol, Dict}(:p3 => Dict{Symbol, Union{Nothing, DataType}}(:value => nothing, :type => MyCustomStructType)), :independent_variable => t, :parameters => Dict{Symbol, Dict{Symbol, Any}}(:p3 => Dict(:type => MyCustomStructType))), false) julia> @named sys = MyModel(p3=MyCustomStructType()) ERROR: MethodError: no method matching iterate(::SymbolicUtils.BasicSymbolic{MyCustomStructType}) Closest candidates are: iterate(::LaTeXStrings.LaTeXString, ::Int64) @ LaTeXStrings C:\Users\\.julia\packages\LaTeXStrings\6NrIG\src\LaTeXStrings.jl:108 iterate(::LaTeXStrings.LaTeXString) @ LaTeXStrings C:\Users\\.julia\packages\LaTeXStrings\6NrIG\src\LaTeXStrings.jl:109 iterate(::DataStructures.TrieIterator) @ DataStructures C:\Users\\.julia\packages\DataStructures\95DJa\src\trie.jl:112 ... Stacktrace: [1] __MyModel__(; name::Symbol, p3::MyCustomStructType) @ Main C:\Users\\.julia\packages\ModelingToolkit\2hOLJ\src\systems\model_parsing.jl:914 [2] (::ModelingToolkit.Model{typeof(__MyModel__), Dict{Symbol, Any}})(; kw::@Kwargs{name::Symbol, p3::MyCustomStructType}) @ ModelingToolkit C:\Users\\.julia\packages\ModelingToolkit\2hOLJ\src\systems\model_parsing.jl:25 [3] top-level scope @ REPL[29]:1
Environment (please complete the following information):
Julia 1.10.5 MTK 9.52.0
Might be related to the work necessary for #3182
The text was updated successfully, but these errors were encountered:
As a work-around, I can make my MyCustomStructType iterable, and it seems to work.
MyCustomStructType
julia> Base.iterate(s::SymbolicUtils.BasicSymbolic{MyCustomStructType}, iter::Bool) = nothing julia> Base.iterate(s::SymbolicUtils.BasicSymbolic{MyCustomStructType}, iter::Nothing=nothing) = (s, false)
so it looks like the bug is "non-numeric objects should not be iterated"...?
Sorry, something went wrong.
AayushSabharwal
Successfully merging a pull request may close this issue.
Describe the bug 🐞
@parameters p3::MyCustomStructType
works OK standalone, but fails with iteration error inside of@mtkmodel
Expected behavior
@parameters
should work inside of@mtkmodel
.Minimal Reproducible Example 👇
The docs claim that the line
@parameters p3::MyCustomStructType # non-numeric
should work. It seems to work stand-alone.but fails inside of
@mtkmodel
Environment (please complete the following information):
Julia 1.10.5
MTK 9.52.0
Might be related to the work necessary for #3182
The text was updated successfully, but these errors were encountered: