From a8b78be5dd454fceae7a4208bc841f01728b2325 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Tue, 12 Nov 2024 13:36:28 +0530 Subject: [PATCH 1/4] refactor: check if algorithm supports late binding tstops --- src/solve.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/solve.jl b/src/solve.jl index 0dd5b6aa0..56aa6dfd0 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -500,6 +500,19 @@ function Base.showerror(io::IO, e::IncompatibleMassMatrixError) println(io, TruncatedStacktraces.VERBOSE_MSG) end +const LATE_BINDING_TSTOPS_ERROR_MESSAGE = """ + This solver does not support providing `tstops` as a function. + Consider using a different solver or providing `tstops` as an array + of times. + """ + +struct LateBindingTstopsNotSupportedError <: Exception end + +function Base.showerror(io::IO, e::LateBindingTstopsNotSupportedError) + println(io, LATE_BINDING_TSTOPS_ERROR_MESSAGE) + println(io, TruncatedStacktraces.VERBOSE_MSG) +end + function init_call(_prob, args...; merge_callbacks = true, kwargshandle = nothing, kwargs...) kwargshandle = kwargshandle === nothing ? KeywordArgError : kwargshandle @@ -555,6 +568,13 @@ function init_up(prob::AbstractDEProblem, sensealg, u0, p, args...; kwargs...) p = p, kwargs...) init_call(_prob, args...; kwargs...) else + tstops = get(kwargs, :tstops, nothing) + if tstops === nothing && has_kwargs(prob) + tstops = get(prob.kwargs, :tstops, nothing) + end + if !(tstops isa Union{Nothing, AbstractArray, Tuple}) && !SciMLBase.allows_late_binding_tstops(alg) + throw(LateBindingTstopsNotSupportedError()) + end _prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...) _alg = prepare_alg(alg, _prob.u0, _prob.p, _prob) check_prob_alg_pairing(_prob, alg) # alg for improved inference @@ -1084,6 +1104,13 @@ function solve_up(prob::Union{AbstractDEProblem, NonlinearProblem}, sensealg, u0 p = p, kwargs...) solve_call(_prob, args...; kwargs...) else + tstops = get(kwargs, :tstops, nothing) + if tstops === nothing && has_kwargs(prob) + tstops = get(prob.kwargs, :tstops, nothing) + end + if !(tstops isa Union{Nothing, AbstractArray, Tuple}) && !SciMLBase.allows_late_binding_tstops(alg) + throw(LateBindingTstopsNotSupportedError()) + end _prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...) _alg = prepare_alg(alg, _prob.u0, _prob.p, _prob) check_prob_alg_pairing(_prob, alg) # use alg for improved inference From 485e6db5b00e89364680f0008ab72566dd9fe065 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 13 Nov 2024 11:51:35 +0530 Subject: [PATCH 2/4] build: bump SciMLBase compat --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index a85c81a24..184be67bd 100644 --- a/Project.toml +++ b/Project.toml @@ -95,7 +95,7 @@ Printf = "1.9" RecursiveArrayTools = "3" Reexport = "1.0" ReverseDiff = "1" -SciMLBase = "2.56.0" +SciMLBase = "2.60.0" SciMLOperators = "0.3" SciMLStructures = "1.5" Setfield = "1" From 5ec188074bb4781c1688c83ff963d0607fd5db10 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 13 Nov 2024 12:24:50 +0530 Subject: [PATCH 3/4] fix: `tstops` can be `Real` --- src/solve.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/solve.jl b/src/solve.jl index 56aa6dfd0..357f2f78d 100644 --- a/src/solve.jl +++ b/src/solve.jl @@ -572,7 +572,7 @@ function init_up(prob::AbstractDEProblem, sensealg, u0, p, args...; kwargs...) if tstops === nothing && has_kwargs(prob) tstops = get(prob.kwargs, :tstops, nothing) end - if !(tstops isa Union{Nothing, AbstractArray, Tuple}) && !SciMLBase.allows_late_binding_tstops(alg) + if !(tstops isa Union{Nothing, AbstractArray, Tuple, Real}) && !SciMLBase.allows_late_binding_tstops(alg) throw(LateBindingTstopsNotSupportedError()) end _prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...) @@ -1108,7 +1108,7 @@ function solve_up(prob::Union{AbstractDEProblem, NonlinearProblem}, sensealg, u0 if tstops === nothing && has_kwargs(prob) tstops = get(prob.kwargs, :tstops, nothing) end - if !(tstops isa Union{Nothing, AbstractArray, Tuple}) && !SciMLBase.allows_late_binding_tstops(alg) + if !(tstops isa Union{Nothing, AbstractArray, Tuple, Real}) && !SciMLBase.allows_late_binding_tstops(alg) throw(LateBindingTstopsNotSupportedError()) end _prob = get_concrete_problem(prob, isadaptive(alg); u0 = u0, p = p, kwargs...) From 831d8237d623d36c8aaa55172f8c2073818bf6b0 Mon Sep 17 00:00:00 2001 From: Anant Thazhemadam Date: Wed, 13 Nov 2024 14:58:11 +0530 Subject: [PATCH 4/4] i: don't fail CI jobs if code coverage reporting fails --- .github/workflows/Downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Downstream.yml b/.github/workflows/Downstream.yml index b2b43a4bb..0ec4ca550 100644 --- a/.github/workflows/Downstream.yml +++ b/.github/workflows/Downstream.yml @@ -91,4 +91,4 @@ jobs: with: file: lcov.info token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true + fail_ci_if_error: false