diff --git a/Project.toml b/Project.toml index cec19daa22..822b12381f 100644 --- a/Project.toml +++ b/Project.toml @@ -160,7 +160,7 @@ StaticArrays = "0.10, 0.11, 0.12, 1.0" StochasticDelayDiffEq = "1.10" StochasticDiffEq = "6.72.1" SymbolicIndexingInterface = "0.3.39" -SymbolicUtils = "3.26.1" +SymbolicUtils = "3.30.0" Symbolics = "6.40" URIs = "1" UnPack = "0.1, 1.0" diff --git a/src/systems/problem_utils.jl b/src/systems/problem_utils.jl index 7a9bc2617e..57d43331b1 100644 --- a/src/systems/problem_utils.jl +++ b/src/systems/problem_utils.jl @@ -1546,7 +1546,12 @@ struct SymbolicTstops{F} end function (st::SymbolicTstops)(p, tspan) - unique!(sort!(reduce(vcat, st.fn(p, tspan...)))) + buffer = reduce(vcat, st.fn(p, tspan...)) + if ArrayInterface.ismutable(buffer) + return unique!(sort!(buffer)) + else + return unique(sort(buffer)) + end end function SymbolicTstops( diff --git a/test/odesystem.jl b/test/odesystem.jl index 2e3bca34e2..4706c51535 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -1414,6 +1414,10 @@ end sol2 = solve(prob2, DImplicitEuler()) expected_tstops = unique!(sort!(vcat(0.0:0.075:10.0, 0.1, 0.2, 0.65, 0.35, 0.45))) @test all(x -> any(isapprox(x, atol = 1e-6), sol2.t), expected_tstops) + + @mtkcompile sys = System([D(x) ~ x + p], t; tstops = [[p]]) + prob = ODEProblem(sys, [], (0.0, 1.0)) + @test prob.kwargs[:tstops](prob.p, prob.tspan) ≈ [0.15] end @testset "Validate input types" begin