Skip to content

Commit 87c7240

Browse files
Merge pull request SciML#718 from AayushSabharwal/as/remake-empty-tuple
fix: handle edge case when `()` as parameters triggers error
2 parents f6bba73 + 2827815 commit 87c7240

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/remake.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,13 @@ function updated_u0_p(prob, u0, p; interpret_symbolicmap = true, use_defaults =
534534
return state_values(prob), parameter_values(prob)
535535
end
536536
if !has_sys(prob.f)
537-
if interpret_symbolicmap && eltype(p) <: Pair
537+
if interpret_symbolicmap && eltype(p) !== Union{} && eltype(p) <: Pair
538538
throw(ArgumentError("This problem does not support symbolic maps with " *
539539
"`remake`, i.e. it does not have a symbolic origin. Please use `remake`" *
540540
"with the `p` keyword argument as a vector of values (paying attention to" *
541541
"parameter order) or pass `interpret_symbolicmap = false` as a keyword argument"))
542542
end
543-
if eltype(u0) <: Pair
543+
if eltype(u0) !== Union{} && eltype(u0) <: Pair
544544
throw(ArgumentError("This problem does not support symbolic maps with" *
545545
" remake, i.e. it does not have a symbolic origin. Please use `remake`" *
546546
"with the `u0` keyword argument as a vector of values, paying attention to the order."))

test/remake_tests.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,14 @@ for prob in deepcopy(probs)
254254
ForwardDiff.derivative(fakeloss!, 1.0)
255255
end
256256
end
257+
258+
# eltype(()) <: Pair, so ensure that this doesn't error
259+
function lorenz!(du, u, _, t)
260+
du[1] = 1 * (u[2] - u[1])
261+
du[2] = u[1] * (2 - u[3]) - u[2]
262+
du[3] = u[1] * u[2] - 3 * u[3]
263+
end
264+
u0 = [1.0; 2.0; 3.0]
265+
tspan = (0.0, 100.0)
266+
prob = ODEProblem(lorenz!, u0, tspan, nothing)
267+
@test_nowarn remake(prob, p = (), interpret_symbolicmap = true)

0 commit comments

Comments
 (0)