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

Metadata of Term changes in substitution #283

Closed
hexaeder opened this issue Apr 19, 2021 · 1 comment · Fixed by #284
Closed

Metadata of Term changes in substitution #283

hexaeder opened this issue Apr 19, 2021 · 1 comment · Fixed by #284

Comments

@hexaeder
Copy link

hexaeder commented Apr 19, 2021

using SymbolicUtils
using SymbolicUtils: Term
@syms a b f t
f = Term(f, (t,)) # create term f(t)
f = setmetadata(f, Bool, true)
hasmetadata(f, Bool) # true
newf = substitute(f, Dict(a=>b)) # unrelated substitution
hasmetadata(newf, Bool) # false

I think this is a M(not)WE for SymbolicUtils. The problem came up after recent changes to MTK SciML/ModelingToolkit.jl/pull/943

using ModelingToolkit
using ModelingToolkit: isparameter
@parameters t a(t)
@variables x(t) y(t)
isparameter(a) # true
isparameter(substitute(a, x=>y)) # false :(
@shashi
Copy link
Member

shashi commented Apr 19, 2021

Oh I see... I think we should use similarterm in substitute and it should carry forward metadata of the "reference" term... via a kwarg so that it can be overloaded. cc @YingboMa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants