[ModelingToolkit] [Symbolics] Symbolic parameter metadata is erased if parameter is of type Term

Hey guys,

not sure if the title was clear enough but I’ll try to illustrate the issue with code.

The code:

@parameters p[1:2]  u 

u = GlobalScope(u) #so parameter u will not be namescoped when one uses 'compose'
p = Symbolics.scalarize(p)
GlobalScope(p) #my GlobalScope version that intends to achieve the same but with array variables

pvec = [p;u] #this is what is supplied to the ODESystem constructor

pvec_ = Symbolics.value.(Symbolics.scalarize(pvec)) #this is run at some point inside the constructor

A first good question is how to add the GlobalScope() property to array variables. I figured that array variables are not used as defined but they have to be scalarized to a vector of Term variables and one can use the same mechanism to provide the GlobalScope property.

When adding all parameters to the ODESystem one creates a vector with both array and non-array parameters. Somewhere inside the constructor, the line pvec_ = Symbolics.value.(Symbolics.scalarize(pvec)). My question is why does the metadata of Term type parameters gets erased while the Sym type parameters is not.