|
23 | 23 | # needing the `FullInterface`.
|
24 | 24 | X = (1, 2, 3)
|
25 | 25 | @test_throws M.InterfaceError matrix(X)
|
26 |
| - |
| 26 | + |
27 | 27 | X = (a=[1, 2, 3], b=[1, 2, 3])
|
28 | 28 | @test_throws M.InterfaceError matrix(X)
|
29 | 29 | end
|
30 | 30 |
|
31 | 31 | @testset "matrix-full" begin
|
32 | 32 | setfull()
|
33 |
| - M.matrix(::FI, ::Val{:table}, X; kw...) = Tables.matrix(X; kw...) |
| 33 | + # next line commented out as already defined in test/mode.jl: |
| 34 | + # M.matrix(::FI, ::Val{:table}, X; kw...) = Tables.matrix(X; kw...) |
34 | 35 | X = (a=[1, 2, 3], b=[1, 2, 3])
|
35 | 36 | @test matrix(X) == hcat([1, 2, 3], [1, 2, 3])
|
36 | 37 | end
|
@@ -120,14 +121,14 @@ end
|
120 | 121 | # ------------------------------------------------------------------------
|
121 | 122 | @testset "istable" begin
|
122 | 123 | # Nothing stops someone from implementing a Tables.jl
|
123 |
| - # interface that subtypes `AbstractArray`, so therefore |
| 124 | + # interface that subtypes `AbstractArray`, so therefore |
124 | 125 | # `istable` should throw an error for `LightInterface`
|
125 | 126 | setlight()
|
126 | 127 | X = rand(5)
|
127 | 128 | @test_throws M.InterfaceError M.istable(X)
|
128 | 129 | X = randn(5, 5)
|
129 | 130 | @test_throws M.InterfaceError M.istable(X)
|
130 |
| - |
| 131 | + |
131 | 132 | # The method runs in `FullInterface`
|
132 | 133 | setfull()
|
133 | 134 | X = rand(5)
|
@@ -184,10 +185,10 @@ end
|
184 | 185 | X = ones(5)
|
185 | 186 | @test nrows(X) == 5
|
186 | 187 | X = ones(5, 3)
|
187 |
| - @test nrows(X) == 5 |
188 |
| - # It doesn't make sense to get the numbers of rows for |
189 |
| - # `AbstractArray`'s of dimension 3 or more. Except if these are |
190 |
| - # defined as Tables. Hence `FullInterface` would be required to check this |
| 188 | + @test nrows(X) == 5 |
| 189 | + # It doesn't make sense to get the numbers of rows for |
| 190 | + # `AbstractArray`'s of dimension 3 or more. Except if these are |
| 191 | + # defined as Tables. Hence `FullInterface` would be required to check this |
191 | 192 | X = ones(5, 3, 2)
|
192 | 193 | @test_throws ArgumentError nrows(X)
|
193 | 194 | M.nrows(::FI, ::Val{:table}, X) = Tables.rowcount(X)
|
@@ -220,13 +221,13 @@ end
|
220 | 221 |
|
221 | 222 | @testset "select-full" begin
|
222 | 223 | setfull()
|
223 |
| - |
| 224 | + |
224 | 225 | # test fallback
|
225 | 226 | X = nothing
|
226 | 227 | @test selectrows(X, 1) === nothing
|
227 | 228 | @test selectcols(X, 1) === nothing
|
228 | 229 | @test select(X, 1, 2) === nothing
|
229 |
| - |
| 230 | + |
230 | 231 | # vector
|
231 | 232 | X = ones(5)
|
232 | 233 | @test selectrows(X, 1) == [1.0]
|
@@ -273,11 +274,11 @@ end
|
273 | 274 |
|
274 | 275 | project(t::NamedTuple, label::Colon) = t
|
275 | 276 | project(t::NamedTuple, label::Symbol) = project(t, [label,])
|
276 |
| - |
| 277 | + |
277 | 278 | function project(t::NamedTuple, indices::AbstractArray{<:Integer})
|
278 | 279 | return NamedTuple{tuple(keys(t)[indices]...)}(tuple([t[i] for i in indices]...))
|
279 | 280 | end
|
280 |
| - |
| 281 | + |
281 | 282 | project(t::NamedTuple, i::Integer) = project(t, [i,])
|
282 | 283 |
|
283 | 284 | X = (x=[1, 2, 3], y=[4, 5, 6], z=[0, 0, 0])
|
|
292 | 293 | @test select(X, :, 1) == [1, 2, 3]
|
293 | 294 | @test selectcols(X, :x) == [1, 2, 3]
|
294 | 295 | @test select(X, 1:2, :z) == [0, 0]
|
295 |
| - |
| 296 | + |
296 | 297 | # extra tests by Anthony
|
297 | 298 | X = (x=[1, 2, 3], y=[10, 20, 30], z= [:a, :b, :c])
|
298 | 299 | @test select(X, 2, :y) == 20
|
|
0 commit comments