@@ -3,47 +3,60 @@ using StaticArrays
33
44sys = SymbolCache ([:x , :y , :z ], [:a , :b , :c ], :t )
55
6- for (buf, newbuf, newvals ) in [
6+ for (buf, newbuf, idxs, vals ) in [
77 # standard operation
8- ([1.0 , 2.0 , 3.0 ], [2.0 , 3.0 , 4.0 ], Dict ( :x => 2.0 , :y => 3.0 , :z => 4.0 ) ),
8+ ([1.0 , 2.0 , 3.0 ], [2.0 , 3.0 , 4.0 ], [ :x , :y , :z ], [ 2.0 , 3.0 , 4.0 ] ),
99 # buffer type "demotion"
10- ([1.0 , 2.0 , 3.0 ], [2 , 2 , 3 ], Dict ( :x => 2 ) ),
10+ ([1.0 , 2.0 , 3.0 ], [2 , 2 , 3 ], [ :x ], [ 2 ] ),
1111 # buffer type promotion
12- ([1 , 2 , 3 ], [2.0 , 2.0 , 3.0 ], Dict ( :x => 2.0 ) ),
12+ ([1 , 2 , 3 ], [2.0 , 2.0 , 3.0 ], [ :x ], [ 2.0 ] ),
1313 # value type promotion
14- ([1 , 2 , 3 ], [2.0 , 3.0 , 4.0 ], Dict ( :x => 2 , :y => 3.0 , :z => 4.0 ) ),
14+ ([1 , 2 , 3 ], [2.0 , 3.0 , 4.0 ], [ :x , :y , :z ], Real[ 2 , 3.0 , 4.0 ] ),
1515 # standard operation
16- ([1.0 , 2.0 , 3.0 ], [2.0 , 3.0 , 4.0 ], Dict ( :a => 2.0 , :b => 3.0 , :c => 4.0 ) ),
16+ ([1.0 , 2.0 , 3.0 ], [2.0 , 3.0 , 4.0 ], [ :a , :b , :c ], [ 2.0 , 3.0 , 4.0 ] ),
1717 # buffer type "demotion"
18- ([1.0 , 2.0 , 3.0 ], [2 , 2 , 3 ], Dict ( :a => 2 ) ),
18+ ([1.0 , 2.0 , 3.0 ], [2 , 2 , 3 ], [ :a ], [ 2 ] ),
1919 # buffer type promotion
20- ([1 , 2 , 3 ], [2.0 , 2.0 , 3.0 ], Dict ( :a => 2.0 ) ),
20+ ([1 , 2 , 3 ], [2.0 , 2.0 , 3.0 ], [ :a ], [ 2.0 ] ),
2121 # value type promotion
22- ([1 , 2 , 3 ], [2 , 3.0 , 4.0 ], Dict (:a => 2 , :b => 3.0 , :c => 4.0 ))
22+ ([1 , 2 , 3 ], [2 , 3.0 , 4.0 ], [:a , :b , :c ], Real[2 , 3.0 , 4.0 ]),
23+ # skip non-parameters
24+ ([1 , 2 , 3 ], [2.0 , 3.0 , 3.0 ], [:a , :b , :(a + b)], [2.0 , 3.0 , 5.0 ])
2325]
2426 for arrType in [Vector, SVector{3 }, MVector{3 }, SizedVector{3 }]
2527 buf = arrType (buf)
2628 newbuf = arrType (newbuf)
27- _newbuf = remake_buffer (sys, buf, newvals )
29+ _newbuf = remake_buffer (sys, buf, idxs, vals )
2830
2931 @test _newbuf != buf # should not alias
3032 @test newbuf == _newbuf # test values
3133 @test typeof (newbuf) == typeof (_newbuf) # ensure appropriate type
34+ @test_deprecated remake_buffer (sys, buf, Dict (idxs .=> vals))
3235 end
3336end
3437
35- # Tuples not allowed for state
36- for (buf, newbuf, newvals) in [
38+ for (buf, newbuf, idxs, vals) in [
3739 # standard operation
38- ((1.0 , 2.0 , 3.0 ), (2.0 , 3.0 , 4.0 ), Dict ( :a => 2.0 , :b => 3.0 , :c => 4.0 ) ),
40+ ((1.0 , 2.0 , 3.0 ), (2.0 , 3.0 , 4.0 ), [ :a , :b , :c ], [ 2.0 , 3.0 , 4.0 ] ),
3941 # buffer type "demotion"
40- ((1.0 , 2.0 , 3.0 ), (2 , 3 , 4 ), Dict ( :a => 2 , :b => 3 , :c => 4 ) ),
42+ ((1.0 , 2.0 , 3.0 ), (2 , 3 , 4 ), [ :a , :b , :c ], [ 2 , 3 , 4 ] ),
4143 # buffer type promotion
42- ((1 , 2 , 3 ), (2.0 , 3.0 , 4.0 ), Dict ( :a => 2.0 , :b => 3.0 , :c => 4.0 ) ),
44+ ((1 , 2 , 3 ), (2.0 , 3.0 , 4.0 ), [ :a , :b , :c ], [ 2.0 , 3.0 , 4.0 ] ),
4345 # value type promotion
44- ((1 , 2 , 3 ), (2 , 3.0 , 4.0 ), Dict (:a => 2 , :b => 3.0 , :c => 4.0 ))
46+ ((1 , 2 , 3 ), (2 , 3.0 , 4.0 ), [:a , :b , :c ], Real[2 , 3.0 , 4.0 ]),
47+ # standard operation
48+ ((1.0 , 2.0 , 3.0 ), (2.0 , 3.0 , 4.0 ), [:x , :y , :z ], [2.0 , 3.0 , 4.0 ]),
49+ # buffer type "demotion"
50+ ((1.0 , 2.0 , 3.0 ), (2 , 3 , 4 ), [:x , :y , :z ], [2 , 3 , 4 ]),
51+ # buffer type promotion
52+ ((1 , 2 , 3 ), (2.0 , 3.0 , 4.0 ), [:x , :y , :z ], [2.0 , 3.0 , 4.0 ]),
53+ # value type promotion
54+ ((1 , 2 , 3 ), (2 , 3.0 , 4.0 ), [:x , :y , :z ], Real[2 , 3.0 , 4.0 ]),
55+ # skip non-variables
56+ ([1 , 2 , 3 ], [2.0 , 3.0 , 3.0 ], [:x , :y , :(x + y)], [2.0 , 3.0 , 5.0 ])
4557]
46- _newbuf = remake_buffer (sys, buf, newvals )
58+ _newbuf = remake_buffer (sys, buf, idxs, vals )
4759 @test newbuf == _newbuf # test values
4860 @test typeof (newbuf) == typeof (_newbuf) # ensure appropriate type
61+ @test_deprecated remake_buffer (sys, buf, Dict (idxs .=> vals))
4962end
0 commit comments