Skip to content

Commit ae2a7ec

Browse files
docs: add docstrings for variable metadata functions
1 parent c7be89d commit ae2a7ec

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/variables.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,50 @@ function isvarkind(m, x)
163163
getmetadata(x, m, false)
164164
end
165165

166+
"""
167+
$(TYPEDSIGNATURES)
168+
169+
Set the `input` metadata of variable `x` to `v`.
170+
"""
166171
setinput(x, v::Bool) = setmetadata(x, VariableInput, v)
172+
"""
173+
$(TYPEDSIGNATURES)
174+
175+
Set the `output` metadata of variable `x` to `v`.
176+
"""
167177
setoutput(x, v::Bool) = setmetadata(x, VariableOutput, v)
168178
setio(x, i::Bool, o::Bool) = setoutput(setinput(x, i), o)
169179

180+
"""
181+
$(TYPEDSIGNATURES)
182+
183+
Check if variable `x` is marked as an input.
184+
"""
170185
isinput(x) = isvarkind(VariableInput, x)
186+
"""
187+
$(TYPEDSIGNATURES)
188+
189+
Check if variable `x` is marked as an output.
190+
"""
171191
isoutput(x) = isvarkind(VariableOutput, x)
172192

173193
# Before the solvability check, we already have handled IO variables, so
174194
# irreducibility is independent from IO.
195+
"""
196+
$(TYPEDSIGNATURES)
197+
198+
Check if `x` is marked as irreducible. This prevents it from being eliminated as an
199+
observed variable in `mtkcompile`.
200+
"""
175201
isirreducible(x) = isvarkind(VariableIrreducible, x)
176202
setirreducible(x, v::Bool) = setmetadata(x, VariableIrreducible, v)
177203
state_priority(x::Union{Num, Symbolics.Arr}) = state_priority(unwrap(x))
204+
"""
205+
$(TYPEDSIGNATURES)
206+
207+
Return the `state_priority` metadata of variable `x`. This influences its priority to be
208+
chosen as a state in `mtkcompile`.
209+
"""
178210
state_priority(x) = convert(Float64, getmetadata(x, VariableStatePriority, 0.0))::Float64
179211

180212
normalize_to_differential(x) = x
@@ -419,6 +451,11 @@ function getdescription(x)
419451
Symbolics.getmetadata(x, VariableDescription, "")
420452
end
421453

454+
"""
455+
$(TYPEDSIGNATURES)
456+
457+
Check if variable `x` has a non-empty attached description.
458+
"""
422459
function hasdescription(x)
423460
getdescription(x) != ""
424461
end

0 commit comments

Comments
 (0)