Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle unknowns inside callable parameters when topsorting equations #3105

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
StaticArrays = "0.10, 0.11, 0.12, 1.0"
SymbolicIndexingInterface = "0.3.31"
SymbolicUtils = "3.7"
Symbolics = "6.12"
Symbolics = "6.14"
URIs = "1"
UnPack = "0.1, 1.0"
Unitful = "1.1"
Expand Down
8 changes: 8 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ function vars!(vars, eq::Equation; op = Differential)
end
function vars!(vars, O; op = Differential)
if isvariable(O)
if iscalledparameter(O)
f = getcalledparameter(O)
push!(vars, f)
for arg in arguments(O)
vars!(vars, arg; op)
end
return vars
end
return push!(vars, O)
end
if symbolic_type(O) == NotSymbolic() && O isa AbstractArray
Expand Down
8 changes: 8 additions & 0 deletions test/structural_transformation/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ se = collect(StructuralTransformations.edges(graph))
@test se == mapreduce(vcat, enumerate(graph.fadjlist)) do (s, d)
StructuralTransformations.BipartiteEdge.(s, d)
end

@testset "observed2graph handles unknowns inside callable parameters" begin
@variables x(t) y(t)
@parameters p(..)
g, _ = ModelingToolkit.observed2graph([y ~ p(x), x ~ 0], [y, x])
@test ModelingToolkit.𝑠neighbors(g, 1) == [2]
@test ModelingToolkit.𝑑neighbors(g, 2) == [1]
end
Loading