Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CircularArrayBuffers"
uuid = "9de3a189-e0c0-4e15-ba3b-b14b9fb0aec1"
authors = ["Jun Tian <tianjun.cpp@gmail.com> and contributors"]
version = "0.1.3"
version = "0.1.4"

[compat]
julia = "1"
Expand Down
6 changes: 5 additions & 1 deletion src/CircularArrayBuffers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ function Base.push!(cb::CircularArrayBuffer{T, N}, data) where {T,N}
cb.nframes += 1
end
if N == 1
cb[cb.nframes] = data
if ndims(data) == 0
cb[cb.nframes] = data[]
else
cb[cb.nframes] = data
end
else
cb[ntuple(_ -> (:), N - 1)..., cb.nframes] .= data
end
Expand Down
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ using Test
@testset "CircularArrayBuffers.jl" begin
A = ones(2, 2)
C = ones(Float32, 2, 2)

# https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/551
@testset "1D with 0d data" begin
b = CircularArrayBuffer{Int}(3)
push!(b, zeros(Int, ()))
@test length(b) == 1
@test b[1] == 0
end

@testset "1D Int" begin
b = CircularArrayBuffer{Int}(3)

Expand Down