Skip to content

Commit 745d254

Browse files
Merge branch 'master' into fix_deprecation
2 parents 6f04ca9 + 1c3a2d4 commit 745d254

9 files changed

Lines changed: 107 additions & 88 deletions

Project.toml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@ JumpProcessesOrdinaryDiffEqCoreExt = "OrdinaryDiffEqCore"
3232
[compat]
3333
ADTypes = "1.22.0"
3434
Adapt = "4.6.0"
35-
Aqua = "0.8.16"
3635
ArrayInterface = "7.25.0"
3736
DataStructures = "0.19.5, 0.19"
3837
DiffEqBase = "7.5.5, 7"
3938
DiffEqCallbacks = "4.17.0"
4039
DocStringExtensions = "0.9.5"
41-
ExplicitImports = "1"
4240
FastBroadcast = "1.3.2, 1"
4341
FunctionWrappers = "1.1.3"
4442
Graphs = "1.14.0"
@@ -55,6 +53,7 @@ RecursiveArrayTools = "4.3.0, 4"
5553
Reexport = "1.2.2"
5654
SafeTestsets = "0.1"
5755
SciMLBase = "3.18.0, 3.1"
56+
SciMLTesting = "1.6"
5857
StableRNGs = "1"
5958
StaticArrays = "1.9.18"
6059
Statistics = "1"
@@ -65,19 +64,18 @@ julia = "1.10"
6564

6665
[extras]
6766
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
68-
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
69-
ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7"
7067
FastBroadcast = "7034ab61-46d4-4ed7-9d0f-46aef9175898"
7168
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
7269
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
7370
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
7471
OrdinaryDiffEqFunctionMap = "d3585ca7-f5d3-4ba6-8057-292ed1abd90f"
7572
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
7673
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
74+
SciMLTesting = "09d9d899-5365-40a9-917a-5f67fddea283"
7775
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
7876
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
7977
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
8078
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
8179

8280
[targets]
83-
test = ["ADTypes", "Aqua", "ExplicitImports", "FastBroadcast", "LinearAlgebra", "LinearSolve", "OrdinaryDiffEq", "OrdinaryDiffEqFunctionMap", "Pkg", "SafeTestsets", "StableRNGs", "Statistics", "StochasticDiffEq", "Test"]
81+
test = ["ADTypes", "FastBroadcast", "LinearAlgebra", "LinearSolve", "OrdinaryDiffEq", "OrdinaryDiffEqFunctionMap", "Pkg", "SafeTestsets", "SciMLTesting", "StableRNGs", "Statistics", "StochasticDiffEq", "Test"]

ext/JumpProcessesOrdinaryDiffEqCoreExt.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module JumpProcessesOrdinaryDiffEqCoreExt
22

33
using JumpProcesses
44
import DiffEqBase
5+
import SciMLBase
56
import OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, DAEAlgorithm,
67
StochasticDiffEqAlgorithm, StochasticDiffEqRODEAlgorithm
78

