From 0cfb6ad02d43cbb27e6e72cbab68f2e72d0eadc9 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Mon, 25 Jul 2016 22:40:38 -0700 Subject: [PATCH 1/4] Run 0.5 on Travis and add 0.5 badge --- .travis.yml | 7 ++++--- README.md | 1 + src/compositedataframe.jl | 42 +++++++++++++++++++-------------------- 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0361a73c..d425b511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,13 @@ language: julia julia: - 0.4 + - nightly os: - linux notifications: email: false -script: - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi - - julia -e 'Pkg.clone(pwd()); Pkg.build("DataFramesMeta"); Pkg.test("DataFramesMeta", coverage=true)' +# script: +# - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi +# - julia -e 'Pkg.clone(pwd()); Pkg.build("DataFramesMeta"); Pkg.test("DataFramesMeta", coverage=true)' after_success: - julia -e 'cd(Pkg.dir("DataFramesMeta")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' diff --git a/README.md b/README.md index 98a5bf3c..07efcd04 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # DataFramesMeta.jl [![DataFramesMeta](http://pkg.julialang.org/badges/DataFramesMeta_0.4.svg)](http://pkg.julialang.org/?pkg=DataFramesMeta&ver=0.4) +[![DataFramesMeta](http://pkg.julialang.org/badges/DataFramesMeta_0.5.svg)](http://pkg.julialang.org/?pkg=DataFramesMeta) [![Coverage Status](http://img.shields.io/coveralls/JuliaStats/DataFramesMeta.jl.svg)](https://coveralls.io/r/JuliaStats/DataFramesMeta.jl) [![Build Status](https://travis-ci.org/JuliaStats/DataFramesMeta.jl.svg?branch=master)](https://travis-ci.org/JuliaStats/DataFramesMeta.jl) diff --git a/src/compositedataframe.jl b/src/compositedataframe.jl index 4a3fc22a..0eba6747 100644 --- a/src/compositedataframe.jl +++ b/src/compositedataframe.jl @@ -1,13 +1,13 @@ using Compat -export AbstractCompositeDataFrame, AbstractCompositeDataFrameRow, +export AbstractCompositeDataFrame, AbstractCompositeDataFrameRow, CompositeDataFrame, row """ AbstractCompositeDataFrame - + An abstract type that is an `AbstractDataFrame`. Each type that inherits from -this is expected to be a type-stable data frame. +this is expected to be a type-stable data frame. """ abstract AbstractCompositeDataFrame <: AbstractDataFrame @@ -16,10 +16,10 @@ abstract AbstractCompositeDataFrameRow """ row(cdf::AbstractCompositeDataFrame, i) - + Return row `i` of `cdf` as a `CompositeDataFrameRow`. This object has the same fields as `cdf` where the type of each field is taken from the `eltype` -of the field in `cdf`. +of the field in `cdf`. See also `eachrow(cdf)`. @@ -43,7 +43,7 @@ A constructor of an `AbstractCompositeDataFrame` that mimics the `DataFrame` constructor. This returns a composite type (not immutable) that is an `AbstractCompositeDataFrame`. -This uses `eval` to create a new type within the current module. +This uses `eval` to create a new type within the current module. ### Arguments @@ -90,7 +90,7 @@ CompositeDataFrame(typename::Symbol; kwargs...) = CompositeDataFrame(adf::AbstractDataFrame) = CompositeDataFrame(DataFrames.columns(adf), names(adf)) - + CompositeDataFrame(adf::AbstractDataFrame, nms::Vector{Symbol}) = CompositeDataFrame(DataFrames.columns(adf), nms) @@ -105,11 +105,11 @@ DataFrames.DataFrame(cdf::AbstractCompositeDataFrame) = DataFrame(DataFrames.col Base.names{T <: AbstractCompositeDataFrame}(cdf::T) = @compat fieldnames(T) DataFrames.ncol(cdf::AbstractCompositeDataFrame) = length(names(cdf)) -DataFrames.nrow(cdf::AbstractCompositeDataFrame) = ncol(cdf) > 0 ? length(cdf.(1))::Int : 0 -DataFrames.nrow(cdf::AbstractCompositeDataFrame) = length(cdf.(1)) +DataFrames.nrow(cdf::AbstractCompositeDataFrame) = ncol(cdf) > 0 ? length(getfield(cdf, 1))::Int : 0 +DataFrames.nrow(cdf::AbstractCompositeDataFrame) = length(getfield(cdf, 1)) + +DataFrames.columns(cdf::AbstractCompositeDataFrame) = Any[ getfield(cdf, i) for i in 1:length(cdf) ] -DataFrames.columns(cdf::AbstractCompositeDataFrame) = Any[ cdf.(i) for i in 1:length(cdf) ] - function Base.hcat(df1::AbstractCompositeDataFrame, df2::AbstractCompositeDataFrame) nms = DataFrames.make_unique([names(df1); names(df2)]) columns = Any[DataFrames.columns(df1)..., DataFrames.columns(df2)...] @@ -125,19 +125,19 @@ DataFrames.index(cdf::AbstractCompositeDataFrame) = DataFrames.Index(names(cdf)) ## getindex ######################################### -Base.getindex(cdf::AbstractCompositeDataFrame, col_inds::DataFrames.ColumnIndex) = cdf.(col_inds) -Base.getindex{T <: DataFrames.ColumnIndex}(cdf::AbstractCompositeDataFrame, col_inds::AbstractVector{T}) = CompositeDataFrame(Any[ cdf.(col_inds[i]) for i = 1:length(col_inds) ], names(cdf)[col_inds]) -Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, col_inds::DataFrames.ColumnIndex) = cdf.(col_inds)[row_inds] -Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, col_inds) = - CompositeDataFrame(Any[ cdf.(col_inds[i])[row_inds] for i = 1:length(col_inds) ], +Base.getindex(cdf::AbstractCompositeDataFrame, col_inds::DataFrames.ColumnIndex) = getfield(cdf, col_inds) +Base.getindex{T <: DataFrames.ColumnIndex}(cdf::AbstractCompositeDataFrame, col_inds::AbstractVector{T}) = CompositeDataFrame(Any[ getfield(cdf, col_inds[i]) for i = 1:length(col_inds) ], names(cdf)[col_inds]) +Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, col_inds::DataFrames.ColumnIndex) = getfield(cdf, col_inds)[row_inds] +Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, col_inds) = + CompositeDataFrame(Any[ getfield(cdf, col_inds[i])[row_inds] for i = 1:length(col_inds) ], Symbol[ names(cdf)[i] for i = 1:length(col_inds) ]) -Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, ::Colon) = typeof(cdf)([cdf.(i)[row_inds] for i in 1:length(cdf)]...) +Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, ::Colon) = typeof(cdf)([getfield(cdf, i)[row_inds] for i in 1:length(cdf)]...) function Base.getindex(cdf::AbstractCompositeDataFrame, row_inds, col_inds::UnitRange) if col_inds.start == 1 && col_inds.stop == length(cdf) - return typeof(cdf)([ cdf.(i)[row_inds] for i in 1:length(cdf) ]...) + return typeof(cdf)([ getfield(cdf, i)[row_inds] for i in 1:length(cdf) ]...) else - return CompositeDataFrame(Any[ cdf.(col_inds[i])[row_inds] for i = 1:length(col_inds) ], names(cdf)[col_inds]) + return CompositeDataFrame(Any[ getfield(cdf, col_inds[i])[row_inds] for i = 1:length(col_inds) ], names(cdf)[col_inds]) end end @@ -147,7 +147,7 @@ end """ CDFRowIterator - + An iterator over the rows of an `AbstractCompositeDataFrame`. Each row is an immutable type with the same names as the parent composite data frame. This iterator is created by calling `eachrow(df)` where `df` is an @@ -176,7 +176,7 @@ Base.map(f::Function, dfri::CDFRowIterator) = [f(row) for row in dfri] order(d::AbstractCompositeDataFrame; args...) = d[sortperm(DataFrame(args...)), :] - + transform(d::AbstractCompositeDataFrame; kwargs...) = CompositeDataFrame(Any[DataFrames.columns(d)..., [ isa(v, Function) ? v(d) : v for (k,v) in kwargs ]...], Symbol[names(d)..., [ k for (k,v) in kwargs ]...]) From 7669ab44aee9a0ac303986d410abfd035a6641f8 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Mon, 25 Jul 2016 23:07:37 -0700 Subject: [PATCH 2/4] Fix symbol deprecations --- src/byrow.jl | 2 +- src/compositedataframe.jl | 4 ++-- test/data.table.timings.jl | 32 ++++++++++++++++---------------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/byrow.jl b/src/byrow.jl index ef3f0d0e..c2932436 100644 --- a/src/byrow.jl +++ b/src/byrow.jl @@ -27,7 +27,7 @@ end byrow_replace(x) = x function byrow_find_newcols(e::Expr, newcol_decl) - if e.head == :macrocall && e.args[1] == symbol("@newcol") + if e.head == :macrocall && e.args[1] == Symbol("@newcol") ea = e.args[2] # expression to assign a new column to df return (nothing, Any[Expr(:kw, ea.args[1], Expr(:call, ea.args[2].args[1], ea.args[2].args[2], :_N))]) diff --git a/src/compositedataframe.jl b/src/compositedataframe.jl index 0eba6747..43265740 100644 --- a/src/compositedataframe.jl +++ b/src/compositedataframe.jl @@ -62,8 +62,8 @@ df = CompositeDataFrame(:MyDF, x = 1:3, y = [2, 1, 2]) """ function CompositeDataFrame(columns::Vector{Any}, cnames::Vector{Symbol} = gennames(length(columns)), - typename::Symbol = symbol("CompositeDF" * string(gensym()))) - rowtypename = symbol(string(typename, "Row")) + typename::Symbol = @compat(Symbol("CompositeDF", gensym()))) + rowtypename = @compat Symbol(typename, "Row") # TODO: length checks e = :(type $(typename) <: AbstractCompositeDataFrame end) e.args[3].args = Any[:($(cnames[i]) :: $(typeof(columns[i]))) for i in 1:length(columns)] diff --git a/test/data.table.timings.jl b/test/data.table.timings.jl index 7bbf872d..3d139068 100644 --- a/test/data.table.timings.jl +++ b/test/data.table.timings.jl @@ -10,12 +10,12 @@ srand(1) # Array version DA = DataFrame( - id1 = P(rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id2 = P(rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id3 = P(rand([symbol(string("id", i)) for i=1:Int(N/K)], N)), # small groups (char) + id1 = P(rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id2 = P(rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id3 = P(rand([@compat(Symbol("id", i)) for i=1:N÷K], N)), # small groups (char) id4 = P(rand(1:K, N)), # large groups (int) id5 = P(rand(1:K, N)), # large groups (int) - id6 = P(rand(1:Int(N/K), N)), # small groups (int) + id6 = P(rand(1:N÷K, N)), # small groups (int) v1 = P(rand(1:5, N)), # int in range [1,5] v2 = P(rand(1:5, N)), # int in range [1,5] v3 = P(rand(N)) # numeric e.g. 23.5749 @@ -24,12 +24,12 @@ DA = DataFrame( # PooledDataArray version DPDA = DataFrame( - id1 = PooledDataArray(rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id2 = PooledDataArray(rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id3 = PooledDataArray(rand([symbol(string("id", i)) for i=1:Int(N/K)], N)), # small groups (char) + id1 = PooledDataArray(rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id2 = PooledDataArray(rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id3 = PooledDataArray(rand([@compat(Symbol("id", i)) for i=1:N÷K], N)), # small groups (char) id4 = PooledDataArray(rand(1:K, N)), # large groups (int) id5 = PooledDataArray(rand(1:K, N)), # large groups (int) - id6 = PooledDataArray(rand(1:Int(N/K), N)), # small groups (int) + id6 = PooledDataArray(rand(1:N÷K, N)), # small groups (int) v1 = P(rand(1:5, N)), # int in range [1,5] v2 = P(rand(1:5, N)), # int in range [1,5] v3 = P(rand(N)) # numeric e.g. 23.5749 @@ -38,12 +38,12 @@ DPDA = DataFrame( # DataArray version DDA = DataFrame( - id1 = (rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id2 = (rand([symbol(string("id", i)) for i=1:K], N)), # large groups (char) - id3 = (rand([symbol(string("id", i)) for i=1:Int(N/K)], N)), # small groups (char) + id1 = (rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id2 = (rand([@compat(Symbol("id", i)) for i=1:K], N)), # large groups (char) + id3 = (rand([@compat(Symbol("id", i)) for i=1:N÷K], N)), # small groups (char) id4 = (rand(1:K, N)), # large groups (int) id5 = (rand(1:K, N)), # large groups (int) - id6 = (rand(1:Int(N/K), N)), # small groups (int) + id6 = (rand(1:N÷K, N)), # small groups (int) v1 = (rand(1:5, N)), # int in range [1,5] v2 = (rand(1:5, N)), # int in range [1,5] v3 = (rand(N)) # numeric e.g. 23.5749 @@ -52,12 +52,12 @@ DDA = DataFrame( # NullableArray version DNA = DataFrame( - id1 = P(NullableArray(rand([symbol(string("id", i)) for i=1:K], N))), # large groups (char) - id2 = P(NullableArray(rand([symbol(string("id", i)) for i=1:K], N))), # large groups (char) - id3 = P(NullableArray(rand([symbol(string("id", i)) for i=1:Int(N/K)], N))), # small groups (char) + id1 = P(NullableArray(rand([@compat(Symbol("id", i)) for i=1:K], N))), # large groups (char) + id2 = P(NullableArray(rand([@compat(Symbol("id", i)) for i=1:K], N))), # large groups (char) + id3 = P(NullableArray(rand([@compat(Symbol("id", i)) for i=1:N÷K], N))), # small groups (char) id4 = P(NullableArray(rand(1:K, N))), # large groups (int) id5 = P(NullableArray(rand(1:K, N))), # large groups (int) - id6 = P(NullableArray(rand(1:Int(N/K), N))), # small groups (int) + id6 = P(NullableArray(rand(1:N÷K, N))), # small groups (int) v1 = P(NullableArray(rand(1:5, N))), # int in range [1,5] v2 = P(NullableArray(rand(1:5, N))), # int in range [1,5] v3 = P(NullableArray(rand(N))) # numeric e.g. 23.5749 From 1a0d7ed83da3adaf19f1e5bbf56e19ee84164e47 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Tue, 26 Jul 2016 18:33:56 -0700 Subject: [PATCH 3/4] Correct Coveralls badge after enabling coverage --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07efcd04..f6af325b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![DataFramesMeta](http://pkg.julialang.org/badges/DataFramesMeta_0.4.svg)](http://pkg.julialang.org/?pkg=DataFramesMeta&ver=0.4) [![DataFramesMeta](http://pkg.julialang.org/badges/DataFramesMeta_0.5.svg)](http://pkg.julialang.org/?pkg=DataFramesMeta) -[![Coverage Status](http://img.shields.io/coveralls/JuliaStats/DataFramesMeta.jl.svg)](https://coveralls.io/r/JuliaStats/DataFramesMeta.jl) +[![Coverage Status](https://coveralls.io/repos/github/JuliaStats/DataFramesMeta.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaStats/DataFramesMeta.jl?branch=master) [![Build Status](https://travis-ci.org/JuliaStats/DataFramesMeta.jl.svg?branch=master)](https://travis-ci.org/JuliaStats/DataFramesMeta.jl) Metaprogramming tools for DataFrames and Associative objects. From dd767d39f93df24123601ce6805102da232f8bf9 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Thu, 28 Jul 2016 12:33:00 -0700 Subject: [PATCH 4/4] Added AppVeyor support --- appveyor.yml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..70c0cddd --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,42 @@ +environment: + matrix: + - JULIAVERSION: "julialang/bin/winnt/x86/0.4/julia-0.4-latest-win32.exe" + - JULIAVERSION: "julialang/bin/winnt/x64/0.4/julia-0.4-latest-win64.exe" + - JULIAVERSION: "julianightlies/bin/winnt/x86/julia-latest-win32.exe" + - JULIAVERSION: "julianightlies/bin/winnt/x64/julia-latest-win64.exe" + +branches: + only: + - master + - /release-.*/ + +skip_commits: + message: /\[av skip\]/ + +notifications: + - provider: Email + on_build_success: false + on_build_failure: false + on_build_status_changed: false + +install: +# If there's a newer build queued for the same PR, cancel this one + - ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod ` + https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | ` + Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { ` + throw "There are newer queued builds for this pull request, failing early." } +# Download most recent Julia Windows binary + - ps: (new-object net.webclient).DownloadFile( + $("http://s3.amazonaws.com/"+$env:JULIAVERSION), + "C:\projects\julia-binary.exe") +# Run installer silently, output to C:\projects\julia + - C:\projects\julia-binary.exe /S /D=C:\projects\julia + +build_script: +# Need to convert from shallow to complete for Pkg.clone to work + - IF EXIST .git\shallow (git fetch --unshallow) + - C:\projects\julia\bin\julia -e "versioninfo(); + Pkg.clone(pwd(), \"DataFramesMeta\"); Pkg.build(\"DataFramesMeta\")" + +test_script: + - C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"DataFramesMeta\")"