Skip to content

Commit 69ce148

Browse files
fixup! fix: fix remake with u0 dependent on Symbol parameter
1 parent 110f94b commit 69ce148

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

test/remake_tests.jl

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,36 @@ a = Remake_Test1(p = 1)
304304
@test @inferred remake(a, kwargs = (; a = 1)) == Remake_Test1(p = 1, a = 1)
305305

306306
@testset "fill_u0 and fill_p ignore identical variables with different names" begin
307-
sys = SymbolCache(Dict(:x => 1, :x2 => 1, :y => 2), Dict(:a => 1, :a2 => 1, :b => 2),
308-
:t; defaults = Dict(:x => 1, :y => 2, :a => 3, :b => 4))
307+
struct SCWrapper{S}
308+
sc::S
309+
end
310+
SymbolicIndexingInterface.symbolic_container(s::SCWrapper) = s.sc
311+
function SymbolicIndexingInterface.is_variable(s::SCWrapper, i::Symbol)
312+
if i == :x2
313+
return is_variable(s.sc, :x)
314+
end
315+
is_variable(s.sc, i)
316+
end
317+
function SymbolicIndexingInterface.variable_index(s::SCWrapper, i::Symbol)
318+
if i == :x2
319+
return variable_index(s.sc, :x)
320+
end
321+
variable_index(s.sc, i)
322+
end
323+
function SymbolicIndexingInterface.is_parameter(s::SCWrapper, i::Symbol)
324+
if i == :a2
325+
return is_parameter(s.sc, :a)
326+
end
327+
is_parameter(s.sc, i)
328+
end
329+
function SymbolicIndexingInterface.parameter_index(s::SCWrapper, i::Symbol)
330+
if i == :a2
331+
return parameter_index(s.sc, :a)
332+
end
333+
parameter_index(s.sc, i)
334+
end
335+
sys = SCWrapper(SymbolCache(Dict(:x => 1, :y => 2), Dict(:a => 1, :b => 2),
336+
:t; defaults = Dict(:x => 1, :y => 2, :a => 3, :b => 4)))
309337
function foo(du, u, p, t)
310338
du .= u .* p
311339
end
@@ -323,7 +351,7 @@ a = Remake_Test1(p = 1)
323351
end
324352

325353
@testset "value of `nothing` is ignored" begin
326-
sys = SymbolCache(Dict(:x => 1, :x2 => 1, :y => 2), Dict(:a => 1, :a2 => 1, :b => 2),
354+
sys = SymbolCache(Dict(:x => 1, :y => 2), Dict(:a => 1, :b => 2),
327355
:t; defaults = Dict(:x => 1, :y => 2, :a => 3, :b => 4))
328356
function foo(du, u, p, t)
329357
du .= u .* p

0 commit comments

Comments
 (0)