Skip to content

Commit

Permalink
Merge pull request #919 from AayushSabharwal/as/remake-array-unknown-…
Browse files Browse the repository at this point in the history
…symbol

fix: handle array unknown provided as `Symbol` to `remake`
  • Loading branch information
ChrisRackauckas authored Jan 24, 2025
2 parents c01ffa5 + c5e4ede commit 00c4070
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -910,7 +910,10 @@ function fill_vars(
v === nothing && continue
idx = index_function(prob, k)
idx === nothing && continue
if !(idx isa AbstractArray) || symbolic_type(k) != ArraySymbolic()
# If `k` is an array symbolic, and `[:k => [1.0, 2.0]]` is provided
if idx isa AbstractArray && symbolic_type(k) == ScalarSymbolic()
k = [idx_to_vsym[i] for i in idx]
elseif !(idx isa AbstractArray) || symbolic_type(k) != ArraySymbolic()
idx = (idx,)
k = (k,)
v = (v,)
Expand Down
8 changes: 8 additions & 0 deletions test/downstream/modelingtoolkit_remake.jl
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,11 @@ end
@test eltype(initprob.u0) <: ForwardDiff.Dual
@test eltype(SciMLStructures.canonicalize(SciMLStructures.Tunable(), initprob.p)[1]) <: ForwardDiff.Dual
end

@testset "Array unknown specified as Symbol" begin
@variables x(t)[1:2]
@parameters k
@mtkbuild sys = ODESystem([D(x[1]) ~ k * x[1], D(x[2]) ~ - x[2]], t)
prob = ODEProblem(sys, [x => ones(2)], (0.0, 1.0), [k => 2.0])
prob2 = remake(prob; u0 = [:x => 2ones(2)])
end

0 comments on commit 00c4070

Please sign in to comment.