@@ -297,26 +297,54 @@ a = Remake_Test1(p = 1)
297
297
@test @inferred remake (a, kwargs = (; a = 1 )) == Remake_Test1 (p = 1 , a = 1 )
298
298
299
299
@testset " fill_u0 and fill_p ignore identical variables with different names" begin
300
- sys = SymbolCache (Dict (:x => 1 , :x2 => 1 , :y => 2 ), Dict (:a => 1 , :a2 => 1 , :b => 2 ),
301
- :t ; defaults = Dict (:x => 1 , :y => 2 , :a => 3 , :b => 4 ))
300
+ struct SCWrapper{S}
301
+ sc:: S
302
+ end
303
+ SymbolicIndexingInterface. symbolic_container (s:: SCWrapper ) = s. sc
304
+ function SymbolicIndexingInterface. is_variable (s:: SCWrapper , i:: Symbol )
305
+ if i == :x2
306
+ return is_variable (s. sc, :x )
307
+ end
308
+ is_variable (s. sc, i)
309
+ end
310
+ function SymbolicIndexingInterface. variable_index (s:: SCWrapper , i:: Symbol )
311
+ if i == :x2
312
+ return variable_index (s. sc, :x )
313
+ end
314
+ variable_index (s. sc, i)
315
+ end
316
+ function SymbolicIndexingInterface. is_parameter (s:: SCWrapper , i:: Symbol )
317
+ if i == :a2
318
+ return is_parameter (s. sc, :a )
319
+ end
320
+ is_parameter (s. sc, i)
321
+ end
322
+ function SymbolicIndexingInterface. parameter_index (s:: SCWrapper , i:: Symbol )
323
+ if i == :a2
324
+ return parameter_index (s. sc, :a )
325
+ end
326
+ parameter_index (s. sc, i)
327
+ end
328
+ sys = SCWrapper (SymbolCache (Dict (:x => 1 , :y => 2 ), Dict (:a => 1 , :b => 2 ),
329
+ :t ; defaults = Dict (:x => 1 , :y => 2 , :a => 3 , :b => 4 )))
302
330
function foo (du, u, p, t)
303
331
du .= u .* p
304
332
end
305
333
prob = ODEProblem (ODEFunction (foo; sys), [1.5 , 2.5 ], (0.0 , 1.0 ), [3.5 , 4.5 ])
306
334
u0 = Dict (:x2 => 2 )
307
335
newu0 = SciMLBase. fill_u0 (prob, u0; defs = default_values (sys))
308
336
@test length (newu0) == 2
309
- @test get (newu0, :x2 , 0 ) == 2
337
+ @test get (newu0, :x , 0 ) == 2
310
338
@test get (newu0, :y , 0 ) == 2.5
311
339
p = Dict (:a2 => 3 )
312
340
newp = SciMLBase. fill_p (prob, p; defs = default_values (sys))
313
341
@test length (newp) == 2
314
- @test get (newp, :a2 , 0 ) == 3
342
+ @test get (newp, :a , 0 ) == 3
315
343
@test get (newp, :b , 0 ) == 4.5
316
344
end
317
345
318
346
@testset " value of `nothing` is ignored" begin
319
- sys = SymbolCache (Dict (:x => 1 , :x2 => 1 , : y => 2 ), Dict (:a => 1 , :a2 => 1 , :b => 2 ),
347
+ sys = SymbolCache (Dict (:x => 1 , :y => 2 ), Dict (:a => 1 , :b => 2 ),
320
348
:t ; defaults = Dict (:x => 1 , :y => 2 , :a => 3 , :b => 4 ))
321
349
function foo (du, u, p, t)
322
350
du .= u .* p
0 commit comments