diff --git a/src/systems/parameter_buffer.jl b/src/systems/parameter_buffer.jl index 4f1bd1a234..23fb2e11a7 100644 --- a/src/systems/parameter_buffer.jl +++ b/src/systems/parameter_buffer.jl @@ -444,6 +444,9 @@ end function validate_parameter_type(ic::IndexCache, stype, sz, sym, index, val) (; portion) = index + if stype <: FnType + stype = fntype_to_function_type(stype) + end # Nonnumeric parameters have to match the type if portion === NONNUMERIC_PORTION val isa stype && return nothing diff --git a/test/initial_values.jl b/test/initial_values.jl index f413c1a018..dbe08962cd 100644 --- a/test/initial_values.jl +++ b/test/initial_values.jl @@ -1,6 +1,7 @@ using ModelingToolkit using ModelingToolkit: t_nounits as t, D_nounits as D, get_u0 using OrdinaryDiffEq +using DataInterpolations using SymbolicIndexingInterface: getu @variables x(t)[1:3]=[1.0, 2.0, 3.0] y(t) z(t)[1:2] @@ -219,3 +220,19 @@ end @test_throws ["a(t)", "c(t)"] ODEProblem( sys, [e => 2, a => b, b => a + 1, c => d, d => c + 1], (0, 1)) end + +@testset "Issue#3490: `remake` works with callable parameters" begin + ts = collect(0.0:0.1:10.0) + spline = LinearInterpolation(ts .^ 2, ts) + Tspline = typeof(spline) + @variables x(t) + @parameters (interp::Tspline)(..) + + @mtkbuild sys = ODESystem(D(x) ~ interp(t), t) + + prob = ODEProblem(sys, [x => 0.0], (0.0, 1.0), [interp => spline]) + spline2 = LinearInterpolation(ts .^ 2, ts .^ 2) + p_new = [interp => spline2] + prob2 = remake(prob; p = p_new) + @test prob2.ps[interp] == spline2 +end