diff --git a/src/CircularArrayBuffers.jl b/src/CircularArrayBuffers.jl index 5c290fd..f4aa7c5 100644 --- a/src/CircularArrayBuffers.jl +++ b/src/CircularArrayBuffers.jl @@ -97,6 +97,7 @@ end end _buffer_frame(cb::CircularArrayBuffer, I::AbstractArray{<:Integer}) = map(i -> _buffer_frame(cb, i), I) +_buffer_frame(cb::CircularArrayBuffer, ::Colon) = _buffer_frame(cb, axes(cb)[end]) function Base.empty!(cb::CircularArrayBuffer) cb.nframes = 0 diff --git a/test/runtests.jl b/test/runtests.jl index b24af66..1e0f65d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -63,6 +63,9 @@ CUDA.allowscalar(false) @test b[end] == 5 @test b[1:end] == [3, 4, 5] + # https://github.com/JuliaReinforcementLearning/CircularArrayBuffers.jl/issues/14 + @test b[:] == [3, 4, 5] + empty!(b) @test isfull(b) == false @test isempty(b) == true @@ -147,6 +150,9 @@ CUDA.allowscalar(false) @test b == reshape([c for x in 3:5 for c in x * A], 2, 2, 3) + # https://github.com/JuliaReinforcementLearning/CircularArrayBuffers.jl/issues/14 + @test b[:, :, :] == reshape([c for x in 3:5 for c in x * A], 2, 2, 3) + push!(b, 6 * ones(Float32, 2, 2)) push!(b, 7 * ones(Int, 2, 2)) @test b == reshape([c for x in 5:7 for c in x * A], 2, 2, 3)