|
44 | 44 | sds = view(ds, [1,2,2,1,3,4,5,5,5], [2,1]) |
45 | 45 | @test byrow(sds, isequal, :, threads = true) == [0,1,1,0,0,0, 1,1,1] |
46 | 46 | @test byrow(sds, isequal, [1], threads = true) == ones(9) |
| 47 | + |
| 48 | + ds = Dataset(x1 = [1,2,3,4,missing], x2 = [3,2,4,5, missing]) |
| 49 | + @test byrow(ds, issorted, :) == [true, true, true, true, true] |
| 50 | + @test byrow(ds, issorted, :, rev = true) == [false, true, false, false, true] |
| 51 | + |
| 52 | + ds = Dataset(randn(10000, 3), :auto) |
| 53 | + map!(ds, x->rand()<.1 ? missing : x, :) |
| 54 | + dsm = Matrix(ds) |
| 55 | + @test byrow(ds, issorted, :) == issorted.(eachrow(dsm)) |
| 56 | + @test byrow(ds, issorted, :, rev = true) == issorted.(eachrow(dsm), rev = true) |
| 57 | + insertcols!(ds, 1, :y=>rand(-1:1, nrow(ds))) |
| 58 | + dsm = Matrix(ds) |
| 59 | + @test byrow(ds, issorted, :) == byrow(ds, issorted, :, threads = false) == issorted.(eachrow(dsm)) |
| 60 | + @test byrow(ds, issorted, :, rev = true) == byrow(ds, issorted, :, rev = true, threads = false) == issorted.(eachrow(dsm), rev = true) |
| 61 | + |
| 62 | + ds = Dataset(g = [1, 1, 1, 2, 2], |
| 63 | + x1_int = [0, 0, 1, missing, 2], |
| 64 | + x2_int = [3, 2, 1, 3, -2], |
| 65 | + x1_float = [1.2, missing, -1.0, 2.3, 10], |
| 66 | + x2_float = [missing, missing, 3.0, missing, missing], |
| 67 | + x3_float = [missing, missing, -1.4, 3.0, -100.0]) |
| 68 | + @test isequal(byrow(ds, findfirst, :, by = ismissing), ["x2_float", "x1_float", missing, "x1_int", "x2_float"]) |
| 69 | + @test isequal(byrow(ds, findlast, :, by = ismissing), ["x3_float", "x3_float", missing, "x2_float", "x2_float"]) |
| 70 | + @test isequal(byrow(ds, findfirst, :, by = x->isless(x,0)), [missing, missing, "x1_float", missing, "x2_int"]) |
| 71 | + @test isequal(byrow(ds, findlast, :, by = x->isless(x,0)), [missing, missing, "x3_float", missing, "x3_float"]) |
| 72 | + @test isequal(byrow(ds, findfirst, :, by = x->1), ["g","g","g", "g","g"]) |
| 73 | + @test isequal(byrow(ds, findfirst, :), ["g","g","g", missing, missing]) |
| 74 | + @test isequal(byrow(ds, findlast, :), ["g","g","x2_int", missing, missing]) |
| 75 | + @test isequal(byrow(ds, findfirst, [3,2,1], by = isequal(2)) ,byrow(ds, findlast, 1:3, by = isequal(2))) |
| 76 | + @test isequal(byrow(ds, findfirst, 1:3, by = isequal(2)) ,byrow(ds, findlast, [3,2,1], by = isequal(2))) |
| 77 | + |
| 78 | + |
| 79 | + sds = view(ds, rand(1:5, 100), [2,1,6,5,3,4]) |
| 80 | + @test isequal(byrow(sds, findfirst,:, by = x->isless(x,0)), byrow(Dataset(sds), findfirst, :, by = x->isless(x,0))) |
| 81 | + @test isequal(byrow(sds, findlast,:, by = x->isless(x,0)), byrow(Dataset(sds), findlast, :, by = x->isless(x,0))) |
| 82 | + @test isequal(byrow(sds, findfirst,:, by = x->isless(x,0), threads = true), byrow(Dataset(sds), findfirst, :, by = x->isless(x,0))) |
| 83 | + @test isequal(byrow(sds, findlast,:, by = x->isless(x,0), threads = true), byrow(Dataset(sds), findlast, :, by = x->isless(x,0))) |
| 84 | + sds = view(ds, rand(1:5, 100), [2,1,6,5,3,4]) |
| 85 | + @test isequal(byrow(sds, findfirst,:, by = x->isless(x,0)), byrow(Dataset(sds), findfirst, :, by = x->isless(x,0))) |
| 86 | + @test isequal(byrow(sds, findlast,:, by = x->isless(x,0)), byrow(Dataset(sds), findlast, :, by = x->isless(x,0))) |
| 87 | + @test isequal(byrow(sds, findfirst,:, by = x->isless(x,0), threads = true), byrow(Dataset(sds), findfirst, :, by = x->isless(x,0))) |
| 88 | + @test isequal(byrow(sds, findlast,:, by = x->isless(x,0), threads = true), byrow(Dataset(sds), findlast, :, by = x->isless(x,0))) |
| 89 | + |
| 90 | + sds = view(ds, rand(1:5, 100), [2,1,3,4]) |
| 91 | + @test isequal(byrow(sds, findfirst,[1,4,3,2], by = x->isless(x,0)), byrow(Dataset(sds), findfirst, [1,4,3,2], by = x->isless(x,0))) |
| 92 | + @test isequal(byrow(sds, findlast,[1,4,3,2], by = x->isless(x,0)), byrow(Dataset(sds), findlast, [1,4,3,2], by = x->isless(x,0))) |
| 93 | + @test isequal(byrow(sds, findfirst,[1,4,3,2], by = x->isless(x,0), threads = true), byrow(Dataset(sds), findfirst, [1,4,3,2], by = x->isless(x,0))) |
| 94 | + @test isequal(byrow(sds, findlast,[1,4,3,2], by = x->isless(x,0), threads = true), byrow(Dataset(sds), findlast, [1,4,3,2], by = x->isless(x,0))) |
| 95 | + |
| 96 | + |
47 | 97 | end |
48 | 98 |
|
49 | 99 | @testset "cum*/!" begin |
|
0 commit comments