Skip to content

Commit 8b8bbd8

Browse files
committed
Merge branch 'master' of github.com:findmyway/CircularArrayBuffers.jl
2 parents 01cf9e3 + d9675ad commit 8b8bbd8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CircularArrayBuffers"
22
uuid = "9de3a189-e0c0-4e15-ba3b-b14b9fb0aec1"
33
authors = ["Jun Tian <tianjun.cpp@gmail.com> and contributors"]
4-
version = "0.1.3"
4+
version = "0.1.4"
55

66
[compat]
77
julia = "1"

src/CircularArrayBuffers.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ function Base.push!(cb::CircularArrayBuffer{T,N}, data) where {T,N}
7272
cb.nframes += 1
7373
end
7474
if N == 1
75-
cb[cb.nframes] = data
75+
if ndims(data) == 0
76+
cb[cb.nframes] = data[]
77+
else
78+
cb[cb.nframes] = data
79+
end
7680
else
7781
cb[ntuple(_ -> (:), N - 1)..., cb.nframes] .= data
7882
end

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ using Test
44
@testset "CircularArrayBuffers.jl" begin
55
A = ones(2, 2)
66
C = ones(Float32, 2, 2)
7+
8+
# https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/551
9+
@testset "1D with 0d data" begin
10+
b = CircularArrayBuffer{Int}(3)
11+
push!(b, zeros(Int, ()))
12+
@test length(b) == 1
13+
@test b[1] == 0
14+
end
15+
716
@testset "1D Int" begin
817
b = CircularArrayBuffer{Int}(3)
918

0 commit comments

Comments
 (0)