Skip to content

Commit 214431c

Browse files
author
Michael Abbott
committed
allow BitArray
1 parent 4b2e7cd commit 214431c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/struct.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ for (bget, rget, cpy) in [(:getindex, :keys_getindex, :copy), (:view, :keys_view
6666
@inbounds Base.$bget(parent(A), I...)
6767
end
6868

69-
@inline function Base.$bget(A::KeyedArray, I::Union{Colon, CartesianIndex})
69+
@inline function Base.$bget(A::KeyedArray, I::Union{Colon, CartesianIndex, BitArray})
7070
@boundscheck checkbounds(parent(A), I)
7171
@inbounds Base.$bget(parent(A), I)
7272
end

test/_basic.jl

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using Test, AxisKeys
2222
@test R[:] == vec(R.data)
2323
@test_broken R[1:2, 1, 1] == R.data[1:2, 1, 1] # trailing 1s are broken
2424
@test axiskeys(R[:, [0.9,0.1,0.9,0.1] .> 0.5],2) == [10,30]
25-
@test_broken ndims(R[R.data .> 0.5]) == 1 # BitArray{2} is broken
25+
@test ndims(R[R.data .> 0.5]) == 1
2626

2727
@test_throws Exception R(:nope) # ideally ArgumentError
2828
@test_throws Exception R('z') # ideally BoundsError?
@@ -197,6 +197,15 @@ end
197197

198198
end
199199
end
200+
@testset "bitarray" begin
201+
202+
x = wrapdims(rand(3,4), a=11:13, b=21:24.0)
203+
b = rand(12) .> 0.5
204+
@test length(x[b]) == sum(b)
205+
m = rand(3,4) .> 0.5 # BitArray{2}
206+
@test size(x[m]) == (sum(m),)
207+
208+
end
200209
@testset "mutation" begin
201210

202211
V = wrapdims([3,5,7,11], μ=10:10:40)

0 commit comments

Comments
 (0)