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

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Feb 9, 2015
1 parent 3a8cad5 commit ecc430c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.3.0-
StatsBase 0.3
Compat 0.2.6
Compat 0.2.11-
20 changes: 17 additions & 3 deletions src/indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ getindex(t::AbstractDataArray, i::Real) =
## getindex: DataArray

# Scalar case
function getindex(da::DataArray, I::Real)
if getindex(da.na, I)
return NA
else
return getindex(da.data, I)
end
end
@nsplat N function getindex(da::DataArray, I::NTuple{N,Real}...)
if getindex(da.na, I...)
return NA
Expand All @@ -125,7 +132,7 @@ end
k = 1
srcextr = daextract(src)
destextr = daextract(dest)
@nloops N i dest d->(@inbounds offset_{d-1} = offset_d + (Base.unsafe_getindex(I_d, i_d)-1)*stride_d) begin
@nloops N i dest d->(@inbounds offset_{d-1} = offset_d + (Base.unsafe_getindex(I[d], i_d)-1)*stride_d) begin
@inbounds if unsafe_isna(src, srcextr, offset_0)
unsafe_dasetindex!(dest, destextr, NA, k)
else
Expand Down Expand Up @@ -159,6 +166,13 @@ end
## getindex: PooledDataArray

# Scalar case
function getindex(pda::PooledDataArray, I::Real)
if getindex(pda.refs, I) == 0
return NA
else
return pda.pool[getindex(pda.refs, I)]
end
end
@nsplat N function getindex(pda::PooledDataArray, I::NTuple{N,Real}...)
if getindex(pda.refs, I...) == 0
return NA
Expand Down Expand Up @@ -215,8 +229,8 @@ end
end

Aextr = daextract(A)
@ncall N checkbounds A J
@nexprs N d->(I_d = Base.to_index(J_d))
checkbounds(A, J...)
@nexprs N d->(I_d = Base.to_index(J[d]))
stride_1 = 1
@nexprs N d->(stride_{d+1} = stride_d*size(A,d))
@nexprs N d->(offset_d = 1) # really only need offset_$N = 1
Expand Down

1 comment on commit ecc430c

@simonster
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately converting the @ncall/J_d to tuplerefs doesn't work on older Julias, so I still need to figure out a good solution.

Please sign in to comment.