Skip to content

Commit 9560073

Browse files
committed
test for correct samples
1 parent 1407351 commit 9560073

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/samplers.jl

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "Samplers" begin
1+
#@testset "Samplers" begin
22
@testset "BatchSampler" begin
33
sz = 32
44
s = BatchSampler(sz)
@@ -205,19 +205,25 @@
205205
@testset "EpisodesSampler" begin
206206
s = EpisodesSampler()
207207
eb = EpisodesBuffer(CircularArraySARTSTraces(capacity=10))
208-
push!(eb, (state = 1, action = 1))
208+
push!(eb, (state = 1,))
209209
for i = 1:5
210-
push!(eb, (state = i+1, action =i+1, reward = i, terminal = false))
210+
push!(eb, (state = i+1, action =i, reward = i, terminal = false))
211211
end
212-
push!(eb, (state = 7, action = 7))
212+
push!(eb, (state = 7,))
213213
for (j,i) = enumerate(8:12)
214-
push!(eb, (state = i, action =i, reward = i-1, terminal = false))
214+
push!(eb, (state = i, action =i-1, reward = i-1, terminal = false))
215215
end
216216

217217
b = sample(s, eb)
218218
@test length(b) == 2
219-
@test length(b[1][:state]) == 5
220-
@test length(b[2][:state]) == 6
219+
@test b[1][:state] == [2:5;]
220+
@test b[1][:next_state] == [3:6;]
221+
@test b[1][:action] == [2:5;]
222+
@test b[1][:reward] == [2:5;]
223+
@test b[2][:state] == [7:11;]
224+
@test b[2][:next_state] == [8:12;]
225+
@test b[2][:action] == [7:11;]
226+
@test b[2][:reward] == [7:11;]
221227

222228
for (j,i) = enumerate(2:5)
223229
push!(eb, (state = i, action =i, reward = i-1, terminal = false))
@@ -241,8 +247,8 @@
241247

242248
b = sample(s, eb)
243249
@test length(b) == 2
244-
@test length(b[1][:state]) == 5
245-
@test length(b[2][:state]) == 6
250+
@test length(b[1][:state]) == 4
251+
@test length(b[2][:state]) == 5
246252
@test !haskey(b[1], :action)
247253
end
248254
end

0 commit comments

Comments
 (0)