Skip to content

Commit

Permalink
fix: fix variable discovery in arrays of Num passed to callable params
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Oct 16, 2024
1 parent 28a5af3 commit a87eb46
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,15 +387,21 @@ function vars!(vars, O; op = Differential)
f = getcalledparameter(O)
push!(vars, f)
for arg in arguments(O)
vars!(vars, arg; op)
if symbolic_type(arg) == NotSymbolic() && arg isa AbstractArray
for el in arg
vars!(vars, unwrap(el); op)
end
else
vars!(vars, arg; op)
end
end
return vars
end
return push!(vars, O)
end
if symbolic_type(O) == NotSymbolic() && O isa AbstractArray
for arg in O
vars!(vars, arg; op)
vars!(vars, unwrap(arg); op)
end
return vars
end
Expand Down
8 changes: 8 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1442,3 +1442,11 @@ end
end
end
end

@testset "Variable discovery in arrays of `Num` inside callable symbolic" begin
@variables x(t) y(t)
@parameters foo(::AbstractVector)
sys = @test_nowarn ODESystem(D(x) ~ foo([x, 2y]), t; name = :sys)
@test length(unknowns(sys)) == 2
@test any(isequal(y), unknowns(sys))
end

0 comments on commit a87eb46

Please sign in to comment.