|
104 | 104 | @inferred TableTransforms.choose(colspec, vecnames)
|
105 | 105 | @inferred TableTransforms.choose(colspec, tupnames)
|
106 | 106 | end
|
107 |
| - |
108 |
| -@testset "TableSelection" begin |
109 |
| - a = rand(4000) |
110 |
| - b = rand(4000) |
111 |
| - c = rand(4000) |
112 |
| - d = rand(4000) |
113 |
| - e = rand(4000) |
114 |
| - f = rand(4000) |
115 |
| - t = Table(; a, b, c, d, e, f) |
116 |
| - |
117 |
| - # Tables.jl interface |
118 |
| - select = [:a, :b, :e] |
119 |
| - newnames = select |
120 |
| - s = TableTransforms.TableSelection(t, newnames, select) |
121 |
| - @test Tables.istable(s) == true |
122 |
| - @test Tables.columnaccess(s) == true |
123 |
| - @test Tables.rowaccess(s) == false |
124 |
| - @test Tables.columns(s) === s |
125 |
| - @test Tables.columnnames(s) == [:a, :b, :e] |
126 |
| - @test Tables.schema(s).names == (:a, :b, :e) |
127 |
| - @test Tables.schema(s).types == (Float64, Float64, Float64) |
128 |
| - @test Tables.materializer(s) == Tables.materializer(t) |
129 |
| - |
130 |
| - # getcolumn |
131 |
| - cols = Tables.columns(t) |
132 |
| - @test Tables.getcolumn(s, :a) == Tables.getcolumn(cols, :a) |
133 |
| - @test Tables.getcolumn(s, 1) == Tables.getcolumn(cols, 1) |
134 |
| - @test Tables.getcolumn(s, 3) == Tables.getcolumn(cols, :e) |
135 |
| - |
136 |
| - # selectin with renaming |
137 |
| - select = [:c, :d, :f] |
138 |
| - newnames = [:x, :y, :z] |
139 |
| - s = TableTransforms.TableSelection(t, newnames, select) |
140 |
| - @test Tables.columnnames(s) == [:x, :y, :z] |
141 |
| - @test Tables.getcolumn(s, :x) == t.c |
142 |
| - @test Tables.getcolumn(s, :y) == t.d |
143 |
| - @test Tables.getcolumn(s, :z) == t.f |
144 |
| - |
145 |
| - # row table |
146 |
| - select = [:a, :b, :e] |
147 |
| - newnames = select |
148 |
| - rt = Tables.rowtable(t) |
149 |
| - s = TableTransforms.TableSelection(rt, newnames, select) |
150 |
| - cols = Tables.columns(rt) |
151 |
| - @test Tables.getcolumn(s, :a) == Tables.getcolumn(cols, :a) |
152 |
| - @test Tables.getcolumn(s, 1) == Tables.getcolumn(cols, 1) |
153 |
| - @test Tables.getcolumn(s, 3) == Tables.getcolumn(cols, :e) |
154 |
| - |
155 |
| - # throws |
156 |
| - @test_throws AssertionError TableTransforms.TableSelection(t, [:a, :b, :z], [:a, :b, :z]) |
157 |
| - @test_throws AssertionError TableTransforms.TableSelection(t, [:x, :y, :z], [:c, :d, :k]) |
158 |
| - s = TableTransforms.TableSelection(t, [:a, :b, :e], [:a, :b, :e]) |
159 |
| - @test_throws ErrorException Tables.getcolumn(s, :f) |
160 |
| - s = TableTransforms.TableSelection(t, [:x, :y, :z], [:c, :d, :f]) |
161 |
| - @test_throws ErrorException Tables.getcolumn(s, :c) |
162 |
| -end |
0 commit comments