From 03db67f4dc4e2d4483deea15fac055e577a9a909 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Thu, 25 Jan 2024 18:35:54 -0500 Subject: [PATCH 1/2] use `vcat` rather than `append!` to combine `d_discontinuities` and `tstops` this version works when tstops is a scalar. --- src/common_interface/solve.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common_interface/solve.jl b/src/common_interface/solve.jl index e07aa70..c416b11 100644 --- a/src/common_interface/solve.jl +++ b/src/common_interface/solve.jl @@ -147,7 +147,7 @@ function DiffEqBase.__init(prob::DiffEqBase.AbstractODEProblem{uType, tupType, i progress && Logging.@logmsg(Logging.LogLevel(-1), progress_name, _id=progress_id, progress=0) - append!(tstops, d_discontinuities) + tstops = vcat(tstops, d_discontinuities) callbacks_internal = DiffEqBase.CallbackSet(callback) max_len_cb = DiffEqBase.max_vector_callback_length(callbacks_internal) @@ -515,7 +515,7 @@ function DiffEqBase.__init(prob::DiffEqBase.AbstractODEProblem{uType, tupType, i progress && Logging.@logmsg(Logging.LogLevel(-1), progress_name, _id=progress_id, progress=0) - append!(tstops, d_discontinuities) + tstops = vcat(tstops, d_discontinuities) callbacks_internal = DiffEqBase.CallbackSet(callback) max_len_cb = DiffEqBase.max_vector_callback_length(callbacks_internal) @@ -1026,7 +1026,7 @@ function DiffEqBase.__init(prob::DiffEqBase.AbstractDAEProblem{uType, duType, tu progress && Logging.@logmsg(Logging.LogLevel(-1), progress_name, _id=progress_id, progress=0) - append!(tstops, d_discontinuities) + tstops = vcat(tstops, d_discontinuities) callbacks_internal = DiffEqBase.CallbackSet(callback) max_len_cb = DiffEqBase.max_vector_callback_length(callbacks_internal) From 308daaba4f4e69f4c6eeea769d48a359b7e5bdce Mon Sep 17 00:00:00 2001 From: oscarddssmith Date: Fri, 26 Jan 2024 12:28:17 -0500 Subject: [PATCH 2/2] add test --- test/common_interface/cvode.jl | 7 ++++--- test/common_interface/ida.jl | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/common_interface/cvode.jl b/test/common_interface/cvode.jl index 845e80c..a40996c 100644 --- a/test/common_interface/cvode.jl +++ b/test/common_interface/cvode.jl @@ -45,9 +45,10 @@ sol = solve(prob, CVODE_Adams(); saveat = saveat, save_everystep = false) @test sol.t == saveat -sol = solve(prob, CVODE_Adams(); tstops = [0.9]) - -@test 0.9 ∈ sol.t +for tstops in [0.9, [0.9]] + sol = solve(prob, CVODE_Adams(); tstops) + @test 0.9 ∈ sol.t +end sol = solve(prob, CVODE_Adams()) sol_idxs = solve(prob, CVODE_Adams(); save_idxs = [1], timeseries_errors = false) diff --git a/test/common_interface/ida.jl b/test/common_interface/ida.jl index e6b7e61..75c14cc 100644 --- a/test/common_interface/ida.jl +++ b/test/common_interface/ida.jl @@ -58,8 +58,10 @@ sol = solve(prob, IDA(); saveat = saveat, save_everystep = true) @test sol.t != saveat @test intersect(sol.t, saveat) == saveat @info "IDA with tstops" -sol = solve(prob, IDA(); tstops = [0.9]) -@test 0.9 ∈ sol.t +for tstops in [0.9, [0.9]] + sol = solve(prob, IDA(); tstops) + @test 0.9 ∈ sol.t +end sol = solve(prob, IDA(); d_discontinuities = [0.9]) @test 0.9 ∈ sol.t