Skip to content

Commit dbe211d

Browse files
committed
add collect_vars equation dispatch
1 parent c69d28e commit dbe211d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/utils.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ recursively searches through all subsystems of `sys`, increasing the depth if it
492492
function collect_scoped_vars!(unknowns, parameters, sys, iv; depth = 1, op = Differential)
493493
if has_eqs(sys)
494494
for eq in get_eqs(sys)
495-
eq isa Equation || continue
495+
eqtype_supports_collect_vars(eq) || continue
496496
(eq isa Equation && eq.lhs isa Union{Symbolic, Number}) || continue
497497
collect_vars!(unknowns, parameters, eq, iv; depth, op)
498498
end
@@ -526,6 +526,16 @@ function collect_vars!(unknowns, parameters, expr, iv; depth = 0, op = Different
526526
return nothing
527527
end
528528

529+
"""
530+
$(TYPEDSIGNATURES)
531+
532+
Indicate whether the given equation type (Equation, Pair, etc) supports `collect_vars!`. Can
533+
be dispatched by higher-level libraries to indicate support.
534+
"""
535+
eqtype_supports_collect_vars(eq) = false
536+
eqtype_supports_collect_vars(eq::Equation) = true
537+
eqtype_supports_collect_vars(eq::Pair) = true
538+
529539
function collect_vars!(unknowns, parameters, eq::Equation, iv;
530540
depth = 0, op = Differential)
531541
collect_vars!(unknowns, parameters, eq.lhs, iv; depth, op)

0 commit comments

Comments
 (0)