Skip to content

Commit

Permalink
Replace tabs with spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
garborg committed Jul 29, 2014
1 parent 47433f5 commit d85c06d
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 275 deletions.
14 changes: 7 additions & 7 deletions test/abstractarray.jl
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
40 changes: 20 additions & 20 deletions test/booleans.jl
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
180 changes: 90 additions & 90 deletions test/constructors.jl
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
70 changes: 35 additions & 35 deletions test/dataarray.jl
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
module TestDataArray
using Base.Test
using DataArrays
using Base.Test
using DataArrays

v = [1, 2, 3, 4]
dv = DataArray(v, falses(size(v)))
v = [1, 2, 3, 4]
dv = DataArray(v, falses(size(v)))

m = [1 2; 3 4]
dm = DataArray(m, falses(size(m)))
m = [1 2; 3 4]
dm = DataArray(m, falses(size(m)))

t = Array(Int, 2, 2, 2)
t[1:2, 1:2, 1:2] = 1
dt = DataArray(t, falses(size(t)))
t = Array(Int, 2, 2, 2)
t[1:2, 1:2, 1:2] = 1
dt = DataArray(t, falses(size(t)))

dv = DataArray(v)
dv = DataArray(v, [false, false, false, false])
dv = DataArray(v)
dv = DataArray(v, [false, false, false, false])

dv = DataArray(Int, 2)
dm = DataArray(Int, 2, 2)
dt = DataArray(Int, 2, 2, 2)
dv = DataArray(Int, 2)
dm = DataArray(Int, 2, 2)
dt = DataArray(Int, 2, 2, 2)

similar(dv)
similar(dm)
similar(dt)
similar(dv)
similar(dm)
similar(dt)

similar(dv, 2)
similar(dm, 2, 2)
similar(dt, 2, 2, 2)
similar(dv, 2)
similar(dm, 2, 2)
similar(dt, 2, 2, 2)


x = DataArray([9, 9, 8])
Expand All @@ -49,19 +49,19 @@ module TestDataArray
@assert isequal(levels(x), @data [1, -2, 4])
@assert isequal(levels(reverse(x)), @data [4, 1, -2])

# Test vecbind
# a = [1:4]
# d = DataArray(a)
# @assert isequal(vecbind(a,a), [a,a])
# @assert isequal(vecbind(a,1.0 * a), 1.0 * [a,a])
# @assert isequal(vecbind(d,a), [d,d])
# @assert isequal(vecbind(a,d), [d,d])
# @assert isequal(vecbind(1.0 * a,d), 1.0 * [d,d])
# @assert isequal(vecbind(d,d), [d,d])
# @assert isequal(vecbind(a,IndexedVector(a)), [a,a])
# @assert isequal(vecbind(a,IndexedVector(d)), [d,d])
# @assert isequal(vecbind(PooledDataArray(a),IndexedVector(d)), [d,d])
# @assert isequal(vecbind(PooledDataArray(a),IndexedVector(a)), [a,a])
# @assert isequal(vecbind(a,RepeatedVector(a,2)), [a,a,a])
# @assert (vecbind(a,StackedVector({a,1.0*a})) == [a,a,a])
# Test vecbind
# a = [1:4]
# d = DataArray(a)
# @assert isequal(vecbind(a,a), [a,a])
# @assert isequal(vecbind(a,1.0 * a), 1.0 * [a,a])
# @assert isequal(vecbind(d,a), [d,d])
# @assert isequal(vecbind(a,d), [d,d])
# @assert isequal(vecbind(1.0 * a,d), 1.0 * [d,d])
# @assert isequal(vecbind(d,d), [d,d])
# @assert isequal(vecbind(a,IndexedVector(a)), [a,a])
# @assert isequal(vecbind(a,IndexedVector(d)), [d,d])
# @assert isequal(vecbind(PooledDataArray(a),IndexedVector(d)), [d,d])
# @assert isequal(vecbind(PooledDataArray(a),IndexedVector(a)), [a,a])
# @assert isequal(vecbind(a,RepeatedVector(a,2)), [a,a,a])
# @assert (vecbind(a,StackedVector({a,1.0*a})) == [a,a,a])
end
Loading

0 comments on commit d85c06d

Please sign in to comment.