You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like there are some cases in which get_variables drops variable metadata, leading to the variables that are return to not be isequal to the original ones. This seems to be the case for callables, which are currently generated by the @mtkmodel macro as pointed out in #1364 (comment).
MWE
using Symbolics
@variables t x(..)
x =x(t)
Symbolics.get_variables(x +1)
# 2-element Vector{SymbolicUtils.BasicSymbolic}:# x# tisequal(Symbolics.get_variables(x +1)[1], Symbolics.value(x)) # false
Symbolics.metadata(Symbolics.value(x))
# Base.ImmutableDict{DataType, Any} with 2 entries:# CallWithParent => x⋆# VariableSource => (:variables, :x)
Symbolics.metadata(Symbolics.get_variables(x +1)[1]) # nothing
While SciML/ModelingToolkit.jl#3217 could help avoid the issue for @mtkmodel based systems, I would expect the metadata to still be there.
The text was updated successfully, but these errors were encountered:
Yeah so #1361 made get_variables search inside x(t) IF x is declared as @variables x(..). Previously, get_variables would return x(t) and now it returns x(..) and t. The problem is that when x(..) is called, the metadata is attached to the called object x(t) and not to the function x(..). The consensus from #1364 was that get_variables should be reverted and the MTK functions should get a kwarg for the search function to use. I'll make this change
It looks like there are some cases in which
get_variables
drops variable metadata, leading to the variables that are return to not beisequal
to the original ones. This seems to be the case for callables, which are currently generated by the@mtkmodel
macro as pointed out in #1364 (comment).MWE
While SciML/ModelingToolkit.jl#3217 could help avoid the issue for
@mtkmodel
based systems, I would expect the metadata to still be there.The text was updated successfully, but these errors were encountered: