diff --git a/src/DiffEqCallbacks.jl b/src/DiffEqCallbacks.jl index 0d6c4818..407fa71e 100644 --- a/src/DiffEqCallbacks.jl +++ b/src/DiffEqCallbacks.jl @@ -2,32 +2,46 @@ module DiffEqCallbacks using ConcreteStructs: @concrete using DataStructures: DataStructures, BinaryMaxHeap, BinaryMinHeap -using DiffEqBase: DiffEqBase, get_tstops, get_tstops_array, get_tstops_max +using DiffEqBase: get_tstops, get_tstops_array, get_tstops_max using DifferentiationInterface: DifferentiationInterface, Constant -using LinearAlgebra: LinearAlgebra, adjoint, axpy!, copyto!, diagind, mul!, ldiv! +using LinearAlgebra: LinearAlgebra, adjoint, axpy!, copyto!, diagind, mul! using Markdown: @doc_str using PrecompileTools: PrecompileTools using RecipesBase: @recipe using RecursiveArrayTools: RecursiveArrayTools, DiffEqArray, copyat_or_push! -using SciMLBase: SciMLBase, CallbackSet, DiscreteCallback, NonlinearFunction, - NonlinearLeastSquaresProblem, NonlinearProblem, RODEProblem, +using SciMLBase: SciMLBase, CallbackSet, DiscreteCallback, DiscreteProblem, + NonlinearFunction, NonlinearProblem, RODEProblem, ReturnCode, SDEProblem, add_tstop!, check_error, get_du, - get_proposed_dt, get_tmp_cache, init, reinit!, - set_proposed_dt!, solve!, terminate! + get_proposed_dt, get_tmp_cache, + set_proposed_dt!, terminate! using StaticArraysCore: StaticArraysCore # SciMLBase v3 renamed `u_modified!` → `derivative_discontinuity!` (with # an `@deprecate` on the old name). Support both SciMLBase v2 and v3 by -# aliasing to whichever name the loaded SciMLBase provides. -@static if isdefined(SciMLBase, :derivative_discontinuity!) - using SciMLBase: derivative_discontinuity! +# binding a const to whichever name the loaded SciMLBase provides. Both +# `derivative_discontinuity!` and `u_modified!` are public in their +# respective SciMLBase versions, so the qualified access is to public API; a +# `const` (rather than a `using` import on one branch) keeps the name a single +# local binding and avoids a stale-import false positive. +const derivative_discontinuity! = if isdefined(SciMLBase, :derivative_discontinuity!) + SciMLBase.derivative_discontinuity! else - const derivative_discontinuity! = SciMLBase.u_modified! + SciMLBase.u_modified! end const DI = DifferentiationInterface true_condition(u, t, integrator) = true +# Local reproduction of SciMLBase's `_unwrap_val` (a leading-underscore internal +# that will not be made public): pull the value out of a `Val`, pass anything +# else through unchanged. +_unwrap_val(B) = B +_unwrap_val(::Val{B}) where {B} = B + +# No-op default `initialize` for `DiscreteCallback`, matching SciMLBase's +# (non-public) `INITIALIZE_DEFAULT`: reset the derivative-discontinuity flag. +INITIALIZE_DEFAULT(cb, u, t, integrator) = derivative_discontinuity!(integrator, false) + include("functor_helpers.jl") include("autoabstol.jl") include("manifold.jl") diff --git a/src/function_caller.jl b/src/function_caller.jl index 2cdb98ce..32efd7cf 100644 --- a/src/function_caller.jl +++ b/src/function_caller.jl @@ -19,7 +19,7 @@ function (affect!::FunctionCallingAffect)(integrator, force_func = false) if curt != integrator.t # If