JuliaReinforcementLearning / ReinforcementLearningTrajectories.jl

A generalized experience replay buffer for reinforcement learning
MIT License
8 stars 8 forks source link

Add append for RelativeTrace to MultiplexArrays #41

Closed HenriDeh closed 1 year ago

HenriDeh commented 1 year ago

Currently, appending a Traces to a Traces fails if they contain a MultiplexTrace. This is because in the append code

    @eval function Base.$f(ts::Traces, xs::Traces)
        for k in keys(xs)
            t = ts.traces[ts.inds[k]]
            $f(t, xs[k])
        end
    end

where f is :append!, t is a MultiplexTrace and xs[k] is a RelativeTrace. Appending to a MutliplexTrace was only defined for a NamedTuple but this is not what is called in the loop above. This PR implements a second append that should only be called once by the above loop (avoiding appending twice, once :state and once :next_state).

codecov[bot] commented 1 year ago

Codecov Report

Merging #41 (8a5ac1b) into main (323793d) will increase coverage by 0.20%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #41      +/-   ##
==========================================
+ Coverage   69.73%   69.94%   +0.20%     
==========================================
  Files          13       13              
  Lines         575      579       +4     
==========================================
+ Hits          401      405       +4     
  Misses        174      174              
Impacted Files Coverage Δ
src/traces.jl 83.81% <100.00%> (+0.28%) :arrow_up:

... and 1 file with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more