Specifying arbitrary metadata
Is your feature request related to a problem? Please describe.
@mtkmodel is great, and I would like to use it to encode several user-specific metadata properties (for instance, I'd like to specify the DCS tag name corresponding to some variable).
I don't particularly care about this metadata being efficiently stored / accessed.
Describe the solution you’d like
I'd like to have syntax for arbitrary metadata. It is already possible to do it with misc
@parameters tau [misc=(; link="myurl", specifity=30)]
but that's not elegant, and hard to read for non-programmers. Ideally, I'd like:
@parameters tau [link="myurl", specifity=30]
that expands to @parameters tau [misc=(; link="myurl", specifity=30)], with some accessor like getmisc(tau, :link). In other words, all unknown parameters become misc named tuple fields.
Describe alternatives you’ve considered
@parameters tau [misc_link="myurl", misc_specifity=30]
would be uglier, but it would perhaps be more palatable for MTK.
Additional context
This is a straight-forward change, and I'd be happy to provide a PR if this is considered desirable. I get that this is breaking-ish.
This is functionality that Symbolics provides. You are free to define your own metadata keys by
- defining a type associated with the metadata key. So
abstract type MiscLink endandabstract type MiscSpecificity end Symbolics.option_to_metadata_type(::Val{:misc_link}) = MiscLinkand similarly for:misc_specificity
Then the syntax you want will work. The metadata will be available using SymbolicUtils.getmetadata(tau, MiscLink, nothing)
Awesome, exactly what we need! If it's in the documentation then we should close this issue, but I couldn't find it here or in Symbolics.jl.
Doesn't look like it is surfaced anywhere. I'll add the relevant docs.