Skip to content

Commit bece61a

Browse files
refactor: format
1 parent 190dbd4 commit bece61a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/src/basics/Variable_metadata.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
5656
@variables k(t) [connect = Stream]
5757
hasconnect(i)
5858
```
59+
5960
```@example connect
6061
getconnect(k)
6162
```
@@ -197,12 +198,13 @@ state_priority(important_dof)
197198

198199
## Units
199200

200-
Units for variables can be designated using symbolic metadata. For more information, please see the [model validation and units](@ref units) section of the docs. Note that `getunit` is not equivalent to `get_unit` - the former is a metadata getter for individual variables (and is provided so the same interface function for `unit` exists like other metadata), while the latter is used to handle more general symbolic expressions.
201+
Units for variables can be designated using symbolic metadata. For more information, please see the [model validation and units](@ref units) section of the docs. Note that `getunit` is not equivalent to `get_unit` - the former is a metadata getter for individual variables (and is provided so the same interface function for `unit` exists like other metadata), while the latter is used to handle more general symbolic expressions.
201202

202203
```@example metadata
203-
@variable speed [unit=u"m/s"]
204+
@variable speed [unit = u"m/s"]
204205
hasunit(speed)
205206
```
207+
206208
```@example metadata
207209
getunit(speed)
208210
```

src/variables.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ ModelingToolkit.dump_variable_metadata(p)
2828
"""
2929
function dump_variable_metadata(var)
3030
uvar = unwrap(var)
31-
variable_source, name = Symbolics.getmetadata(uvar, VariableSource, (:unknown, :unknown))
31+
variable_source, name = Symbolics.getmetadata(
32+
uvar, VariableSource, (:unknown, :unknown))
3233
type = symtype(uvar)
3334
if type <: AbstractArray
3435
shape = Symbolics.shape(var)
@@ -102,7 +103,9 @@ getconnect(x::Symbolic) = Symbolics.getmetadata(x, VariableConnectType, nothing)
102103
Determine whether variable `x` has a connect type. See also [`getconnect`](@ref).
103104
"""
104105
hasconnect(x) = getconnect(x) !== nothing
105-
setconnect(x, t::Type{T}) where T <: AbstractConnectType = setmetadata(x, VariableConnectType, t)
106+
function setconnect(x, t::Type{T}) where {T <: AbstractConnectType}
107+
setmetadata(x, VariableConnectType, t)
108+
end
106109

107110
### Input, Output, Irreducible
108111
isvarkind(m, x::Union{Num, Symbolics.Arr}) = isvarkind(m, value(x))
@@ -581,7 +584,7 @@ metadata associated with it.
581584
See also [`getmisc(x)`](@ref).
582585
"""
583586
hasmisc(x) = getmisc(x) !== nothing
584-
setmisc(x, miscdata) = setmetadata(x, VariableMisc, miscdata)
587+
setmisc(x, miscdata) = setmetadata(x, VariableMisc, miscdata)
585588

586589
## Units ======================================================================
587590
"""

0 commit comments

Comments
 (0)