Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Fix internal checkbounds
Browse files Browse the repository at this point in the history
  • Loading branch information
mbauman committed Jun 4, 2015
1 parent 744455a commit 36a5611
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,16 @@ function Base.to_index(A::DataArray)
end

# Fast implementation of checkbounds for DataArray input
Base.checkbounds(sz::Int, I::AbstractDataVector{Bool}) =
length(I) == sz || throw(BoundsError())
function Base.checkbounds{T<:Real}(sz::Int, I::AbstractDataArray{T})
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"))
extr = daextract(I)
b = true
for i = 1:length(I)
@inbounds v = unsafe_getindex_notna(I, extr, i)
checkbounds(sz, v)
b &= Base._checkbounds(sz, v)
end
b
end

# Fallbacks to avoid ambiguity
Expand Down

0 comments on commit 36a5611

Please sign in to comment.