Skip to content

Commit

Permalink
Fix ref{*} methods
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmyleswhite committed Mar 20, 2013
1 parent f91b63a commit eade720
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/dataframe.jl
Expand Up @@ -383,7 +383,7 @@ function getindex(df::DataFrame, col_ind::ColumnIndex)
end

# df[MultiColumnIndex] => (Sub)?DataFrame
function ref{T <: ColumnIndex}(df::DataFrame, col_inds::AbstractVector{T})
function getindex{T <: ColumnIndex}(df::DataFrame, col_inds::AbstractVector{T})
selected_columns = df.colindex[col_inds]
new_columns = df.columns[selected_columns]
return DataFrame(new_columns, Index(df.colindex.names[selected_columns]))
Expand All @@ -396,20 +396,20 @@ function getindex(df::DataFrame, row_ind::Real, col_ind::ColumnIndex)
end

# df[SingleRowIndex, MultiColumnIndex] => (Sub)?DataFrame
function ref{T <: ColumnIndex}(df::DataFrame, row_ind::Real, col_inds::AbstractVector{T})
function getindex{T <: ColumnIndex}(df::DataFrame, row_ind::Real, col_inds::AbstractVector{T})
selected_columns = df.colindex[col_inds]
new_columns = {dv[[row_ind]] for dv in df.columns[selected_columns]}
return DataFrame(new_columns, Index(df.colindex.names[selected_columns]))
end

# df[MultiRowIndex, SingleColumnIndex] => (Sub)?AbstractDataVector
function ref{T <: Real}(df::DataFrame, row_inds::AbstractVector{T}, col_ind::ColumnIndex)
function getindex{T <: Real}(df::DataFrame, row_inds::AbstractVector{T}, col_ind::ColumnIndex)
selected_column = df.colindex[col_ind]
return df.columns[selected_column][row_inds]
end

# df[MultiRowIndex, MultiColumnIndex] => (Sub)?DataFrame
function ref{R <: Real, T <: ColumnIndex}(df::DataFrame, row_inds::AbstractVector{R}, col_inds::AbstractVector{T})
function getindex{R <: Real, T <: ColumnIndex}(df::DataFrame, row_inds::AbstractVector{R}, col_inds::AbstractVector{T})
selected_columns = df.colindex[col_inds]
new_columns = {dv[row_inds] for dv in df.columns[selected_columns]}
return DataFrame(new_columns, Index(df.colindex.names[selected_columns]))
Expand All @@ -418,9 +418,9 @@ end
# Special cases involving expressions
getindex(df::DataFrame, ex::Expr) = getindex(df, with(df, ex))
getindex(df::DataFrame, ex::Expr, c::ColumnIndex) = getindex(df, with(df, ex), c)
ref{T <: ColumnIndex}(df::DataFrame, ex::Expr, c::AbstractVector{T}) = getindex(df, with(df, ex), c)
getindex{T <: ColumnIndex}(df::DataFrame, ex::Expr, c::AbstractVector{T}) = getindex(df, with(df, ex), c)
getindex(df::DataFrame, c::Real, ex::Expr) = getindex(df, c, with(df, ex))
ref{T <: Real}(df::DataFrame, c::AbstractVector{T}, ex::Expr) = getindex(df, c, with(df, ex))
getindex{T <: Real}(df::DataFrame, c::AbstractVector{T}, ex::Expr) = getindex(df, c, with(df, ex))
getindex(df::DataFrame, ex1::Expr, ex2::Expr) = getindex(df, with(df, ex1), with(df, ex2))

##############################################################################
Expand Down
10 changes: 5 additions & 5 deletions src/reshape.jl
Expand Up @@ -144,7 +144,7 @@ function getindex(v::StackedVector,i::Real)
v.components[j][k]
end

function ref{I<:Real}(v::StackedVector,i::AbstractVector{I})
function getindex{I<:Real}(v::StackedVector,i::AbstractVector{I})
result = similar(v.components[1], length(i))
for idx in 1:length(i)
result[idx] = v[i[idx]]
Expand All @@ -165,11 +165,11 @@ repl_show(io::IO, v::StackedVector) = internal_repl_show_vector(io, v)

PooledDataArray(v::StackedVector) = PooledDataArray(v[:]) # could be more efficient

function ref{T,I<:Real}(v::RepeatedVector{T},i::AbstractVector{I})
function getindex{T,I<:Real}(v::RepeatedVector{T},i::AbstractVector{I})
j = mod(i - 1, length(v.parent)) + 1
v.parent[j]
end
function ref{T}(v::RepeatedVector{T},i::Real)
function getindex{T}(v::RepeatedVector{T},i::Real)
j = mod(i - 1, length(v.parent)) + 1
v.parent[j]
end
Expand All @@ -194,11 +194,11 @@ function PooledDataArray(v::RepeatedVector)
res
end

function ref{T}(v::EachRepeatedVector{T},i::Real)
function getindex{T}(v::EachRepeatedVector{T},i::Real)
j = div(i - 1, v.n) + 1
v.parent[j]
end
function ref{T,I<:Real}(v::EachRepeatedVector{T},i::AbstractVector{I})
function getindex{T,I<:Real}(v::EachRepeatedVector{T},i::AbstractVector{I})
j = div(i - 1, v.n) + 1
v.parent[j]
end
Expand Down

0 comments on commit eade720

Please sign in to comment.