Skip to content

Commit b282837

Browse files
committed
support colon in last dimension
1 parent 73ccf07 commit b282837

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/CircularArrayBuffers.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ end
9797
end
9898

9999
_buffer_frame(cb::CircularArrayBuffer, I::AbstractArray{<:Integer}) = map(i -> _buffer_frame(cb, i), I)
100+
_buffer_frame(cb::CircularArrayBuffer, ::Colon) = _buffer_frame(cb, axes(cb)[end])
100101

101102
function Base.empty!(cb::CircularArrayBuffer)
102103
cb.nframes = 0

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ CUDA.allowscalar(false)
6363
@test b[end] == 5
6464
@test b[1:end] == [3, 4, 5]
6565

66+
# https://github.com/JuliaReinforcementLearning/CircularArrayBuffers.jl/issues/14
67+
@test b[:] == [3, 4, 5]
68+
6669
empty!(b)
6770
@test isfull(b) == false
6871
@test isempty(b) == true
@@ -147,6 +150,9 @@ CUDA.allowscalar(false)
147150

148151
@test b == reshape([c for x in 3:5 for c in x * A], 2, 2, 3)
149152

153+
# https://github.com/JuliaReinforcementLearning/CircularArrayBuffers.jl/issues/14
154+
@test b[:, :, :] == reshape([c for x in 3:5 for c in x * A], 2, 2, 3)
155+
150156
push!(b, 6 * ones(Float32, 2, 2))
151157
push!(b, 7 * ones(Int, 2, 2))
152158
@test b == reshape([c for x in 5:7 for c in x * A], 2, 2, 3)

0 commit comments

Comments
 (0)