Skip to content

Commit

Permalink
change test for tables
Browse files Browse the repository at this point in the history
  • Loading branch information
panlanfeng committed Sep 16, 2016
1 parent 312db7b commit 08194f0
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions test/tabletest.jl
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
using StatsBase
x = repeat(["a", "b", "c", "d"], outer=[100]);
y = repeat(["A", "B", "C", "D"], inner=[10], outer=[10]);

srand(2016);
x = sample(1:5, 100);
y = sample(["a", "b"], 100);
table1 = RFlavor.table(y)
table2=RFlavor.table(x, y)

@test sprint(show, table1) == """\
2-element Named Array{Int64,1}
Dim1 │
──┼───
a │ 61
b │ 39"""

@test sprint(show, table2) == """\
5×2 Named Array{Int64,2}
Dim1 ╲ Dim2 │ a b
────────────┼───────
1 │ 14 9
2 │ 15 7
3 │ 10 10
4 │ 10 5
5 │ 12 8"""
@test table(x).array == [100, 100, 100, 100]
@test table(y).array == [100, 100, 100, 100]
@test table(x, y).array == [30 20 30 20;
30 20 30 20;
20 30 20 30;
20 30 20 30]

0 comments on commit 08194f0

Please sign in to comment.