Skip to content

Commit

Permalink
Merge pull request #3127 from AayushSabharwal/as/pdep-const-rhs
Browse files Browse the repository at this point in the history
fix: handle parameter dependencies with constant RHS
  • Loading branch information
ChrisRackauckas authored Oct 16, 2024
2 parents d838bbf + 713c1cb commit 41de08f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/systems/diffeqs/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,7 @@ function ODESystem(eqs, iv; kwargs...)
end
end
for eq in get(kwargs, :parameter_dependencies, Equation[])
if eq isa Pair
collect_vars!(allunknowns, ps, eq, iv)
else
collect_vars!(allunknowns, ps, eq, iv)
end
collect_vars!(allunknowns, ps, eq, iv)
end
for ssys in get(kwargs, :systems, ODESystem[])
collect_scoped_vars!(allunknowns, ps, ssys, iv)
Expand Down
2 changes: 2 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ end

function collect_defaults!(defs, vars)
for v in vars
symbolic_type(v) == NotSymbolic() && continue
if haskey(defs, v) || !hasdefault(unwrap(v)) || (def = getdefault(v)) === nothing
continue
end
Expand All @@ -262,6 +263,7 @@ end

function collect_var_to_name!(vars, xs)
for x in xs
symbolic_type(x) == NotSymbolic() && continue
x = unwrap(x)
if hasmetadata(x, Symbolics.GetindexParent)
xarr = getmetadata(x, Symbolics.GetindexParent)
Expand Down
5 changes: 5 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1442,3 +1442,8 @@ end
end
end
end

@testset "Parameter dependencies with constant RHS" begin
@parameters p
@test_nowarn ODESystem(Equation[], t; parameter_dependencies = [p ~ 1.0], name = :a)
end

0 comments on commit 41de08f

Please sign in to comment.