Skip to content

Commit d2efa83

Browse files
fix: fix single-element symbolic tstops
1 parent 646bace commit d2efa83

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/systems/problem_utils.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,12 @@ struct SymbolicTstops{F}
15461546
end
15471547

15481548
function (st::SymbolicTstops)(p, tspan)
1549-
unique!(sort!(reduce(vcat, st.fn(p, tspan...))))
1549+
buffer = reduce(vcat, st.fn(p, tspan...))
1550+
if ArrayInterface.ismutable(buffer)
1551+
return unique!(sort!(buffer))
1552+
else
1553+
return unique(sort(buffer))
1554+
end
15501555
end
15511556

15521557
function SymbolicTstops(

test/odesystem.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,10 @@ end
14141414
sol2 = solve(prob2, DImplicitEuler())
14151415
expected_tstops = unique!(sort!(vcat(0.0:0.075:10.0, 0.1, 0.2, 0.65, 0.35, 0.45)))
14161416
@test all(x -> any(isapprox(x, atol = 1e-6), sol2.t), expected_tstops)
1417+
1418+
@mtkcompile sys = System([D(x) ~ x + p], t; tstops = [[p]])
1419+
prob = ODEProblem(sys, [], (0.0, 1.0))
1420+
@test prob.kwargs[:tstops](prob.p, prob.tspan) [0.15]
14171421
end
14181422

14191423
@testset "Validate input types" begin

0 commit comments

Comments
 (0)