-
Notifications
You must be signed in to change notification settings - Fork 60
Update to use NullableArrays and CategoricalArrays #145
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
Merged
+137
−63
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
faddb45
Update to use NullableArrays and CategoricalArrays
randy3k 6f5937d
julia 0.5 above only
randy3k 7293165
DataFrames 0.8.3 is okay
randy3k 51cd71c
improve CategoricalArray and NullableCategoricalArray
randy3k 7cfcb07
handle Nullable objects
randy3k c98e28d
improve field access and tests
randy3k c5eec81
more test improvement
randy3k 2f762d7
scalar is okay
randy3k 371f8cf
improve tests for Nullable
randy3k 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 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 |
---|---|---|
|
@@ -3,7 +3,6 @@ os: | |
- linux | ||
- osx | ||
julia: | ||
- 0.4 | ||
- 0.5 | ||
- nightly | ||
notifications: | ||
|
This file contains 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,7 @@ | ||
julia 0.4 | ||
DataStructures | ||
DataArrays 0.3.8 | ||
DataFrames 0.7.6 | ||
julia 0.5 | ||
DataStructures 0.4.3 | ||
DataFrames 0.8.3 | ||
NullableArrays 0.0.9 | ||
CategoricalArrays 0.0.6 | ||
Compat 0.8 | ||
@windows WinReg | ||
@windows WinReg 0.2.0 |
This file contains 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 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 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 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 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 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 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,31 +1,52 @@ | ||
using DataArrays,DataFrames | ||
using NullableArrays,CategoricalArrays,DataFrames | ||
|
||
v110 = rcopy(DataArray,reval("x <- 1:10")) | ||
@test isa(v110,DataVector) | ||
@test eltype(v110) == Cint | ||
@test isequal(rcopy(Nullable, RObject(1)), Nullable(1)) | ||
@test isequal(rcopy(Nullable, RObject("abc")), Nullable("abc")) | ||
@test rcopy(RObject(Nullable(1))) == 1 | ||
@test isnull(rcopy(Nullable, RObject(Nullable(1, true)))) | ||
|
||
v110 = rcopy(NullableArray,reval("c(1L, NA)")) | ||
@test isa(v110,NullableVector) | ||
@test eltype(v110) == Nullable{Int32} | ||
@test isnull(rcopy(NullableArray, RObject(v110[2]))[1]) | ||
|
||
attenu = rcopy(DataFrame,:attenu) | ||
@test isa(attenu,DataFrame) | ||
@test size(attenu) == (182,5) | ||
|
||
dist = attenu[:dist] | ||
@test isa(dist,DataArray{Float64}) | ||
@test isa(dist,Vector{Float64}) | ||
station = attenu[:station] | ||
@test isa(station,NullableCategoricalArray) | ||
|
||
@test rcopy(DataArray,"c(NA,TRUE)").na == @data([NA,true]).na | ||
@test rcopy(DataArray,"c(NA,1)").na == @data([NA,1.0]).na | ||
@test rcopy(DataArray,"c(NA,1+0i)").na == @data([NA,1.0+0.0*im]).na | ||
@test rcopy(DataArray,"c(NA,1L)").na == @data([NA,one(Int32)]).na | ||
@test rcopy(DataArray,"c(NA,'NA')").na == @data([NA,"NA"]).na | ||
@test_throws ErrorException rcopy(DataArray,"as.factor(c('a','a','c'))") | ||
@test rcopy(PooledDataArray,"as.factor(c('a','a','c'))").pool == ["a","c"] | ||
@test isequal(rcopy(NullableArray,"c(NA,TRUE)"), NullableArray([true,true], [true,false])) | ||
@test isequal(rcopy(NullableArray,"c(NA,1)"), NullableArray([true,1.], [true,false])) | ||
@test isequal(rcopy(NullableArray,"c(NA,1+0i)"), NullableArray([true,1.+0*im], [true,false])) | ||
@test isequal(rcopy(NullableArray,"c(NA,1L)"), NullableArray([true,one(Int32)], [true,false])) | ||
@test isequal(rcopy(NullableArray,"c(NA,'NA')"), NullableArray(["", "NA"], [true,false])) | ||
@test_throws ErrorException rcopy(NullableArray,"as.factor(c('a','a','c'))") | ||
@test CategoricalArrays.levels(rcopy(CategoricalArray,"factor(c('a','a','c'))")) == ["a","c"] | ||
@test CategoricalArrays.levels(rcopy(NullableCategoricalArray,"factor(c('a',NA,'c'))")) == ["a","c"] | ||
@test CategoricalArrays.ordered(rcopy(CategoricalArray,"ordered(c('a','a','c'))")) | ||
@test CategoricalArrays.ordered(rcopy(NullableCategoricalArray,"ordered(c('a',NA,'c'))")) | ||
|
||
@test rcopy(DataArray,RObject(@data([NA,true]))).na == @data([NA,true]).na | ||
@test rcopy(DataArray,RObject(@data([NA,1]))).na == @data([NA,1]).na | ||
@test rcopy(DataArray,RObject(@data([NA,1.]))).na == @data([NA,1.]).na | ||
@test rcopy(DataArray,RObject(@data([NA,1.+0*im]))).na == @data([NA,1.+0*im]).na | ||
@test rcopy(DataArray,RObject(@data([NA,NA,"a","b"]))).na == @data([NA,NA,"a","b"]).na | ||
pda = PooledDataArray(repeat(["a", "b"], inner = [5])) | ||
@test rcopy(PooledDataArray,RObject(pda)).refs == repeat([1,2], inner = [5]) | ||
v = NullableArray([true,true], [true,false]) | ||
@test isequal(rcopy(NullableArray,RObject(v)), v) | ||
v = NullableArray([1,2], [true,false]) | ||
@test isequal(rcopy(NullableArray,RObject(v)), v) | ||
v = NullableArray([1.,2.], [true,false]) | ||
@test isequal(rcopy(NullableArray,RObject(v)), v) | ||
v = NullableArray([0,1.+0*im], [true,false]) | ||
@test isequal(rcopy(NullableArray,RObject(v)), v) | ||
v = NullableArray(["","abc"], [true,false]) | ||
@test isequal(rcopy(NullableArray,RObject(v)), v) | ||
v = CategoricalArray(repeat(["a", "b"], inner = 5)) | ||
@test isequal(rcopy(CategoricalArray,RObject(v)), v) | ||
v = NullableCategoricalArray(repeat(["a", "b"], inner = 5), repeat([true, false], outer = 5)) | ||
@test isequal(rcopy(NullableCategoricalArray,RObject(v)), v) | ||
v = CategoricalArray(repeat(["a", "b"], inner = 5), ordered=true) | ||
@test isequal(rcopy(CategoricalArray,RObject(v)), v) | ||
v = NullableCategoricalArray(repeat(["a", "b"], inner = 5), repeat([true, false], outer = 5), ordered=true) | ||
@test isequal(rcopy(NullableCategoricalArray,RObject(v)), v) | ||
|
||
@test rcopy(rcall(:dim,RObject(attenu))) == [182,5] | ||
|
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.
You shouldn't need
import
for this, merelyusing
AFAICT.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.
it is because RCall also has a isnull method.