|
8 | 8 | t = Table(; a, b, c, d, e, f) |
9 | 9 |
|
10 | 10 | # Tables.jl interface |
11 | | - select = [:a, :b, :e] |
12 | | - newnames = select |
13 | | - s = TT.TableSelection(t, newnames, select) |
| 11 | + names = [:a, :b, :e] |
| 12 | + s = TT.TableSelection(t, names) |
14 | 13 | @test Tables.istable(s) == true |
15 | 14 | @test Tables.columnaccess(s) == true |
16 | 15 | @test Tables.rowaccess(s) == false |
17 | 16 | @test Tables.columns(s) === s |
18 | | - @test Tables.columnnames(s) == [:a, :b, :e] |
| 17 | + @test Tables.columnnames(s) == (:a, :b, :e) |
19 | 18 | @test Tables.schema(s).names == (:a, :b, :e) |
20 | 19 | @test Tables.schema(s).types == (Float64, Float64, Float64) |
21 | 20 | @test Tables.materializer(s) == Tables.materializer(t) |
|
26 | 25 | @test Tables.getcolumn(s, 1) == Tables.getcolumn(cols, 1) |
27 | 26 | @test Tables.getcolumn(s, 3) == Tables.getcolumn(cols, :e) |
28 | 27 |
|
29 | | - # selectin with renaming |
30 | | - select = [:c, :d, :f] |
31 | | - newnames = [:x, :y, :z] |
32 | | - s = TT.TableSelection(t, newnames, select) |
33 | | - @test Tables.columnnames(s) == [:x, :y, :z] |
34 | | - @test Tables.getcolumn(s, :x) == t.c |
35 | | - @test Tables.getcolumn(s, :y) == t.d |
36 | | - @test Tables.getcolumn(s, :z) == t.f |
37 | | - @test Tables.getcolumn(s, 1) == t.c |
38 | | - @test Tables.getcolumn(s, 2) == t.d |
39 | | - @test Tables.getcolumn(s, 3) == t.f |
40 | | - |
41 | 28 | # row table |
42 | | - select = [:a, :b, :e] |
43 | | - newnames = select |
| 29 | + names = [:a, :b, :e] |
44 | 30 | rt = Tables.rowtable(t) |
45 | | - s = TT.TableSelection(rt, newnames, select) |
| 31 | + s = TT.TableSelection(rt, names) |
46 | 32 | cols = Tables.columns(rt) |
47 | 33 | @test Tables.getcolumn(s, :a) == Tables.getcolumn(cols, :a) |
48 | 34 | @test Tables.getcolumn(s, 1) == Tables.getcolumn(cols, 1) |
49 | 35 | @test Tables.getcolumn(s, 3) == Tables.getcolumn(cols, :e) |
50 | 36 |
|
51 | 37 | # throws |
52 | | - @test_throws AssertionError TT.TableSelection(t, [:a, :b, :z], [:a, :b, :z]) |
53 | | - @test_throws AssertionError TT.TableSelection(t, [:x, :y, :z], [:c, :d, :k]) |
54 | | - s = TT.TableSelection(t, [:a, :b, :e], [:a, :b, :e]) |
55 | | - @test_throws ErrorException Tables.getcolumn(s, :f) |
56 | | - @test_throws ErrorException Tables.getcolumn(s, 4) |
57 | | - s = TT.TableSelection(t, [:x, :y, :z], [:c, :d, :f]) |
58 | | - @test_throws ErrorException Tables.getcolumn(s, :c) |
59 | | - @test_throws ErrorException Tables.getcolumn(s, 4) |
60 | | - @test_throws ErrorException Tables.getcolumn(s, -2) |
| 38 | + @test_throws AssertionError TT.TableSelection(t, [:a, :b, :z]) |
| 39 | + @test_throws AssertionError TT.TableSelection(t, [:x, :y, :z]) |
61 | 40 | end |
0 commit comments