Skip to content

Commit

Permalink
Add rle support for BitArray (JuliaLang#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfiske authored and ararslan committed Aug 7, 2019
1 parent 0faf210 commit 416af55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ julia> rle([1,1,1,2,2,3,3,3,3,2,2,2])
([1, 2, 3, 2], [3, 2, 4, 3])
```
"""
function rle(v::Vector{T}) where T
function rle(v::AbstractVector{T}) where T
n = length(v)
vals = T[]
lens = Int[]
Expand Down
5 changes: 5 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ vals, lens = rle(z)
@test lens == [2, 2, 1, 1, 3]
@test inverse_rle(vals, lens) == z

z = BitArray([true, true, false, false, true])
(vals, lens) = rle(z)
@test vals == [true, false, true]
@test lens == [2, 2, 1]

# levelsmap
a = [1, 1, 2, 2, 2, 3, 1, 2, 2, 3, 3, 3, 3, 2]
b = [true, false, false, true, false, true, true, false]
Expand Down

0 comments on commit 416af55

Please sign in to comment.