Skip to content

Commit

Permalink
minor code fixes, bump version, and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkamins committed Aug 14, 2020
1 parent e15c3bc commit 63e252f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SentinelArrays"
uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c"
authors = ["Jacob Quinn <[email protected]>"]
version = "1.2.10"
version = "1.2.11"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
2 changes: 1 addition & 1 deletion src/chainedvector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function ChainedVector(arrays::Vector{A}) where {A <: AbstractVector{T}} where {
inds = Vector{Int}(undef, n)
x = 0
@inbounds for i = 1:n
# note that arrays[i] can have zero length
x += length(arrays[i])
inds[i] = x
end
Expand Down Expand Up @@ -57,7 +58,6 @@ end
while i > chunk_len
chunk += 1
@inbounds chunk_len = A.inds[chunk]
i <= chunk_len && break
end
x = A.arrays[chunk][1]
# find next valid index
Expand Down
24 changes: 24 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,28 @@ c2 = copy(c)
deleteat!(c2, Int[])
@test length(c2) == 15

@testset "iteration protocol on ChainedVector" begin
@test isnothing(iterate(ChainedVector([[]])))
for len in 0:6
for j in 0:len
cv = ChainedVector([1:j, j+1:len])
for (i, v) in enumerate(cv)
@test i == v
end
for k in j:len
cv = ChainedVector([1:j, j+1:k, k+1:len])
for (i, v) in enumerate(cv)
@test i == v
end
for l in k:len
cv = ChainedVector([1:j, j+1:k, k+1:l, l+1:len])
for (i, v) in enumerate(cv)
@test i == v
end
end
end
end
end
end

end

0 comments on commit 63e252f

Please sign in to comment.