Skip to content

Commit 2435aef

Browse files
authored
Lighter tests (#142)
1 parent 604ed83 commit 2435aef

11 files changed

+84
-98
lines changed

test/metadata.jl

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
@testset "Metadata" begin
22
@testset "ConstMeta" begin
3-
a = rand(100)
4-
b = rand(100)
5-
c = rand(100)
6-
d = rand(100)
3+
a = rand(10)
4+
b = rand(10)
5+
c = rand(10)
6+
d = rand(10)
77
t = Table(; a, b, c, d)
8-
m = ConstMeta(fill(1, 100))
8+
m = ConstMeta(fill(1, 10))
99
mt = MetaTable(t, m)
1010

1111
T = Select(1, 3)
@@ -35,12 +35,12 @@
3535
end
3636

3737
@testset "VarMeta" begin
38-
a = rand(100)
39-
b = rand(100)
40-
c = rand(100)
41-
d = rand(100)
38+
a = rand(10)
39+
b = rand(10)
40+
c = rand(10)
41+
d = rand(10)
4242
t = Table(; a, b, c, d)
43-
m = VarMeta(fill(1, 100))
43+
m = VarMeta(fill(1, 10))
4444
mt = MetaTable(t, m)
4545

4646
T = Reject(1, 3)

test/tableselection.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@testset "TableSelection" begin
2-
a = rand(4000)
3-
b = rand(4000)
4-
c = rand(4000)
5-
d = rand(4000)
6-
e = rand(4000)
7-
f = rand(4000)
2+
a = rand(10)
3+
b = rand(10)
4+
c = rand(10)
5+
d = rand(10)
6+
e = rand(10)
7+
f = rand(10)
88
t = Table(; a, b, c, d, e, f)
99

1010
# Tables.jl interface

test/transforms/functional.jl

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Functional" begin
2-
x = π*rand(1500)
3-
y = π*rand(1500)
2+
x = π*rand(100)
3+
y = π*rand(100)
44
t = Table(; x, y)
55
T = Functional(cos)
66
n, c = apply(T, t)
@@ -9,8 +9,8 @@
99
tₒ = revert(T, n, c)
1010
@test Tables.matrix(t) Tables.matrix(tₒ)
1111

12-
x = 2*(rand(1500) .- 0.5)
13-
y = 2*(rand(1500) .- 0.5)
12+
x = 2*(rand(100) .- 0.5)
13+
y = 2*(rand(100) .- 0.5)
1414
t = Table(; x, y)
1515
T = Functional(acos)
1616
n, c = apply(T, t)
@@ -19,8 +19,8 @@
1919
tₒ = revert(T, n, c)
2020
@test Tables.matrix(t) Tables.matrix(tₒ)
2121

22-
x = π*(rand(1500) .- 0.5)
23-
y = π*(rand(1500) .- 0.5)
22+
x = π*(rand(100) .- 0.5)
23+
y = π*(rand(100) .- 0.5)
2424
t = Table(; x, y)
2525
T = Functional(sin)
2626
n, c = apply(T, t)
@@ -29,8 +29,8 @@
2929
tₒ = revert(T, n, c)
3030
@test Tables.matrix(t) Tables.matrix(tₒ)
3131

32-
x = 2*(rand(1500) .- 0.5)
33-
y = 2*(rand(1500) .- 0.5)
32+
x = 2*(rand(100) .- 0.5)
33+
y = 2*(rand(100) .- 0.5)
3434
t = Table(; x, y)
3535
T = Functional(asin)
3636
n, c = apply(T, t)
@@ -39,8 +39,8 @@
3939
tₒ = revert(T, n, c)
4040
@test Tables.matrix(t) Tables.matrix(tₒ)
4141

42-
x = rand(Normal(0,25), 1500)
43-
y = x + rand(Normal(10,2), 1500)
42+
x = rand(Normal(0,25), 100)
43+
y = x + rand(Normal(10,2), 100)
4444
t = Table(; x, y)
4545
T = Functional(exp)
4646
n, c = apply(T, t)
@@ -49,17 +49,17 @@
4949
tₒ = revert(T, n, c)
5050
@test Tables.matrix(t) Tables.matrix(tₒ)
5151

52-
x = rand(Normal(0,25), 1500)
53-
y = x + rand(Normal(10,2), 1500)
52+
x = rand(Normal(0,25), 100)
53+
y = x + rand(Normal(10,2), 100)
5454
t = Table(; x, y)
5555
T = Functional(x -> x)
5656
n, c = apply(T, t)
5757
@test t == n
5858
@test !isrevertible(T)
5959

6060
# functor tests
61-
x = rand(1500)
62-
y = rand(1500)
61+
x = rand(100)
62+
y = rand(100)
6363
t = Table(; x, y)
6464
f = Polynomial(1, 2, 3) # f(x) = 1 + 2x + 3x²
6565
T = Functional(f)
@@ -71,8 +71,8 @@
7171
@test !isrevertible(T)
7272

7373
# apply functions to specific columns
74-
x = π*rand(1500)
75-
y = 2*(rand(1500) .- 0.5)
74+
x = π*rand(100)
75+
y = 2*(rand(100) .- 0.5)
7676
z = x + y
7777
t = Table(; x, y, z)
7878
T = Functional(1 => cos, 2 => acos)
@@ -83,8 +83,8 @@
8383
tₒ = revert(T, n, c)
8484
@test Tables.matrix(t) Tables.matrix(tₒ)
8585

86-
x = π*rand(1500)
87-
y = π*(rand(1500) .- 0.5)
86+
x = π*rand(100)
87+
y = π*(rand(100) .- 0.5)
8888
z = x + y
8989
t = Table(; x, y, z)
9090
T = Functional(:x => cos, :y => sin)
@@ -95,8 +95,8 @@
9595
tₒ = revert(T, n, c)
9696
@test Tables.matrix(t) Tables.matrix(tₒ)
9797

98-
x = 2*(rand(1500) .- 0.5)
99-
y = 2*(rand(1500) .- 0.5)
98+
x = 2*(rand(100) .- 0.5)
99+
y = 2*(rand(100) .- 0.5)
100100
z = x + y
101101
t = Table(; x, y, z)
102102
T = Functional("x" => acos, "y" => asin)
@@ -121,8 +121,8 @@
121121
@test !isrevertible(T)
122122

123123
# row table
124-
x = π*rand(1500)
125-
y = π*rand(1500)
124+
x = π*rand(100)
125+
y = π*rand(100)
126126
t = Table(; x, y)
127127
rt = Tables.rowtable(t)
128128
T = Functional(cos)

test/transforms/identity.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@testset "Identity" begin
2-
x = rand(4000)
3-
y = rand(4000)
2+
x = rand(10)
3+
y = rand(10)
44
t = Table(; x, y)
55
T = Identity()
66
n, c = apply(T, t)

test/transforms/parallel.jl

+8-19
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,18 @@
33
y = x + rand(Normal(0, 2), 1500)
44
z = y + rand(Normal(0, 5), 1500)
55
t = Table(; x, y, z)
6+
67
T = Scale(low=0.3, high=0.6) EigenAnalysis(:VDV)
78
n, c = apply(T, t)
89
tₒ = revert(T, n, c)
910
@test Tables.matrix(t) Tables.matrix(tₒ)
1011

1112
# check cardinality of parallel transform
12-
x = rand(Normal(0, 10), 1500)
13-
y = x + rand(Normal(0, 2), 1500)
14-
z = y + rand(Normal(0, 5), 1500)
15-
t = Table(; x, y, z)
1613
T = ZScore() EigenAnalysis(:V)
1714
n = T(t)
1815
@test length(Tables.columnnames(n)) == 6
1916

2017
# distributivity with respect to sequential transform
21-
x = rand(Normal(0, 10), 1500)
22-
y = x + rand(Normal(0, 2), 1500)
23-
z = y + rand(Normal(0, 5), 1500)
24-
t = Table(; x, y, z)
2518
T₁ = Center()
2619
T₂ = Scale(low=0.2, high=0.8)
2720
T₃ = EigenAnalysis(:VD)
@@ -31,25 +24,21 @@
3124
n₂ = P₂(t)
3225
@test Tables.matrix(n₁) Tables.matrix(n₂)
3326

34-
# reapply with parallel transform
35-
t = Table(x=rand(1000))
36-
T = ZScore() Quantile()
37-
n1, c1 = apply(T, t)
38-
n2 = reapply(T, t, c1)
39-
@test n1 == n2
40-
4127
# row table
42-
x = rand(Normal(0, 10), 1500)
43-
y = x + rand(Normal(0, 2), 1500)
44-
z = y + rand(Normal(0, 5), 1500)
45-
t = Table(; x, y, z)
4628
rt = Tables.rowtable(t)
4729
T = Scale(low=0.3, high=0.6) EigenAnalysis(:VDV)
4830
n, c = apply(T, rt)
4931
@test Tables.isrowtable(n)
5032
rtₒ = revert(T, n, c)
5133
@test Tables.matrix(rt) Tables.matrix(rtₒ)
5234

35+
# reapply with parallel transform
36+
t = Table(x=rand(100))
37+
T = ZScore() Quantile()
38+
n1, c1 = apply(T, t)
39+
n2 = reapply(T, t, c1)
40+
@test n1 == n2
41+
5342
# https://github.com/JuliaML/TableTransforms.jl/issues/80
5443
t = (a=rand(3), b=rand(3))
5544
T = Select(:a) Select(:b)

test/transforms/quantile.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@testset "Quantile" begin
2-
t = Table(z=rand(1000))
2+
t = Table(z=rand(100))
33
T = Quantile()
44
n, c = apply(T, t)
55
tₒ = revert(T, n, c)

test/transforms/rename.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@testset "Rename" begin
2-
a = rand(4000)
3-
b = rand(4000)
4-
c = rand(4000)
5-
d = rand(4000)
2+
a = rand(10)
3+
b = rand(10)
4+
c = rand(10)
5+
d = rand(10)
66
t = Table(; a, b, c, d)
77

88
# integer => symbol

test/transforms/select.jl

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@testset "Select" begin
2-
a = rand(4000)
3-
b = rand(4000)
4-
c = rand(4000)
5-
d = rand(4000)
6-
e = rand(4000)
7-
f = rand(4000)
2+
a = rand(10)
3+
b = rand(10)
4+
c = rand(10)
5+
d = rand(10)
6+
e = rand(10)
7+
f = rand(10)
88
t = Table(; a, b, c, d, e, f)
99

1010
T = Select(:f, :d)
@@ -94,10 +94,10 @@
9494
@test n1 == n2
9595

9696
# selection with renaming
97-
a = rand(4000)
98-
b = rand(4000)
99-
c = rand(4000)
100-
d = rand(4000)
97+
a = rand(10)
98+
b = rand(10)
99+
c = rand(10)
100+
d = rand(10)
101101
t = Table(; a, b, c, d)
102102

103103
# integer => symbol
@@ -194,10 +194,10 @@
194194
@test tₒ == t
195195
@test Tables.schema(tₒ) == Tables.schema(t)
196196

197-
x1 = rand(4000)
198-
x2 = rand(4000)
199-
y1 = rand(4000)
200-
y2 = rand(4000)
197+
x1 = rand(10)
198+
x2 = rand(10)
199+
y1 = rand(10)
200+
y2 = rand(10)
201201
t = Table(; x1, x2, y1, y2)
202202

203203
# select columns whose names contain the character x
@@ -241,12 +241,12 @@
241241
end
242242

243243
@testset "Reject" begin
244-
a = rand(4000)
245-
b = rand(4000)
246-
c = rand(4000)
247-
d = rand(4000)
248-
e = rand(4000)
249-
f = rand(4000)
244+
a = rand(10)
245+
b = rand(10)
246+
c = rand(10)
247+
d = rand(10)
248+
e = rand(10)
249+
f = rand(10)
250250
t = Table(; a, b, c, d, e, f)
251251

252252
T = Reject(:f, :d)
@@ -342,10 +342,10 @@ end
342342
tₒ = revert(T, n, c)
343343
@test t == tₒ
344344

345-
x1 = rand(4000)
346-
x2 = rand(4000)
347-
y1 = rand(4000)
348-
y2 = rand(4000)
345+
x1 = rand(10)
346+
x2 = rand(10)
347+
y1 = rand(10)
348+
y2 = rand(10)
349349
t = Table(; x1, x2, y1, y2)
350350

351351
# reject columns whose names contain the character x

test/transforms/sequential.jl

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,19 @@
33
y = x + rand(Normal(0, 2), 1500)
44
z = y + rand(Normal(0, 5), 1500)
55
t = Table(; x, y, z)
6+
67
T = Scale(low=0.2, high=0.8) EigenAnalysis(:VDV)
78
n, c = apply(T, t)
89
tₒ = revert(T, n, c)
910
@test Tables.matrix(t) Tables.matrix(tₒ)
1011

11-
x = rand(Normal(0, 10), 1500)
12-
y = x + rand(Normal(0, 2), 1500)
13-
z = y + rand(Normal(0, 5), 1500)
14-
t = Table(; x, y, z)
1512
T = Select(:x, :z) ZScore() EigenAnalysis(:V) Scale(low=0, high=1)
1613
n, c = apply(T, t)
1714
tₒ = revert(T, n, c)
1815
@test Tables.matrix(t) Tables.matrix(tₒ)
1916

2017
# reapply with Sequential transform
21-
t = Table(x=rand(1000))
18+
t = Table(x=rand(100))
2219
T = ZScore() Quantile()
2320
n1, c1 = apply(T, t)
2421
n2 = reapply(T, t, c1)

test/transforms/sort.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
@test t == tₒ
2929

3030
# random test
31-
a = rand(200)
32-
b = rand(200)
33-
c = rand(200)
34-
d = rand(200)
31+
a = rand(10)
32+
b = rand(10)
33+
c = rand(10)
34+
d = rand(10)
3535
t = Table(; a, b, c, d)
3636

3737
T = Sort(:c)

test/transforms/zscore.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@test Tables.matrix(rt) Tables.matrix(rtₒ)
3232

3333
# make sure transform works with single-column tables
34-
t = Table(x=rand(10000))
34+
t = Table(x=rand(100))
3535
n, c = apply(ZScore(), t)
3636
r = revert(ZScore(), n, c)
3737
@test isapprox(mean(n.x), 0.0, atol=1e-8)

0 commit comments

Comments
 (0)