From 4faf6562edf046f8cd073f7f42f0630a22e39663 Mon Sep 17 00:00:00 2001 From: Ludvig Killingberg Date: Fri, 13 Sep 2024 20:49:44 +0200 Subject: [PATCH] Fix NStepBatchSampler sampling out of bounds indicies When stacksize > 1, NStepBatchSampler samples inds < stacksize, which causes out of bounds errors. --- src/samplers.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/samplers.jl b/src/samplers.jl index e5443a7..3a369e8 100644 --- a/src/samplers.jl +++ b/src/samplers.jl @@ -200,7 +200,7 @@ function valid_range(s::NStepBatchSampler, eb::EpisodesBuffer) stacksize = isnothing(s.stacksize) ? 1 : s.stacksize for idx in eachindex(range) step_number = eb.step_numbers[idx] - range[idx] = step_number >= stacksize && eb.sampleable_inds[idx] + range[idx] = step_number >= stacksize && eb.sampleable_inds[idx] && idx >= stacksize ns[idx] = min(s.n, eb.episodes_lengths[idx] - step_number + 1) end return range, ns