Skip to content

Commit e2c83e9

Browse files
Merge pull request #1105 from AayushSabharwal/as/late-tstops
refactor: check if algorithm supports late binding tstops
2 parents b52cf18 + 831d823 commit e2c83e9

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

.github/workflows/Downstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@ jobs:
9191
with:
9292
file: lcov.info
9393
token: ${{ secrets.CODECOV_TOKEN }}
94-
fail_ci_if_error: true
94+
fail_ci_if_error: false

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Printf = "1.9"
9595
RecursiveArrayTools = "3"
9696
Reexport = "1.0"
9797
ReverseDiff = "1"
98-
SciMLBase = "2.56.0"
98+
SciMLBase = "2.60.0"
9999
SciMLOperators = "0.3"
100100
SciMLStructures = "1.5"
101101
Setfield = "1"

src/solve.jl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,19 @@ function Base.showerror(io::IO, e::IncompatibleMassMatrixError)
500500
println(io, TruncatedStacktraces.VERBOSE_MSG)
501501
end
502502

503+
const LATE_BINDING_TSTOPS_ERROR_MESSAGE = """
504+
This solver does not support providing `tstops` as a function.
505+
Consider using a different solver or providing `tstops` as an array
506+
of times.
507+
"""
508+
509+
struct LateBindingTstopsNotSupportedError <: Exception end
510+
511+
function Base.showerror(io::IO, e::LateBindingTstopsNotSupportedError)
512+
println(io, LATE_BINDING_TSTOPS_ERROR_MESSAGE)
513+
println(io, TruncatedStacktraces.VERBOSE_MSG)
514+
end
515+
503516
function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothing,
504517
kwargs...)
505518
kwargshandle = kwargshandle === nothing ? KeywordArgError : kwargshandle
@@ -555,6 +568,13 @@ function init_up(prob::AbstractDEProblem, sensealg, u0, p, args...; kwargs...)
555568
p = p, kwargs...)
556569
init_call(_prob, args...; kwargs...)
557570
else
571+
tstops = get(kwargs, :tstops, nothing)
572+
if tstops === nothing && has_kwargs(prob)
573+
tstops = get(prob.kwargs, :tstops, nothing)
574+
end
575+
if !(tstops isa Union{Nothing, AbstractArray, Tuple, Real}) && !SciMLBase.allows_late_binding_tstops(alg)
576+
throw(LateBindingTstopsNotSupportedError())
577+
end
558578
_prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
559579
_alg = prepare_alg(alg, _prob.u0, _prob.p, _prob)
560580
check_prob_alg_pairing(_prob, alg) # alg for improved inference
@@ -1084,6 +1104,13 @@ function solve_up(prob::Union{AbstractDEProblem, NonlinearProblem}, sensealg, u0
10841104
p = p, kwargs...)
10851105
solve_call(_prob, args...; kwargs...)
10861106
else
1107+
tstops = get(kwargs, :tstops, nothing)
1108+
if tstops === nothing && has_kwargs(prob)
1109+
tstops = get(prob.kwargs, :tstops, nothing)
1110+
end
1111+
if !(tstops isa Union{Nothing, AbstractArray, Tuple, Real}) && !SciMLBase.allows_late_binding_tstops(alg)
1112+
throw(LateBindingTstopsNotSupportedError())
1113+
end
10871114
_prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...)
10881115
_alg = prepare_alg(alg, _prob.u0, _prob.p, _prob)
10891116
check_prob_alg_pairing(_prob, alg) # use alg for improved inference

0 commit comments

Comments
 (0)