From bb384b3826177a598368124cbf0d1300c83cf1b7 Mon Sep 17 00:00:00 2001 From: "William S. Moses" Date: Tue, 12 Sep 2023 21:11:27 -0400 Subject: [PATCH 1/2] Make ODEProblem into a mutable struct --- src/problems/ode_problems.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index 20949d644..a4dcbc544 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -94,7 +94,7 @@ prob = ODEProblemLibrary.prob_ode_linear sol = solve(prob) ``` """ -struct ODEProblem{uType, tType, isinplace, P, F, K, PT} <: +mutable struct ODEProblem{uType, tType, isinplace, P, F, K, PT} <: AbstractODEProblem{uType, tType, isinplace} """The ODE is `du = f(u,p,t)` for out-of-place and f(du,u,p,t) for in-place.""" f::F From 97517ddb96ea6a48f13e3e15d5d3056a564d3799 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Thu, 21 Sep 2023 20:27:04 -0400 Subject: [PATCH 2/2] add a big warning on mutation of ODEProblem --- src/problems/ode_problems.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/problems/ode_problems.jl b/src/problems/ode_problems.jl index a4dcbc544..ce4425db3 100644 --- a/src/problems/ode_problems.jl +++ b/src/problems/ode_problems.jl @@ -162,6 +162,16 @@ mutable struct ODEProblem{uType, tType, isinplace, P, F, K, PT} <: end TruncatedStacktraces.@truncate_stacktrace ODEProblem 3 1 2 +function Base.setproperty!(prob::ODEProblem, s::Symbol, v) + @warn "Mutation of ODEProblem detected. SciMLBase v2.0 has made ODEProblem temporarily mutable in order to allow for interfacing with EnzymeRules due to a current limitation in the rule system. This change is only intended to be temporary and ODEProblem will return to being a struct in a later non-breaking release. Do not rely on this behavior, use with caution." + Base.setfield!(prob, s, v) +end + +function Base.setproperty!(prob::ODEProblem, s::Symbol, v, order::Symbol) + @warn "Mutation of ODEProblem detected. SciMLBase v2.0 has made ODEProblem temporarily mutable in order to allow for interfacing with EnzymeRules due to a current limitation in the rule system. This change is only intended to be temporary and ODEProblem will return to being a struct in a later non-breaking release. Do not rely on this behavior, use with caution." + Base.setfield!(prob, s, v, order) +end + """ ODEProblem(f::ODEFunction,u0,tspan,p=NullParameters(),callback=CallbackSet())