forked from JuliaLang/Compat.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
275 additions
and
275 deletions.
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
module TestAbstractArray | ||
using Base.Test | ||
using DataArrays | ||
using Base.Test | ||
using DataArrays | ||
|
||
unsorted_dv = @data [2, 1, NA] | ||
unsorted_dv = @data [2, 1, NA] | ||
|
||
# TODO: Make this work | ||
# tiedrank(dv) | ||
# TODO: Make this work | ||
# tiedrank(dv) | ||
|
||
@assert first(unsorted_dv) == 2 | ||
@assert isna(last(unsorted_dv)) | ||
@assert first(unsorted_dv) == 2 | ||
@assert isna(last(unsorted_dv)) | ||
end |
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,26 +1,26 @@ | ||
module TestBooleans | ||
using Base.Test | ||
using DataArrays | ||
using Base.Test | ||
using DataArrays | ||
|
||
@assert NA | true == true | ||
@assert isna(NA | false) | ||
@assert isna(NA | NA) | ||
@assert true | NA == true | ||
@assert isna(false | NA) | ||
@assert NA | true == true | ||
@assert isna(NA | false) | ||
@assert isna(NA | NA) | ||
@assert true | NA == true | ||
@assert isna(false | NA) | ||
|
||
@assert isna(NA & true) | ||
@assert NA & false == false | ||
@assert isna(NA & NA) | ||
@assert isna(true & NA) | ||
@assert false & NA == false | ||
@assert isna(NA & true) | ||
@assert NA & false == false | ||
@assert isna(NA & NA) | ||
@assert isna(true & NA) | ||
@assert false & NA == false | ||
|
||
@assert any((@data [1, 2, NA]) .== 1) == true | ||
@assert any((@data [NA, 1, 2]) .== 1) == true | ||
@assert isna(any((@data [1, 2, NA]) .== 3)) | ||
@assert any((@data [1, 2, 3] ).== 4) == false | ||
@assert any((@data [1, 2, NA]) .== 1) == true | ||
@assert any((@data [NA, 1, 2]) .== 1) == true | ||
@assert isna(any((@data [1, 2, NA]) .== 3)) | ||
@assert any((@data [1, 2, 3] ).== 4) == false | ||
|
||
@assert isna(all((@data [1, 1, NA]) .== 1)) | ||
@assert isna(all((@data [NA, 1, 1]) .== 1)) | ||
@assert all((@data [1, 1, 1]) .== 1) == true | ||
@assert all((@data [1, 2, 1]) .== 1) == false | ||
@assert isna(all((@data [1, 1, NA]) .== 1)) | ||
@assert isna(all((@data [NA, 1, 1]) .== 1)) | ||
@assert all((@data [1, 1, 1]) .== 1) == true | ||
@assert all((@data [1, 2, 1]) .== 1) == false | ||
end |
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,128 +1,128 @@ | ||
module TestConstructors | ||
using Base.Test | ||
using DataArrays | ||
using Base.Test | ||
using DataArrays | ||
|
||
# | ||
# NA's | ||
# | ||
# | ||
# NA's | ||
# | ||
|
||
@assert isna(NAtype()) | ||
@assert isna(NA) | ||
@assert isna(NAtype()) | ||
@assert isna(NA) | ||
|
||
# | ||
# DataVector's | ||
# | ||
# | ||
# DataVector's | ||
# | ||
|
||
dv = DataArray([1, 2, 3], falses(3)) | ||
@assert isequal(dv.data, [1, 2, 3]) | ||
@assert isequal(dv.na, falses(3)) | ||
@assert isequal(dv, DataArray([1, 2, 3], [false, false, false])) | ||
@assert isequal(dv, DataArray([1, 2, 3])) | ||
dv = DataArray([1, 2, 3], falses(3)) | ||
@assert isequal(dv.data, [1, 2, 3]) | ||
@assert isequal(dv.na, falses(3)) | ||
@assert isequal(dv, DataArray([1, 2, 3], [false, false, false])) | ||
@assert isequal(dv, DataArray([1, 2, 3])) | ||
|
||
dv = convert(DataArray, trues(3)) | ||
@assert isequal(dv.data, [true, true, true]) | ||
@assert isequal(dv.na, falses(3)) | ||
@assert isequal(dv, convert(DataArray, trues(3))) | ||
dv = convert(DataArray, trues(3)) | ||
@assert isequal(dv.data, [true, true, true]) | ||
@assert isequal(dv.na, falses(3)) | ||
@assert isequal(dv, convert(DataArray, trues(3))) | ||
|
||
dv = DataArray([1, 2, 3], falses(3)) | ||
@assert isequal(dv, convert(DataArray, 1:3)) | ||
dv = DataArray([1, 2, 3], falses(3)) | ||
@assert isequal(dv, convert(DataArray, 1:3)) | ||
|
||
dv = DataArray(Int, 3) | ||
@assert isequal(eltype(dv), Int) | ||
@assert isequal(dv.na, trues(3)) | ||
dv = DataArray(Int, 3) | ||
@assert isequal(eltype(dv), Int) | ||
@assert isequal(dv.na, trues(3)) | ||
|
||
dv = convert(DataArray, zeros(3)) | ||
@assert isequal(dv, convert(DataArray, zeros(3))) | ||
dv = convert(DataArray, zeros(3)) | ||
@assert isequal(dv, convert(DataArray, zeros(3))) | ||
|
||
dv = convert(DataArray, zeros(Int, 3)) | ||
@assert isequal(dv, convert(DataArray, zeros(Int, 3))) | ||
dv = convert(DataArray, zeros(Int, 3)) | ||
@assert isequal(dv, convert(DataArray, zeros(Int, 3))) | ||
|
||
dv = convert(DataArray, ones(3)) | ||
@assert isequal(dv, convert(DataArray, ones(3))) | ||
dv = convert(DataArray, ones(3)) | ||
@assert isequal(dv, convert(DataArray, ones(3))) | ||
|
||
dv = convert(DataArray, ones(Int, 3)) | ||
@assert isequal(dv, convert(DataArray, ones(Int, 3))) | ||
dv = convert(DataArray, ones(Int, 3)) | ||
@assert isequal(dv, convert(DataArray, ones(Int, 3))) | ||
|
||
dv = convert(DataArray, falses(3)) | ||
@assert isequal(dv, convert(DataArray, falses(3))) | ||
dv = convert(DataArray, falses(3)) | ||
@assert isequal(dv, convert(DataArray, falses(3))) | ||
|
||
dv = convert(DataArray, trues(3)) | ||
@assert isequal(dv, convert(DataArray, trues(3))) | ||
dv = convert(DataArray, trues(3)) | ||
@assert isequal(dv, convert(DataArray, trues(3))) | ||
|
||
# | ||
# PooledDataArray's | ||
# | ||
# | ||
# PooledDataArray's | ||
# | ||
|
||
pdv = PooledDataArray([1, 2, 3], falses(3)) | ||
@assert all(pdv .== [1, 2, 3]) | ||
@assert all(isna(pdv) .== falses(3)) | ||
pdv = PooledDataArray([1, 2, 3], falses(3)) | ||
@assert all(pdv .== [1, 2, 3]) | ||
@assert all(isna(pdv) .== falses(3)) | ||
|
||
@assert isequal(pdv, PooledDataArray([1, 2, 3], [false, false, false])) | ||
@assert isequal(pdv, PooledDataArray([1, 2, 3])) | ||
@assert isequal(pdv, PooledDataArray([1, 2, 3], [false, false, false])) | ||
@assert isequal(pdv, PooledDataArray([1, 2, 3])) | ||
|
||
pdv = convert(PooledDataArray, trues(3)) | ||
@assert all(pdv .== [true, true, true]) | ||
@assert all(isna(pdv) .== falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, trues(3))) | ||
pdv = convert(PooledDataArray, trues(3)) | ||
@assert all(pdv .== [true, true, true]) | ||
@assert all(isna(pdv) .== falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, trues(3))) | ||
|
||
pdv = PooledDataArray([1, 2, 3], falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, 1:3)) | ||
@assert isequal(pdv, convert(PooledDataArray, PooledDataArray([1, 2, 3]))) | ||
pdv = PooledDataArray([1, 2, 3], falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, 1:3)) | ||
@assert isequal(pdv, convert(PooledDataArray, PooledDataArray([1, 2, 3]))) | ||
|
||
pdv = PooledDataArray(Int, 3) | ||
@assert isequal(eltype(pdv), Int) | ||
@assert all(isna(pdv) .== trues(3)) | ||
pdv = PooledDataArray(Int, 3) | ||
@assert isequal(eltype(pdv), Int) | ||
@assert all(isna(pdv) .== trues(3)) | ||
|
||
pdv = convert(PooledDataArray, zeros(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, zeros(3))) | ||
pdv = convert(PooledDataArray, zeros(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, zeros(3))) | ||
|
||
pdv = convert(PooledDataArray, zeros(Int, 3)) | ||
@assert isequal(pdv, convert(PooledDataArray, zeros(Int, 3))) | ||
pdv = convert(PooledDataArray, zeros(Int, 3)) | ||
@assert isequal(pdv, convert(PooledDataArray, zeros(Int, 3))) | ||
|
||
pdv = convert(PooledDataArray, ones(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, ones(3))) | ||
pdv = convert(PooledDataArray, ones(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, ones(3))) | ||
|
||
pdv = convert(PooledDataArray, ones(Int, 3)) | ||
@assert isequal(pdv, convert(PooledDataArray, ones(Int, 3))) | ||
pdv = convert(PooledDataArray, ones(Int, 3)) | ||
@assert isequal(pdv, convert(PooledDataArray, ones(Int, 3))) | ||
|
||
pdv = convert(PooledDataArray, falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, falses(3))) | ||
pdv = convert(PooledDataArray, falses(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, falses(3))) | ||
|
||
pdv = convert(PooledDataArray, trues(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, trues(3))) | ||
pdv = convert(PooledDataArray, trues(3)) | ||
@assert isequal(pdv, convert(PooledDataArray, trues(3))) | ||
|
||
# | ||
# DataMatrix | ||
# | ||
# | ||
# DataMatrix | ||
# | ||
|
||
dm = DataArray([1 2; 3 4], falses(2, 2)) | ||
@assert isequal(dm.data, [1 2; 3 4]) | ||
@assert isequal(dm.na, falses(2, 2)) | ||
dm = DataArray([1 2; 3 4], falses(2, 2)) | ||
@assert isequal(dm.data, [1 2; 3 4]) | ||
@assert isequal(dm.na, falses(2, 2)) | ||
|
||
@assert isequal(dm, DataArray([1 2; 3 4], [false false; false false])) | ||
@assert isequal(dm, DataArray([1 2; 3 4])) | ||
@assert isequal(dm, DataArray([1 2; 3 4], [false false; false false])) | ||
@assert isequal(dm, DataArray([1 2; 3 4])) | ||
|
||
dm = convert(DataArray, trues(2, 2)) | ||
@assert isequal(dm.data, trues(2, 2)) | ||
@assert isequal(dm.na, falses(2, 2)) | ||
dm = convert(DataArray, trues(2, 2)) | ||
@assert isequal(dm.data, trues(2, 2)) | ||
@assert isequal(dm.na, falses(2, 2)) | ||
|
||
@assert isequal(dm, convert(DataArray, trues(2, 2))) | ||
@assert isequal(dm, convert(DataArray, trues(2, 2))) | ||
|
||
dm = DataArray(Int, 2, 2) | ||
@assert isequal(eltype(dm), Int) | ||
@assert isequal(dm.na, trues(2, 2)) | ||
dm = DataArray(Int, 2, 2) | ||
@assert isequal(eltype(dm), Int) | ||
@assert isequal(dm.na, trues(2, 2)) | ||
|
||
convert(DataArray, zeros(2, 2)) | ||
convert(DataArray, zeros(2, 2)) | ||
|
||
convert(DataArray, zeros(Int, 2, 2)) | ||
convert(DataArray, zeros(Int, 2, 2)) | ||
|
||
convert(DataArray, ones(2, 2)) | ||
convert(DataArray, ones(Int, 2, 2)) | ||
convert(DataArray, ones(2, 2)) | ||
convert(DataArray, ones(Int, 2, 2)) | ||
|
||
convert(DataArray, falses(2, 2)) | ||
convert(DataArray, trues(2, 2)) | ||
convert(DataArray, falses(2, 2)) | ||
convert(DataArray, trues(2, 2)) | ||
|
||
convert(DataArray, eye(3, 2)) | ||
convert(DataArray, eye(2)) | ||
convert(DataArray, diagm(Float64[pi, pi])) | ||
convert(DataArray, eye(3, 2)) | ||
convert(DataArray, eye(2)) | ||
convert(DataArray, diagm(Float64[pi, pi])) | ||
end |
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
Oops, something went wrong.