Skip to content

Commit c5cc07a

Browse files
docs: add docs for apply_to_variables
1 parent d507ff9 commit c5cc07a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/systems/abstractsystem.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,8 +1048,18 @@ function Base.setproperty!(sys::AbstractSystem, prop::Symbol, val)
10481048
""")
10491049
end
10501050

1051-
apply_to_variables(f::F, ex) where {F} = _apply_to_variables(f, ex)
1052-
apply_to_variables(f::F, ex::Num) where {F} = wrap(_apply_to_variables(f, unwrap(ex)))
1051+
"""
1052+
$(TYPEDSIGNATURES)
1053+
1054+
Apply function `f` to each variable in expression `ex`. `f` should be a function that takes
1055+
a variable and returns the replacement to use. A "variable" in this context refers to a
1056+
symbolic quantity created directly from a variable creation macro such as
1057+
[`Symbolics.@variables`](@ref), [`@independent_variables`](@ref), [`@parameters`](@ref),
1058+
[`@constants`](@ref) or [`@brownians`](@ref).
1059+
"""
1060+
apply_to_variables(f, ex) = _apply_to_variables(f, ex)
1061+
apply_to_variables(f, ex::Num) = wrap(_apply_to_variables(f, unwrap(ex)))
1062+
apply_to_variables(f, ex::Symbolics.Arr) = wrap(_apply_to_variables(f, unwrap(ex)))
10531063
function _apply_to_variables(f::F, ex) where {F}
10541064
if isvariable(ex)
10551065
return f(ex)

0 commit comments

Comments
 (0)