Skip to content

Commit

Permalink
Add deprecation warnings for #509
Browse files Browse the repository at this point in the history
  • Loading branch information
simonster committed Jan 31, 2014
1 parent 3c79fd4 commit f3ac4bc
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 20 deletions.
21 changes: 1 addition & 20 deletions src/DataFrames.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,25 +140,6 @@ include("formula.jl")
include("io.jl")
include("extras.jl")
include("RDA.jl")

##############################################################################
##
## Deprecations
##
##############################################################################

Base.@deprecate vecbind vcat
Base.@deprecate rbind vcat
Base.@deprecate cbind hcat
Base.@deprecate read_table readtable
Base.@deprecate print_table printtable
Base.@deprecate write_table writetable
Base.@deprecate merge(df1::AbstractDataFrame, df2::AbstractDataFrame; on::Any = nothing, kind::Symbol = :inner) Base.join
Base.@deprecate colnames(adf::AbstractDataFrame) Base.names
Base.@deprecate colnames!(adf::AbstractDataFrame, vals) names!
Base.@deprecate coltypes(adf::AbstractDataFrame) types
Base.@deprecate EachRow eachrow
Base.@deprecate EachCol eachcol
Base.@deprecate subset sub
include("deprecated.jl")

end # module DataFrames
78 changes: 78 additions & 0 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using Base.depwarn

Base.@deprecate vecbind vcat
Base.@deprecate rbind vcat
Base.@deprecate cbind hcat
Base.@deprecate read_table readtable
Base.@deprecate print_table printtable
Base.@deprecate write_table writetable
Base.@deprecate merge(df1::AbstractDataFrame, df2::AbstractDataFrame; on::Any = nothing, kind::Symbol = :inner) Base.join
Base.@deprecate colnames(adf::AbstractDataFrame) Base.names
Base.@deprecate colnames!(adf::AbstractDataFrame, vals) names!
Base.@deprecate coltypes(adf::AbstractDataFrame) types
Base.@deprecate EachRow eachrow
Base.@deprecate EachCol eachcol
Base.@deprecate subset sub

function DataFrame{T<:String}(columns::Vector{Any}, cnames::Vector{T})
depwarn("DataFrame(::Vector{Any}, ::Vector{T<:String}) is deprecated, use DataFrame(::Vector{Any}, ::Vector{Symbol}) instead",
:DataFrame)
DataFrame(columns, map(symbol, cnames))
end

function DataFrame{D <: Associative, T <: String}(ds::Vector{D}, ks::Vector{T})
depwarn("DataFrame(::Vector{D<:Associative}, ::Vector{T<:String}) is deprecated, use DataFrame(::Vector{D<:Associative}, ::Vector{Symbol}) instead",
:DataFrame)
DataFrame(ds, map(symbol, ks))
end

function pool!(df::AbstractDataFrame, cname::String)
depwarn("pool!(::AbstractDataFrame, ::String) is deprecated, use pool!(::AbstractDataFrame, ::Symbol) instead", :pool!)
pool!(df, symbol(cname))
end

function pool!{T<:String}(df::AbstractDataFrame, cname::Vector{T})
depwarn("pool!(::AbstractDataFrame, ::Vector{T<:String}) is deprecated, use pool!(::AbstractDataFrame, ::Vector{T<:Symbol}) instead", :pool!)
pool!(df, map(symbol, cnames))
end

function Base.getindex(df::DataFrame, col_ind::String)
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :getindex)
getindex(df, symbol(col_ind))
end

function Base.getindex{T<:String}(df::DataFrame, col_inds::AbstractVector{T})
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :getindex)
getindex(df, map(symbol, col_inds))
end

function Base.getindex(df::DataFrame, row_ind, col_ind::String)
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :getindex)
getindex(df, row_ind, symbol(col_ind))
end

function Base.getindex{T<:String}(df::DataFrame, row_ind, col_inds::AbstractVector{T})
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :getindex)
getindex(df, row_ind, map(symbol, col_inds))
end

function Base.setindex!(df::DataFrame, v, col_ind::String)
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :setindex!)
setindex!(df, v, symbol(col_ind))
end

function Base.setindex!{T<:String}(df::DataFrame, v, col_inds::AbstractVector{T})
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :setindex!)
setindex!(df, v, map(symbol, col_ind))
end

function Base.setindex!(df::DataFrame, v, row_ind, col_ind::String)
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :setindex!)
setindex!(df, v, row_ind, symbol(col_ind))
end

function Base.assign{T<:String}(df::DataFrame, v, row_ind, col_inds::AbstractVector{T})
depwarn("indexing DataFrames with strings is deprecated; use symbols instead", :setindex!)
setindex!(df, v, row_ind, map(symbol, col_ind))
end

0 comments on commit f3ac4bc

Please sign in to comment.