Skip to content

Commit b4716dd

Browse files
Merge pull request #127 from SciML/as/remake
feat: add `SciMLBase.remake` method for generated functions
2 parents dc655a2 + dbf3765 commit b4716dd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/ode_def_opts.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ function ode_def_opts(name::Symbol, opts::Dict{Symbol, Bool}, curmod, ex::Expr,
186186

187187
(f::$name)(args...) = f.f(args...)
188188

189+
function ParameterizedFunctions.SciMLBase.remake(func::$name; kwargs...)
190+
return func
191+
end
192+
189193
$fname($(f_ex_oop.args[1].args...)) = $(f_ex_oop.args[2])
190194
$fname($(f_ex_iip.args[1].args...)) = $(f_ex_iip.args[2])
191195
$full_tex

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,13 @@ sir_ode = @ode_def SIRModel begin
110110
dI = b * S * I - g * I
111111
dR = g * I
112112
end b g
113+
114+
@testset "remake" begin
115+
f = @ode_def begin
116+
dx = a * x - b * x * y
117+
dy = -c * y + d * x * y
118+
end a b c d
119+
# pass dummy values, `remake` should ignore everything
120+
f2 = remake(f; f = nothing, initialization_data = 3)
121+
@test f2 === f
122+
end

0 commit comments

Comments
 (0)