Skip to content

Commit 4faf656

Browse files
authored
Fix NStepBatchSampler sampling out of bounds indicies
When stacksize > 1, NStepBatchSampler samples inds < stacksize, which causes out of bounds errors.
1 parent de01fb3 commit 4faf656

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/samplers.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function valid_range(s::NStepBatchSampler, eb::EpisodesBuffer)
200200
stacksize = isnothing(s.stacksize) ? 1 : s.stacksize
201201
for idx in eachindex(range)
202202
step_number = eb.step_numbers[idx]
203-
range[idx] = step_number >= stacksize && eb.sampleable_inds[idx]
203+
range[idx] = step_number >= stacksize && eb.sampleable_inds[idx] && idx >= stacksize
204204
ns[idx] = min(s.n, eb.episodes_lengths[idx] - step_number + 1)
205205
end
206206
return range, ns

0 commit comments

Comments
 (0)