Skip to content

Commit 824765f

Browse files
committed
deal with partialnt indexation
1 parent 2b2eb4a commit 824765f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/episodes.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ function Base.push!(eb::EpisodesBuffer, xs::NamedTuple)
9595
push!(eb.episodes_lengths, 0)
9696
push!(eb.sampleable_inds, 0)
9797
elseif !partial #typical inserting
98-
eb.sampleable_inds[end] = 1 #previous step is now indexable
98+
if length(eb.traces) < length(eb) && length(eb) > 2 #case when PartialNamedTuple is used. Steps are indexable one step later
99+
eb.sampleable_inds[end-1] = 1
100+
else #case when we don't, length of traces and eb will match.
101+
eb.sampleable_inds[end] = 1 #previous step is now indexable
102+
end
99103
push!(eb.sampleable_inds, 0) #this one is no longer
100104
ep_length = last(eb.step_numbers)
101105
push!(eb.episodes_lengths, ep_length)
@@ -114,6 +118,7 @@ end
114118

115119
function Base.push!(eb::EpisodesBuffer, xs::PartialNamedTuple) #wrap a NamedTuple to push without incrementing the step number.
116120
push!(eb.traces, xs.namedtuple)
121+
eb.sampleable_inds[end-1] = 1 #completes the episode trajectory.
117122
end
118123

119124
#= currently unsupported due to lack of support of appending a named tuple to traces with multiplextraces.

0 commit comments

Comments
 (0)