Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove check in check_error! #670

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/integrator_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,8 @@ Same as `check_error` but also set solution's return code
"""
function check_error!(integrator::DEIntegrator)
code = check_error(integrator)
integrator.sol = solution_new_retcode(integrator.sol, code)
if code != ReturnCode.Success
integrator.sol = solution_new_retcode(integrator.sol, code)
postamble!(integrator)
end
return code
Expand Down
11 changes: 11 additions & 0 deletions test/integrator_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ mutable struct DummySolution
retcode::Any
end

SciMLBase.solution_new_retcode(::DummySolution, code) = DummySolution(code)

mutable struct DummyIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}
uprev::U
tprev::T
Expand Down Expand Up @@ -46,6 +48,9 @@ function SciMLBase.done(integrator::DummyIntegrator)
integrator.t > 10
end

SciMLBase.check_error(::DummyIntegrator) = ReturnCode.Success
SciMLBase.postamble!(::DummyIntegrator) = nothing

integrator = DummyIntegrator()
@test step_dt!(integrator, 1.5) == 2
@test step_dt!(integrator, 1.5, true) == 1.5
Expand All @@ -62,3 +67,9 @@ for (uprev, tprev, u, t) in intervals(DummyIntegrator())
end
@test eltype(collect(intervals(DummyIntegrator()))) ==
Tuple{Vector{Float64}, Float64, Vector{Float64}, Float64}

@test integrator.sol.retcode == ReturnCode.Default
@test check_error(integrator) == ReturnCode.Success
@test integrator.sol.retcode == ReturnCode.Default
@test SciMLBase.check_error!(integrator) == ReturnCode.Success
@test integrator.sol.retcode == ReturnCode.Success
Comment on lines +72 to +76
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test that nothing is allocated and this is good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 14f6bce ok? Or do you also want to test this on Lorentz using OrdinaryDiffEq?