From c317809af1068708d96de6e7c1fbe08f7ddf112c Mon Sep 17 00:00:00 2001 From: Torkel Date: Tue, 4 Apr 2023 11:12:46 -0400 Subject: [PATCH 1/3] testfix --- src/problem.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/problem.jl b/src/problem.jl index d0bde3c3..7c07a36c 100644 --- a/src/problem.jl +++ b/src/problem.jl @@ -119,6 +119,12 @@ function DiffEqBase.remake(thing::JumpProblem; kwargs...) thing.kwargs) end +# when setindex! is used. +function Base.setindex!(prob::JumpProblem, args...; kwargs...) + ___internal_setindex!(prob.prob, args...; kwargs...) + update_parameters!(prob.massaction_jump, prob.dprob.p; kwargs...) +end + DiffEqBase.isinplace(::JumpProblem{iip}) where {iip} = iip JumpProblem(prob::JumpProblem) = prob From 887e0db7c0c2e6efc4a37ccd719a0fa0b1b4c2fc Mon Sep 17 00:00:00 2001 From: Torkel Date: Tue, 4 Apr 2023 11:23:01 -0400 Subject: [PATCH 2/3] getindex as well --- src/JumpProcesses.jl | 2 +- src/problem.jl | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/JumpProcesses.jl b/src/JumpProcesses.jl index 7b1915f7..64273373 100644 --- a/src/JumpProcesses.jl +++ b/src/JumpProcesses.jl @@ -7,7 +7,7 @@ using RandomNumbers, TreeViews, LinearAlgebra, Markdown, DocStringExtensions using DataStructures, PoissonRandom, Random, ArrayInterface using FunctionWrappers, UnPack using Graphs -using SciMLBase: SciMLBase +using SciMLBase: SciMLBase, ___internal_setindex! using Base.FastMath: add_fast import DiffEqBase: DiscreteCallback, init, solve, solve!, plot_indices, initialize! diff --git a/src/problem.jl b/src/problem.jl index 7c07a36c..6b8b1bac 100644 --- a/src/problem.jl +++ b/src/problem.jl @@ -122,9 +122,14 @@ end # when setindex! is used. function Base.setindex!(prob::JumpProblem, args...; kwargs...) ___internal_setindex!(prob.prob, args...; kwargs...) - update_parameters!(prob.massaction_jump, prob.dprob.p; kwargs...) + if using_params(prob.massaction_jump) + update_parameters!(prob.massaction_jump, prob.prob.p) + end end +# when getindex is used. +Base.getindex(prob::JumpProblem, args...; kwargs...) = Base.getindex(prob.prob, args...; kwargs...) + DiffEqBase.isinplace(::JumpProblem{iip}) where {iip} = iip JumpProblem(prob::JumpProblem) = prob From ad4d693caf2d17898dfebc9660a7b3d25e6e14e3 Mon Sep 17 00:00:00 2001 From: Torkel Date: Tue, 4 Apr 2023 11:24:34 -0400 Subject: [PATCH 3/3] formating --- src/problem.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/problem.jl b/src/problem.jl index 6b8b1bac..2dade240 100644 --- a/src/problem.jl +++ b/src/problem.jl @@ -128,7 +128,9 @@ function Base.setindex!(prob::JumpProblem, args...; kwargs...) end # when getindex is used. -Base.getindex(prob::JumpProblem, args...; kwargs...) = Base.getindex(prob.prob, args...; kwargs...) +function Base.getindex(prob::JumpProblem, args...; kwargs...) + Base.getindex(prob.prob, args...; kwargs...) +end DiffEqBase.isinplace(::JumpProblem{iip}) where {iip} = iip JumpProblem(prob::JumpProblem) = prob