|
1 | | -using JuliaDBMeta, Compat, NamedTuples |
2 | | -using Compat.Test |
| 1 | +addprocs(4) |
3 | 2 |
|
4 | | -iris1 = loadtable(joinpath(@__DIR__, "tables", "iris.csv")) |
| 3 | +@everywhere using JuliaDBMeta, Compat, NamedTuples |
| 4 | +@everywhere using JuliaDB, Dagger |
| 5 | +@everywhere using Compat.Test |
| 6 | + |
| 7 | +iris1 = collect(loadtable(joinpath(@__DIR__, "tables", "iris.csv"))) |
5 | 8 | iris2 = table(iris1, chunks = 5) |
6 | 9 |
|
7 | 10 | @testset "utils" begin |
|
76 | 79 | @test (@where_vec t (:x .< 3) .& (:z .== 0.2)) == view(t, [2]) |
77 | 80 | @test @where_vec(t, 1:2) == view(t, 1:2) |
78 | 81 | @test @where_vec(rows(t), 1:2) == view(t, 1:2) |
| 82 | + @test JuliaDBMeta._view(rows(t), 1:2) == view(rows(t), 1:2) |
79 | 83 | @test @where_vec((:x .< 3) .& (:z .== 0.2))(t) == view(t, [2]) |
80 | 84 | @test (@where t (:x < 3) .& (:z == 0.2)) == view(t, [2]) |
81 | 85 | @test @where((:x < 3) .& (:z == 0.2))(t) == view(t, [2]) |
82 | 86 |
|
83 | 87 | t = table([1,1,3], [4,5,6], [0.1, 0.2, 0.3], names = [:x, :y, :z]) |
84 | 88 | grp = groupby(@map(@NT(z = :z))∘@where(:y != 5), t, :x, flatten = true) |
85 | 89 | @test grp == table([1, 3], [0.1, 0.3], names = [:x, :z], pkey = :x) |
86 | | - collect(@where iris2 :SepalLength > 4) == @where iris1 :SepalLength > 4 |
| 90 | + @test collect(@where iris2 :SepalLength > 4) == @where iris1 :SepalLength > 4 |
87 | 91 | end |
88 | 92 |
|
89 | 93 | @testset "apply" begin |
|
145 | 149 | @test @groupby({m = maximum(:y - :z) / _.key.x})(reindex(t, :x)) == outcome |
146 | 150 | @test @groupby(t, :x, {l = length(_)}) == table([1,2], [2,2], names = [:x, :l], pkey = :l) |
147 | 151 | @test @groupby(t, :x, {l = length(_)}) == t |> @groupby(:x, {l = length(_)}) |
| 152 | + @test @groupby(t, :x, flatten = true, _) == reindex(t, :x) |
| 153 | + @test @groupby(t, :x, {identity = _}) == groupby(identity, t, :x) |
148 | 154 | end |
0 commit comments