Skip to content

Commit c8f523e

Browse files
committed
fix MovingWindow display when buffer isn't full
1 parent 7fbb87e commit c8f523e

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# Updated by PkgExplorer.jl at 2023-07-03 09:17:32 (UTC).
21
name = "OnlineStats"
32
uuid = "a15396b6-48d5-5d58-9928-6d29437db91e"
4-
version = "1.6.2"
3+
version = "1.6.3"
54

65
[deps]
76
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

src/stats/stats.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ end
381381
MovingWindow(b::Int, T::Type) = MovingWindow(T[], b, 1, 0)
382382
MovingWindow(T::Type, b::Int) = MovingWindow(b, T)
383383
function value(o::MovingWindow)
384+
o.n < o.b && return o.value
384385
perm = vcat(collect(o.first:o.b), collect(1:(o.first-1)))
385386
o.first = 1
386387
permute!(o.value, perm)

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ end
351351
end
352352
#-----------------------------------------------------------------------# MovingWindow
353353
@testset "MovingWindow" begin
354+
@test MovingWindow(10,Int) == MovingWindow(Int, 10)
355+
string(MovingWindow)
354356
o = fit!(MovingWindow(10, Int), 1:12)
355357
for i in 1:10
356358
@test o[i] == (1:12)[i + 2]

0 commit comments

Comments
 (0)