From 1ad28ddc2eae05a5cba7b31b6ab702d9fb0e59a4 Mon Sep 17 00:00:00 2001 From: Kaitlyn Loftus <51452508+kaitlyn-loftus@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:29:44 -0600 Subject: [PATCH] update retcode from symbol (#288) * update retcode from symbol * Add tests * Bump the version number --------- Co-authored-by: David Widmann --- Project.toml | 2 +- src/integrators/interface.jl | 2 +- test/integrators/events.jl | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index e3d7cd8..a87677f 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DelayDiffEq" uuid = "bcd4f6db-9728-5f36-b5f7-82caef46ccdb" authors = ["Chris Rackauckas "] -version = "5.47.1" +version = "5.47.2" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" diff --git a/src/integrators/interface.jl b/src/integrators/interface.jl index edd016f..2732e06 100644 --- a/src/integrators/interface.jl +++ b/src/integrators/interface.jl @@ -256,7 +256,7 @@ function DiffEqBase.last_step_failed(integrator::DDEIntegrator) end # terminate integration -function DiffEqBase.terminate!(integrator::DDEIntegrator, retcode = :Terminated) +function DiffEqBase.terminate!(integrator::DDEIntegrator, retcode = ReturnCode.Terminated) integrator.sol = DiffEqBase.solution_new_retcode(integrator.sol, retcode) integrator.opts.tstops.valtree = typeof(integrator.opts.tstops.valtree)() nothing diff --git a/test/integrators/events.jl b/test/integrators/events.jl index f6966c7..75d3807 100644 --- a/test/integrators/events.jl +++ b/test/integrators/events.jl @@ -34,6 +34,7 @@ end # discrete callback @testset "discrete" begin + # Automatic absolute tolerances cb = AutoAbstol() sol1 = solve(prob, alg, callback = cb) @@ -42,6 +43,11 @@ end @test sol3.errors[:L2] < 1.4e-3 @test sol3.errors[:L∞] < 4.1e-3 + + # Terminate early + cb = DiscreteCallback((u, t, integrator) -> t == 4, terminate!) + sol = @test_logs solve(prob, alg; callback = cb, tstops = [4.0]) + @test sol.t[end] == 4 end @testset "save discontinuity" begin