Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ function Base.to_index(A::DataArray)
end

# Fast implementation of checkbounds for DataArray input
# This overrides an internal API that changed after #10525
# This overrides an internal API that changed after JuliaLang/julia#10525,
# and which was finally stabilized and documented with JuliaLang/julia#11895.
if VERSION < v"0.4-dev+5194"
Base.checkbounds(sz::Int, I::AbstractDataVector{Bool}) =
length(I) == sz || throw(BoundsError())
Expand All @@ -99,7 +100,7 @@ if VERSION < v"0.4-dev+5194"
checkbounds(sz, v)
end
end
else
elseif VERSION < v"0.4-dev+6993"
Base._checkbounds(sz::Int, I::AbstractDataVector{Bool}) = length(I) == sz
function Base._checkbounds{T<:Real}(sz::Int, I::AbstractDataArray{T})
anyna(I) && throw(NAException("cannot index into an array with a DataArray containing NAs"))
Expand All @@ -111,6 +112,18 @@ else
end
b
end
else
Base.checkbounds(::Type{Bool}, sz::Int, I::AbstractDataVector{Bool}) = length(I) == sz
function Base.checkbounds{T<:Real}(::Type{Bool}, sz::Int, I::AbstractDataArray{T})
anyna(I) && throw(NAException("cannot index into an array with a DataArray containing NAs"))
extr = daextract(I)
b = true
for i = 1:length(I)
@inbounds v = unsafe_getindex_notna(I, extr, i)
b &= Base.checkbounds(Bool, sz, v)
end
b
end
end

# Indexing uses undocumented APIs to determine the resulting shape. These APIs
Expand Down