Skip to content

Commit 6af5667

Browse files
fix: handle array and scalar parameters in split = false systems
1 parent bc1409a commit 6af5667

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/systems/abstractsystem.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,8 +791,13 @@ function complete(sys::AbstractSystem; split = true, flatten = true)
791791
end
792792
@set! sys.ps = ordered_ps
793793
end
794-
elseif has_index_cache(sys)
795-
@set! sys.index_cache = nothing
794+
else
795+
if has_index_cache(sys)
796+
@set! sys.index_cache = nothing
797+
end
798+
ps = mapreduce(
799+
Symbolics.scalarize, vcat, parameters(sys; initial_parameters = true))
800+
@set! sys.ps = ps
796801
end
797802
if isdefined(sys, :initializesystem) && get_initializesystem(sys) !== nothing
798803
@set! sys.initializesystem = complete(get_initializesystem(sys); split)

test/split_parameters.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,12 @@ end
268268
@test_nowarn sol = solve(prob)
269269
end
270270
end
271+
272+
@testset "Array and scalar parameters with `split = false`" begin
273+
@variables x(t)
274+
@parameters p[1:2] q
275+
@mtkbuild sys=ODESystem(D(x) ~ sum(p) * x + q, t) split=false
276+
@test length(parameters(sys)) == 3
277+
prob = ODEProblem(sys, [x => 1.0], (0.0, 1.0), [p => ones(2), q => 1.0])
278+
@test prob.p isa Vector{Float64}
279+
end

0 commit comments

Comments
 (0)