@@ -285,6 +285,7 @@ using Test
285285 show(eb);
286286 =#
287287 end
288+
288289 @testset " ElasticArraySARTSATraces with PartialNamedTuple" begin
289290 eb = EpisodesBuffer (
290291 ElasticArraySARTSATraces ()
@@ -312,8 +313,8 @@ using Test
312313 @test eb. step_numbers[end ] == 1
313314 @test eb. sampleable_inds == [1 ,1 ,1 ,1 ,1 ,0 ,0 ]
314315 @test eb[:action ][6 ] == 6
315- @test eb[:next_action ][6 ] == 6
316- @test eb[6 ][ :reward ] == 0 # 6 is not a valid index, the reward there is dummy, filled as zero
316+ @test eb[:next_action ][5 ] == 6
317+ @test eb[:reward ][ 6 ] == 0 # 6 is not a valid index, the reward there is dummy, filled as zero
317318 ep2_len = 0
318319 for (j,i) = enumerate (8 : 11 )
319320 ep2_len += 1
@@ -325,7 +326,6 @@ using Test
325326 end
326327 @test eb. sampleable_inds == [1 ,1 ,1 ,1 ,1 ,0 ,1 ,1 ,1 ,1 ,0 ]
327328 @test length (eb. traces) == 9 # an action is missing at this stage
328- # three last steps replace oldest steps in the buffer.
329329 for (i, s) = enumerate (12 : 13 )
330330 ep2_len += 1
331331 push! (eb, (state = s, action = s- 1 , reward = s- 1 , terminal = false ))
@@ -335,18 +335,18 @@ using Test
335335 @test eb. episodes_lengths[end - ep2_len: end ] == fill (ep2_len, ep2_len + 1 )
336336 end
337337 push! (eb, PartialNamedTuple ((action = 13 ,)))
338- @test length (eb. traces) == 10
338+ @test length (eb. traces) == 12
339339 # episode 1
340- for (i,s) in enumerate ( 3 : 13 )
341- if i in (4 , 11 )
340+ for i in 1 : 13
341+ if i in (6 , 13 )
342342 @test eb. sampleable_inds[i] == 0
343343 continue
344344 else
345345 @test eb. sampleable_inds[i] == 1
346346 end
347347 b = eb[i]
348- @test b[:state ] == b[:action ] == b[:reward ] == s
349- @test b[:next_state ] == b[:next_action ] == s + 1
348+ @test b[:state ] == b[:action ] == b[:reward ] == i
349+ @test b[:next_state ] == b[:next_action ] == i + 1
350350 end
351351 # episode 2
352352 # start a third episode
@@ -360,9 +360,9 @@ using Test
360360 push! (eb, (state = s, action = s- 1 , reward = s- 1 , terminal = false ))
361361 end
362362 push! (eb, PartialNamedTuple ((action = 26 ,)))
363- @test eb. sampleable_inds == [fill (true , 10 ); [false ]]
364- @test eb. episodes_lengths == fill (length (15 : 26 ), 11 )
365- @test eb. step_numbers == [3 : 13 ;]
363+ @test eb. sampleable_inds[ end - 10 : end ] == [fill (true , 10 ); [false ]]
364+ @test eb. episodes_lengths[ end - 10 : end ] == fill (length (15 : 26 ), 11 )
365+ @test eb. step_numbers[ end - 10 : end ] == [3 : 13 ;]
366366 #= Deactivated until https://github.com/JuliaArrays/ElasticArrays.jl/pull/56/files merged and pop!/popfirst! added to ElasticArrays
367367 step = popfirst!(eb)
368368 @test length(eb) == length(eb.sampleable_inds) - 1 == length(eb.step_numbers) - 1 == length(eb.episodes_lengths) - 1 == 9
0 commit comments