@@ -14,8 +15,8 @@ import OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm, DAEAlgorithm,
1415
# This method resolves the ambiguity by being more specific in the problem type
1516
# (AbstractJumpProblem vs Union{..., AbstractJumpProblem, ...}) while matching
1617
# the exact algorithm union from OrdinaryDiffEqCore.
17-
function DiffEqBase.__init(
18-
_jump_prob::DiffEqBase.AbstractJumpProblem{P},
18+
function SciMLBase.__init(
19+
_jump_prob::SciMLBase.AbstractJumpProblem{P},
1920
alg::Union{OrdinaryDiffEqAlgorithm, DAEAlgorithm,
2021
StochasticDiffEqAlgorithm, StochasticDiffEqRODEAlgorithm};
2122
merge_callbacks = true, kwargs...) where {P}

src/SSA_stepper.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ see the
5656
[tutorial](https://docs.sciml.ai/JumpProcesses/stable/tutorials/discrete_stochastic_example/)
5757
for details.
5858
"""
59-
struct SSAStepper <: DiffEqBase.AbstractDEAlgorithm end
59+
struct SSAStepper <: SciMLBase.AbstractDEAlgorithm end
6060
SciMLBase.allows_late_binding_tstops(::SSAStepper) = true
6161

6262
"""
@@ -140,14 +140,20 @@ function SciMLBase.derivative_discontinuity!(integrator::SSAIntegrator, bool::Bo
140140
integrator.u_modified = bool
141141
end
142142

143-
function DiffEqBase.__solve(jump_prob::JumpProblem, alg::SSAStepper; kwargs...)
143+
@static if isdefined(SciMLBase, :derivative_discontinuity!)
144+
function SciMLBase.derivative_discontinuity!(integrator::SSAIntegrator, bool::Bool)
145+
integrator.u_modified = bool
146+
end
147+
end
148+
149+
function SciMLBase.__solve(jump_prob::JumpProblem, alg::SSAStepper; kwargs...)
144150
# init will handle kwargs merging via init_call
145151
integrator = init(jump_prob, alg; kwargs...)
146152
solve!(integrator)
147153
integrator.sol
148154
end
149155

150-
function DiffEqBase.solve!(integrator::SSAIntegrator)
156+
function SciMLBase.solve!(integrator::SSAIntegrator)
151157
end_time = integrator.sol.prob.tspan[2]
152158
while should_continue_solve(integrator) # It stops before adding a tstop over
153159
step!(integrator)
@@ -185,7 +191,7 @@ function DiffEqBase.solve!(integrator::SSAIntegrator)
185191
end
186192

187193
if integrator.sol.retcode === ReturnCode.Default
188-
integrator.sol = DiffEqBase.solution_new_retcode(integrator.sol, ReturnCode.Success)
194+
integrator.sol = SciMLBase.solution_new_retcode(integrator.sol, ReturnCode.Success)
189195
end
190196
end
191197

@@ -216,7 +222,7 @@ function check_continuous_callback_error(callback)
216222
return nothing
217223
end
218224

219-
function DiffEqBase.__init(jump_prob::JumpProblem,
225+
function SciMLBase.__init(jump_prob::JumpProblem,
220226
alg::SSAStepper;
221227
save_start = true,
222228
save_end = true,
@@ -267,10 +273,10 @@ function DiffEqBase.__init(jump_prob::JumpProblem,
267273
end
268274
save_everystep = any(cb.save_positions)
269275

270-
sol = DiffEqBase.build_solution(prob, alg, t, u, dense = save_everystep,
276+
sol = SciMLBase.build_solution(prob, alg, t, u, dense = save_everystep,
271277
calculate_error = false,
272278
stats = DiffEqBase.Stats(0),
273-
interp = DiffEqBase.ConstantInterpolation(t, u))
279+
interp = SciMLBase.ConstantInterpolation(t, u))
274280

275281
_saveat = (saveat isa Number) ? (prob.tspan[1]:saveat:prob.tspan[2]) : saveat
276282
if _saveat !== nothing && !isempty(_saveat) && _saveat[1] == prob.tspan[1]
@@ -456,7 +462,7 @@ end
456462

457463
function DiffEqBase.terminate!(integrator::SSAIntegrator, retcode = ReturnCode.Terminated)
458464
integrator.keep_stepping = false
459-
integrator.sol = DiffEqBase.solution_new_retcode(integrator.sol, retcode)
465+
integrator.sol = SciMLBase.solution_new_retcode(integrator.sol, retcode)
460466
nothing
461467
end
462468

src/coupling.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ David F. Anderson, Masanori Koyama; An asymptotic relationship between coupling
33
methods for stochastically modeled population processes. IMA J Numer Anal 2015;
44
35 (4): 1757-1778. doi: 10.1093/imanum/dru044
55
"""
6-
function SplitCoupledJumpProblem(prob::DiffEqBase.AbstractJumpProblem,
7-
prob_control::DiffEqBase.AbstractJumpProblem,
6+
function SplitCoupledJumpProblem(prob::SciMLBase.AbstractJumpProblem,
7+
prob_control::SciMLBase.AbstractJumpProblem,
88
aggregator::AbstractAggregatorAlgorithm,
99
coupling_map::Vector{Tuple{Int, Int}}; kwargs...)
1010
JumpProblem(cat_problems(prob.prob, prob_control.prob), aggregator,
@@ -17,8 +17,8 @@ function cat_problems(prob::DiscreteProblem, prob_control::DiscreteProblem)
1717
DiscreteProblem(u0_coupled, prob.tspan, prob.p)
1818
end
1919

20-
function cat_problems(prob::DiffEqBase.AbstractODEProblem,
21-
prob_control::DiffEqBase.AbstractODEProblem)
20+
function cat_problems(prob::SciMLBase.AbstractODEProblem,
21+
prob_control::SciMLBase.AbstractODEProblem)
2222
l = length(prob.u0) # add l_c = length(prob_control.u0)
2323

2424
_f = SciMLBase.unwrapped_f(prob.f)
@@ -32,9 +32,9 @@ function cat_problems(prob::DiffEqBase.AbstractODEProblem,
3232
ODEProblem(new_f, u0_coupled, prob.tspan, prob.p)
3333
end
3434

35-
function cat_problems(prob::DiscreteProblem, prob_control::DiffEqBase.AbstractODEProblem)
35+
function cat_problems(prob::DiscreteProblem, prob_control::SciMLBase.AbstractODEProblem)
3636
l = length(prob.u0) # add l_c = length(prob_control.u0)
37-
if !(prob.f isa typeof(DiffEqBase.DISCRETE_INPLACE_DEFAULT))
37+
if !(prob.f isa typeof(SciMLBase.DISCRETE_INPLACE_DEFAULT))
3838
@warn("Coupling to DiscreteProblem with nontrivial f. Note that, unless scale_by_time=true, the meaning of f will change when using an ODE/SDE/DDE/DAE solver.")
3939
end
4040

@@ -49,8 +49,8 @@ function cat_problems(prob::DiscreteProblem, prob_control::DiffEqBase.AbstractOD
4949
ODEProblem(new_f, u0_coupled, prob.tspan, prob.p)
5050
end
5151

52-
function cat_problems(prob::DiffEqBase.AbstractSDEProblem,
53-
prob_control::DiffEqBase.AbstractSDEProblem)
52+
function cat_problems(prob::SciMLBase.AbstractSDEProblem,
53+
prob_control::SciMLBase.AbstractSDEProblem)
5454
l = length(prob.u0)
5555
new_f = function (du, u, p, t)
5656
prob.f(@view(du[1:l]), u.u, p, t)
@@ -64,8 +64,8 @@ function cat_problems(prob::DiffEqBase.AbstractSDEProblem,
6464
SDEProblem(new_f, new_g, u0_coupled, prob.tspan, prob.p)
6565
end
6666

67-
function cat_problems(prob::DiffEqBase.AbstractSDEProblem,
68-
prob_control::DiffEqBase.AbstractODEProblem)
67+
function cat_problems(prob::SciMLBase.AbstractSDEProblem,
68+
prob_control::SciMLBase.AbstractODEProblem)
6969
l = length(prob.u0)
7070

7171
_f = SciMLBase.unwrapped_f(prob.f)
@@ -85,9 +85,9 @@ function cat_problems(prob::DiffEqBase.AbstractSDEProblem,
8585
SDEProblem(new_f, new_g, u0_coupled, prob.tspan, prob.p)
8686
end
8787

88-
function cat_problems(prob::DiffEqBase.AbstractSDEProblem, prob_control::DiscreteProblem)
88+
function cat_problems(prob::SciMLBase.AbstractSDEProblem, prob_control::DiscreteProblem)
8989
l = length(prob.u0)
90-
if !(prob_control.f isa typeof(DiffEqBase.DISCRETE_INPLACE_DEFAULT))
90+
if !(prob_control.f isa typeof(SciMLBase.DISCRETE_INPLACE_DEFAULT))
9191
@warn("Coupling to DiscreteProblem with nontrivial f. Note that, unless scale_by_time=true, the meaning of f will change when using an ODE/SDE/DDE/DAE solver.")
9292
end
9393
new_f = function (du, u, p, t)
@@ -104,20 +104,20 @@ function cat_problems(prob::DiffEqBase.AbstractSDEProblem, prob_control::Discret
104104
SDEProblem(new_f, new_g, u0_coupled, prob.tspan)
105105
end
106106

107-
function cat_problems(prob_control::DiffEqBase.AbstractODEProblem, prob::DiscreteProblem)
107+
function cat_problems(prob_control::SciMLBase.AbstractODEProblem, prob::DiscreteProblem)
108108
cat_problems(prob, prob_control)
109109
end
110-
function cat_problems(prob_control::DiscreteProblem, prob::DiffEqBase.AbstractSDEProblem)
110+
function cat_problems(prob_control::DiscreteProblem, prob::SciMLBase.AbstractSDEProblem)
111111
cat_problems(prob, prob_control)
112112
end
113-
function cat_problems(prob_control::DiffEqBase.AbstractODEProblem,
114-
prob::DiffEqBase.AbstractSDEProblem)
113+
function cat_problems(prob_control::SciMLBase.AbstractODEProblem,
114+
prob::SciMLBase.AbstractSDEProblem)
115115
cat_problems(prob, prob_control)
116116
end
117117

118118
# this only depends on the jumps in prob, not prob.prob
119-
function build_split_jumps(prob::DiffEqBase.AbstractJumpProblem,
120-
prob_control::DiffEqBase.AbstractJumpProblem,
119+
function build_split_jumps(prob::SciMLBase.AbstractJumpProblem,
120+
prob_control::SciMLBase.AbstractJumpProblem,
121121
coupling_map::Vector{Tuple{Int, Int}})
122122
num_jumps = length(prob.discrete_jump_aggregation.rates)
123123
num_jumps_control = length(prob_control.discrete_jump_aggregation.rates)

src/problem.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function isinplace_jump(p, rj)
2-
if p isa DiscreteProblem && p.f === DiffEqBase.DISCRETE_INPLACE_DEFAULT &&
2+
if p isa DiscreteProblem && p.f === SciMLBase.DISCRETE_INPLACE_DEFAULT &&
33
rj !== nothing
44
# Just a default discrete problem f, so don't use it for iip
55
DiffEqBase.isinplace(rj)
@@ -71,7 +71,7 @@ the DifferentialEquations.jl [docs](https://docs.sciml.ai/JumpProcesses/stable/)
7171
examples and commonly asked questions.
7272
"""
7373
mutable struct JumpProblem{iip, P, A, C, J <: Union{Nothing, AbstractJumpAggregator}, J1,
74-
J2, J3, J4, R, K} <: DiffEqBase.AbstractJumpProblem{P, J}
74+
J2, J3, J4, R, K} <: SciMLBase.AbstractJumpProblem{P, J}
7575
"""The type of problem to couple the jumps to. For a pure jump process use `DiscreteProblem`, to couple to ODEs, `ODEProblem`, etc."""
7676
prob::P
7777
"""The aggregator algorithm that determines the next jump times and types for `ConstantRateJump`s and `MassActionJump`s. Examples include `Direct`."""
@@ -111,7 +111,7 @@ function remake_extended_u0(prob, newu0, rng)
111111
ExtendedJumpArray(newu0, jump_u)
112112
end
113113

114-
Base.@pure remaker_of(prob::T) where {T <: JumpProblem} = DiffEqBase.parameterless_type(T)
114+
Base.@pure remaker_of(prob::T) where {T <: JumpProblem} = SciMLBase.parameterless_type(T)
115115
function DiffEqBase.remake(jprob::JumpProblem; u0 = missing, p = missing,
116116
interpret_symbolicmap = true, use_defaults = false, kwargs...)
117117
T = remaker_of(jprob)
@@ -240,7 +240,7 @@ make_kwarg(; kwargs...) = kwargs
240240

241241
function JumpProblem(prob, aggregator::AbstractAggregatorAlgorithm, jumps::JumpSet;
242242
vr_aggregator::VariableRateAggregator = VR_FRM(),
243-
save_positions = prob isa DiffEqBase.AbstractDiscreteProblem ?
243+
save_positions = prob isa SciMLBase.AbstractDiscreteProblem ?
244244
(false, true) : (true, true),
245245
rng = DEFAULT_RNG, scale_rates = true, useiszero = true,
246246
spatial_system = nothing, hopping_constants = nothing,
@@ -319,7 +319,7 @@ end
319319

320320
# Special dispatch for PureLeaping aggregator - bypasses all aggregation
321321
function JumpProblem(prob, aggregator::PureLeaping, jumps::JumpSet;
322-
save_positions = prob isa DiffEqBase.AbstractDiscreteProblem ?
322+
save_positions = prob isa SciMLBase.AbstractDiscreteProblem ?
323323
(false, true) : (true, true),
324324
rng = DEFAULT_RNG, scale_rates = true, useiszero = true,
325325
spatial_system = nothing, hopping_constants = nothing,

src/simple_regular_solve.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
struct SimpleTauLeaping <: DiffEqBase.AbstractDEAlgorithm end
1+
struct SimpleTauLeaping <: SciMLBase.AbstractDEAlgorithm end
22

3-
struct SimpleExplicitTauLeaping{T <: AbstractFloat} <: DiffEqBase.AbstractDEAlgorithm
3+
struct SimpleExplicitTauLeaping{T <: AbstractFloat} <: SciMLBase.AbstractDEAlgorithm
44
epsilon::T # Error control parameter
55
end
66

@@ -142,9 +142,9 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleTauLeaping;
142142
push!(tsave, tspan[2])
143143
end
144144

145-
sol = DiffEqBase.build_solution(prob, alg, tsave, usave,
145+
sol = SciMLBase.build_solution(prob, alg, tsave, usave,
146146
calculate_error = false,
147-
interp = DiffEqBase.ConstantInterpolation(tsave, usave))
147+
interp = SciMLBase.ConstantInterpolation(tsave, usave))
148148
end
149149

150150
# Compute the highest order of reaction (HOR) for each reaction j, as per Cao et al. (2006), Section IV.
@@ -399,9 +399,9 @@ function DiffEqBase.solve(jump_prob::JumpProblem, alg::SimpleExplicitTauLeaping;
399399
dtmin, saveat_times, usave, tsave, du, counts, rate_cache, rate_effective, maj,
400400
save_end)
401401

402-
sol = DiffEqBase.build_solution(prob, alg, tsave, usave,
402+
sol = SciMLBase.build_solution(prob, alg, tsave, usave,
403403
calculate_error = false,
404-
interp = DiffEqBase.ConstantInterpolation(tsave, usave))
404+
interp = SciMLBase.ConstantInterpolation(tsave, usave))
405405
return sol
406406
end
407407

src/solve.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem{P},
2-
alg::DiffEqBase.AbstractDEAlgorithm;
1+
function SciMLBase.__solve(jump_prob::SciMLBase.AbstractJumpProblem{P},
2+
alg::SciMLBase.AbstractDEAlgorithm;
33
merge_callbacks = true, kwargs...) where {P}
44
# Merge jump_prob.kwargs with passed kwargs
55
kwargs = DiffEqBase.merge_problem_kwargs(jump_prob; merge_callbacks, kwargs...)
@@ -10,7 +10,7 @@ function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem{P},
1010
end
1111

1212
#Ambiguity Fix
13-
function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem{P},
13+
function SciMLBase.__solve(jump_prob::SciMLBase.AbstractJumpProblem{P},
1414
alg::Union{SciMLBase.AbstractRODEAlgorithm, SciMLBase.AbstractSDEAlgorithm};
1515
merge_callbacks = true, kwargs...) where {P}
1616
# Merge jump_prob.kwargs with passed kwargs
@@ -23,24 +23,24 @@ end
2323

2424
# if passed a JumpProblem over a DiscreteProblem, and no aggregator is selected use
2525
# SSAStepper
26-
function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem{P};
26+
function SciMLBase.__solve(jump_prob::SciMLBase.AbstractJumpProblem{P};
2727
kwargs...) where {P <: DiscreteProblem}
28-
DiffEqBase.__solve(jump_prob, SSAStepper(); kwargs...)
28+
SciMLBase.__solve(jump_prob, SSAStepper(); kwargs...)
2929
end
3030

31-
function DiffEqBase.__solve(jump_prob::DiffEqBase.AbstractJumpProblem; kwargs...)
31+
function SciMLBase.__solve(jump_prob::SciMLBase.AbstractJumpProblem; kwargs...)
3232
error("Auto-solver selection is currently only implemented for JumpProblems defined over DiscreteProblems. Please explicitly specify a solver algorithm in calling solve.")
3333
end
3434

35-
function DiffEqBase.__init(_jump_prob::DiffEqBase.AbstractJumpProblem{P},
36-
alg::DiffEqBase.AbstractDEAlgorithm; merge_callbacks = true, kwargs...) where {P}
35+
function SciMLBase.__init(_jump_prob::SciMLBase.AbstractJumpProblem{P},
36+
alg::SciMLBase.AbstractDEAlgorithm; merge_callbacks = true, kwargs...) where {P}
3737
# Merge jump_prob.kwargs with passed kwargs
3838
kwargs = DiffEqBase.merge_problem_kwargs(_jump_prob; merge_callbacks, kwargs...)
3939

4040
__jump_init(_jump_prob, alg; kwargs...)
4141
end
4242

43-
function __jump_init(_jump_prob::DiffEqBase.AbstractJumpProblem{P}, alg;
43+
function __jump_init(_jump_prob::SciMLBase.AbstractJumpProblem{P}, alg;
4444
callback = nothing, seed = nothing,
4545
alias_jump = Threads.threadid() == 1,
4646
kwargs...) where {P}
@@ -52,7 +52,7 @@ function __jump_init(_jump_prob::DiffEqBase.AbstractJumpProblem{P}, alg;
5252
end
5353

5454
# DDEProblems do not have a recompile_flag argument
55-
if jump_prob.prob isa DiffEqBase.AbstractDDEProblem
55+
if jump_prob.prob isa SciMLBase.AbstractDDEProblem
5656
# callback comes after jump consistent with SSAStepper
5757
integrator = init(jump_prob.prob, alg;
5858
callback = CallbackSet(jump_prob.jump_callback, callback),

0 commit comments

Comments
 (0)