@@ -430,7 +430,7 @@ function has_observed_with_lhs(sys, sym)
430
430
if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
431
431
return haskey (ic. observed_syms_to_timeseries, sym)
432
432
else
433
- return any (isequal (sym), [eq . lhs for eq in observed (sys)] )
433
+ return any (isequal (sym), observeds (sys))
434
434
end
435
435
end
436
436
@@ -489,7 +489,7 @@ function _all_ts_idxs!(ts_idxs, ::ScalarSymbolic, sys, sym::Symbol)
489
489
if has_index_cache (sys) && (ic = get_index_cache (sys)) != = nothing
490
490
return _all_ts_idxs! (ts_idxs, sys, ic. symbol_to_variable[sym])
491
491
elseif is_variable (sys, sym) || is_independent_variable (sys, sym) ||
492
- any (isequal (sym), [ getname (eq . lhs) for eq in observed ( sys)] )
492
+ any (isequal (sym), getname .( observeds ( sys)) )
493
493
push! (ts_idxs, ContinuousTimeseries ())
494
494
elseif is_timeseries_parameter (sys, sym)
495
495
push! (ts_idxs, timeseries_parameter_index (sys, s). timeseries_idx)
@@ -579,7 +579,7 @@ SymbolicIndexingInterface.constant_structure(::AbstractSystem) = true
579
579
580
580
function SymbolicIndexingInterface. all_variable_symbols (sys:: AbstractSystem )
581
581
syms = variable_symbols (sys)
582
- obs = getproperty .( observed ( sys), :lhs )
582
+ obs = observeds ( sys)
583
583
return isempty (obs) ? syms : vcat (syms, obs)
584
584
end
585
585
@@ -1411,6 +1411,7 @@ _nonum(@nospecialize x) = x isa Num ? x.val : x
1411
1411
$(TYPEDSIGNATURES)
1412
1412
1413
1413
Get the unknown variables of the system `sys` and its subsystems.
1414
+ These must be explicitly solved for, unlike `observeds(sys)`.
1414
1415
1415
1416
See also [`ModelingToolkit.get_unknowns`](@ref).
1416
1417
"""
@@ -1673,6 +1674,14 @@ function controls(sys::AbstractSystem)
1673
1674
isempty (systems) ? ctrls : [ctrls; reduce (vcat, namespace_controls .(systems))]
1674
1675
end
1675
1676
1677
+ """
1678
+ $(TYPEDSIGNATURES)
1679
+
1680
+ Get the observed equations of the system `sys` and its subsystems.
1681
+ These can be expressed in terms of `unknowns(sys)`, and do not have to be explicitly solved for.
1682
+
1683
+ See also [`observeds`](@ref) and [`ModelingToolkit.get_observed()`](@ref).
1684
+ """
1676
1685
function observed (sys:: AbstractSystem )
1677
1686
obs = get_observed (sys)
1678
1687
systems = get_systems (sys)
@@ -1682,6 +1691,19 @@ function observed(sys::AbstractSystem)
1682
1691
init = Equation[])]
1683
1692
end
1684
1693
1694
+ """
1695
+ $(TYPEDSIGNATURES)
1696
+
1697
+ Get the observed variables of the system `sys` and its subsystems.
1698
+ These can be expressed in terms of `unknowns(sys)`, and do not have to be explicitly solved for.
1699
+ It is equivalent to all left hand sides of `observed(sys)`.
1700
+
1701
+ See also [`observed`](@ref).
1702
+ """
1703
+ function observeds (sys:: AbstractSystem )
1704
+ return map (eq -> eq. lhs, observed (sys))
1705
+ end
1706
+
1685
1707
Base. @deprecate default_u0 (x) defaults (x) false
1686
1708
Base. @deprecate default_p (x) defaults (x) false
1687
1709
0 commit comments