-
Notifications
You must be signed in to change notification settings - Fork 17
Switch to DataTables #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b0048e1
remove ctor @compat for v0.4
alyst be72ad0
switch to DataTables
alyst fae1a59
temporarily require DataTables master for CI
alyst 01ad191
convert logical vector to Vector{Bool} + tests
alyst 10d9294
update tests
alyst f53af10
group tests into testsets
alyst 57aef24
implement reviewer suggestions
alyst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
julia 0.5 | ||
DataFrames 0.7 | ||
DataArrays 0.3 | ||
DataTables | ||
FileIO 0.1.2 | ||
GZip 0.2 | ||
Compat 0.17 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,76 @@ | ||
module TestRDA | ||
using Base.Test | ||
using DataFrames | ||
using DataTables | ||
using RData | ||
using Compat | ||
|
||
# check for Float64 NA | ||
@test !RData.isna_float64(reinterpret(UInt64, 1.0)) | ||
@test !RData.isna_float64(reinterpret(UInt64, NaN)) | ||
@test !RData.isna_float64(reinterpret(UInt64, Inf)) | ||
@test !RData.isna_float64(reinterpret(UInt64, -Inf)) | ||
@test RData.isna_float64(reinterpret(UInt64, RData.R_NA_FLOAT64)) | ||
# check that alternative NA is also recognized (#10) | ||
@test RData.isna_float64(reinterpret(UInt64, RData.R_NA_FLOAT64 | ((Base.significand_mask(Float64) + 1) >> 1))) | ||
@testset "Detect R floating-point NAs" begin | ||
@test !RData.isna_float64(reinterpret(UInt64, 1.0)) | ||
@test !RData.isna_float64(reinterpret(UInt64, NaN)) | ||
@test !RData.isna_float64(reinterpret(UInt64, Inf)) | ||
@test !RData.isna_float64(reinterpret(UInt64, -Inf)) | ||
@test RData.isna_float64(reinterpret(UInt64, RData.R_NA_FLOAT64)) | ||
# check that alternative NA is also recognized (#10) | ||
@test RData.isna_float64(reinterpret(UInt64, RData.R_NA_FLOAT64 | ((Base.significand_mask(Float64) + 1) >> 1))) | ||
end | ||
|
||
testdir = dirname(@__FILE__) | ||
@testset "Reading minimal RData" begin | ||
df = DataTable(num = NullableArray([1.1, 2.2])) | ||
@test sexp2julia(load("$testdir/data/minimal.rda",convert=false)["df"]) == df | ||
@test load("$testdir/data/minimal.rda",convert=true)["df"] == df | ||
@test load("$testdir/data/minimal_ascii.rda")["df"] == df | ||
end | ||
|
||
df = DataFrame(num = [1.1, 2.2]) | ||
@test isequal(sexp2julia(load("$testdir/data/minimal.rda",convert=false)["df"]), df) | ||
@test isequal(load("$testdir/data/minimal.rda",convert=true)["df"], df) | ||
@test isequal(load("$testdir/data/minimal_ascii.rda")["df"], df) | ||
|
||
df[:int] = Int32[1, 2] | ||
df[:logi] = [true, false] | ||
df[:chr] = ["ab", "c"] | ||
df[:factor] = pool(df[:chr]) | ||
df[:cplx] = Complex128[1.1+0.5im, 1.0im] | ||
@test isequal(sexp2julia(load("$testdir/data/types.rda",convert=false)["df"]), df) | ||
@test isequal(sexp2julia(load("$testdir/data/types_ascii.rda",convert=false)["df"]), df) | ||
|
||
df[2, :] = NA | ||
append!(df, df[2, :]) | ||
df[3, :num] = NaN | ||
df[:, :cplx] = @data [NA, @compat(Complex128(1,NaN)), NaN] | ||
@test isequal(sexp2julia(load("$testdir/data/NAs.rda",convert=false)["df"]), df) | ||
# ASCII format saves NaN as NA | ||
df[3, :num] = NA | ||
df[:, :cplx] = @data [NA, NA, NA] | ||
@test isequal(sexp2julia(load("$testdir/data/NAs_ascii.rda",convert=false)["df"]), df) | ||
|
||
rda_names = names(sexp2julia(load("$testdir/data/names.rda",convert=false)["df"])) | ||
expected_names = [:_end, :x!, :x1, :_B_C_, :x, :x_1] | ||
@test rda_names == expected_names | ||
rda_names = names(sexp2julia(load("$testdir/data/names_ascii.rda",convert=false)["df"])) | ||
@test rda_names == [:_end, :x!, :x1, :_B_C_, :x, :x_1] | ||
|
||
rda_envs = load("$testdir/data/envs.rda",convert=false) | ||
|
||
rda_pairlists = load("$testdir/data/pairlists.rda",convert=false) | ||
|
||
rda_closures = load("$testdir/data/closures.rda",convert=false) | ||
|
||
rda_cmpfuns = load("$testdir/data/cmpfun.rda",convert=false) | ||
@testset "Conversion to Julia types" begin | ||
df = DataTable(num = NullableArray([1.1, 2.2]), | ||
int = NullableArray(Int32[1, 2]), | ||
logi = NullableArray([true, false]), | ||
chr = NullableArray(["ab", "c"]), | ||
factor = categorical(NullableArray(["ab", "c"]), true), | ||
cplx = NullableArray(Complex128[1.1+0.5im, 1.0im])) | ||
rdf = sexp2julia(load("$testdir/data/types.rda",convert=false)["df"]) | ||
@test eltypes(rdf) == eltypes(df) | ||
@test rdf == df | ||
rdf_ascii = sexp2julia(load("$testdir/data/types_ascii.rda",convert=false)["df"]) | ||
@test eltypes(rdf_ascii) == eltypes(df) | ||
@test rdf_ascii == df | ||
end | ||
|
||
@testset "NAs conversion" begin | ||
df = DataTable(num = NullableArray([1.1, 2.2]), | ||
int = NullableArray(Int32[1, 2]), | ||
logi = NullableArray([true, false]), | ||
chr = NullableArray(["ab", "c"]), | ||
factor = categorical(NullableArray(["ab", "c"]), true), | ||
cplx = NullableArray(Complex128[1.1+0.5im, 1.0im])) | ||
df[2, :] = Nullable() | ||
append!(df, df[2, :]) | ||
df[3, :num] = NaN | ||
df[:, :cplx] = NullableArray([Nullable(), Complex128(1,NaN), NaN]) | ||
@test isequal(sexp2julia(load("$testdir/data/NAs.rda",convert=false)["df"]), df) | ||
# ASCII format saves NaN as NA | ||
df[3, :num] = Nullable() | ||
df[:, :cplx] = NullableArray{Complex128}(3) | ||
@test sexp2julia(load("$testdir/data/NAs_ascii.rda",convert=false)["df"]) == df | ||
end | ||
|
||
@testset "Column names conversion" begin | ||
rda_names = names(sexp2julia(load("$testdir/data/names.rda",convert=false)["df"])) | ||
expected_names = [:_end, :x!, :x1, :_B_C_, :x, :x_1] | ||
@test rda_names == expected_names | ||
rda_names = names(sexp2julia(load("$testdir/data/names_ascii.rda",convert=false)["df"])) | ||
@test rda_names == [:_end, :x!, :x1, :_B_C_, :x, :x_1] | ||
end | ||
|
||
@testset "Reading RDA with complex types (environments, closures etc)" begin | ||
rda_envs = load("$testdir/data/envs.rda",convert=false) | ||
|
||
rda_pairlists = load("$testdir/data/pairlists.rda",convert=false) | ||
|
||
rda_closures = load("$testdir/data/closures.rda",convert=false) | ||
|
||
rda_cmpfuns = load("$testdir/data/cmpfun.rda",convert=false) | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you still need the checkout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be necessary since there's a tag for DataTables.