Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/systems/parameter_buffer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions test/initial_values.jl
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -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
Loading