-
-
Notifications
You must be signed in to change notification settings - Fork 231
Closed as not planned
Description
I have the problem that my symbols are detected as variables instead of parameters. This is due they not have the MTKVariableTypeCtx
metadata information. I could set by:
SymbolicUtils.setmetadata(s,MTK.MTKVariableTypeCtx,MTK.PARAMETER)
However, I would like my package to be independent of the ModelingToolkit dependency. I was wondering if in the isparameter
function in
ModelingToolkit.jl/src/parameters.jl
Lines 7 to 27 in 60c95b9
function isparameter(x) | |
x = unwrap(x) | |
if x isa Symbolic && (varT = getvariabletype(x, nothing)) !== nothing | |
return varT === PARAMETER | |
#TODO: Delete this branch | |
elseif x isa Symbolic && Symbolics.getparent(x, false) !== false | |
p = Symbolics.getparent(x) | |
isparameter(p) || | |
(hasmetadata(p, Symbolics.VariableSource) && | |
getmetadata(p, Symbolics.VariableSource)[1] == :parameters) | |
elseif iscall(x) && operation(x) isa Symbolic | |
varT === PARAMETER || isparameter(operation(x)) | |
elseif iscall(x) && operation(x) == (getindex) | |
isparameter(arguments(x)[1]) | |
elseif x isa Symbolic | |
varT === PARAMETER | |
else | |
false | |
end | |
end |
we could add an extra case which checks the Symbolics.VariableSource
metadata outside of the symbolic having a parent. That way symbolic parameters that were not made with MTK.@parameters
can still be used in ModelingToolkit.
Metadata
Metadata
Assignees
Labels
No labels