Metadata

Symbolics.jl provides a metadata system for attaching additional information to symbolic variables. This system allows for extensible annotations that can be used to store default values, source information, and custom user-defined metadata.

Using Metadata

Metadata can be attached to variables when they are created with the @variables macro. Common metadata includes default values and other annotations:

using Symbolics

# Variable with default value
@variables x=1.0 y=2.0

# Variables with custom metadata (once registered)
@variables z [description="Temperature in Kelvin"]

Extending Metadata

You can define custom metadata types for use with the @variables macro by defining a new metadata type and registering it:

using Symbolics

# Define a custom metadata type
struct MyCustomMetadata <: Symbolics.AbstractVariableMetadata end

# Register it for use in @variables
Symbolics.option_to_metadata_type(::Val{:my_custom}) = MyCustomMetadata

# Now you can use it
@variables x [my_custom = "some value"]

Metadata API

Symbolics.VariableDefaultValueType
struct VariableDefaultValue <: Symbolics.AbstractVariableMetadata

Symbolic metadata key for storing the default value of a symbolic variable.

source
Symbolics.VariableSourceType
struct VariableSource <: Symbolics.AbstractVariableMetadata

Symbolic metadata key for storing the macro used to create a symbolic variable.

source
Missing docstring.

Missing docstring for Symbolics.CallWithMetadata. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Symbolics.Unknown. Check Documenter's build log for details.

Symbolics.option_to_metadata_typeFunction
option_to_metadata_type(
    _::Val{opt}
) -> Type{Symbolics.SymLatexWrapper}

Define a new metadata key assignable in @variables. This function should take Val{name} where name is a Symbol, and return the key type for the given metadata name name. For example,

Symbolics.option_to_metadata_type(::Val{:custom_name}) = CustomType

Allows the following syntax:

@variables x [custom_name = 1]

And stores 1 as the value associated with the CustomType key in the symbolic metadata of x.

source