|
1 | 1 | @testset "group" begin
|
2 | 2 | @test group(identity, 11:20)::Dictionary == Dictionary(11:20, (x->[x]).(11:20))
|
3 |
| - @test group(iseven, 1:10)::Dictionary == dictionary(true => [2,4,6,8,10], false => [1,3,5,7,9]) |
| 3 | + @test group(iseven, 1:10)::Dictionary == dictionary([false => [1,3,5,7,9], true => [2,4,6,8,10]]) |
4 | 4 |
|
5 |
| - @test group(iseven, x -> x*2, 1:10)::Dictionary == dictionary(true => [4,8,12,16,20], false => [2,6,10,14,18]) |
| 5 | + @test group(iseven, x -> x*2, 1:10)::Dictionary == dictionary([false => [2,6,10,14,18], true => [4,8,12,16,20]]) |
6 | 6 |
|
7 |
| - @test group((x,y) -> iseven(x+y), (x,y) -> x, 1:10, [1,3,4,2,5,6,4,2,3,9])::Dictionary == dictionary(true => [1,4,5,6,8,9], false => [2,3,7,10]) |
| 7 | + @test group((x,y) -> iseven(x+y), (x,y) -> x, 1:10, [1,3,4,2,5,6,4,2,3,9])::Dictionary == dictionary([true => [1,4,5,6,8,9], false => [2,3,7,10]]) |
8 | 8 | end
|
9 | 9 |
|
10 | 10 | @testset "grouponly" begin
|
|
14 | 14 |
|
15 | 15 | @testset "groupunique" begin
|
16 | 16 | @test groupunique(identity, 11:20)::Dictionary{Int, Indices{Int}} == Dictionary(11:20, map(x -> Indices([x]), 11:20))
|
17 |
| - @test groupunique(iseven, 11:20)::Dictionary{Bool, Indices{Int}} == dictionary(true => Indices([12,14,16,18,20]), false => Indices([11,13,15,17,19])) |
| 17 | + @test groupunique(iseven, 11:20)::Dictionary{Bool, Indices{Int}} == dictionary([false => Indices([11,13,15,17,19]), true => Indices([12,14,16,18,20])]) |
18 | 18 | end
|
19 | 19 |
|
20 | 20 | @testset "groupfind" begin
|
21 | 21 | @test groupfind(identity, 11:20) == Dictionary(11:20, (x->[x]).(1:10))
|
22 |
| - @test groupfind(iseven, 11:20) == dictionary(true => [2,4,6,8,10], false => [1,3,5,7,9]) |
| 22 | + @test groupfind(iseven, 11:20) == dictionary([false => [1,3,5,7,9], true => [2,4,6,8,10]]) |
23 | 23 | end
|
24 | 24 |
|
25 | 25 | @testset "groupview" begin
|
|
29 | 29 |
|
30 | 30 | @testset "groupreduce" begin
|
31 | 31 | @test groupreduce(identity, +, 1:10) == Dictionary(1:10, 1:10)
|
32 |
| - @test groupreduce(iseven, +, 1:10) == dictionary(true => 30, false => 25) |
| 32 | + @test groupreduce(iseven, +, 1:10) == dictionary([false => 25, true => 30]) |
33 | 33 |
|
34 |
| - @test groupreduce(iseven, x -> x*2, +, 1:10) == dictionary(true => 60, false => 50) |
| 34 | + @test groupreduce(iseven, x -> x*2, +, 1:10) == dictionary([false => 50, true => 60]) |
35 | 35 |
|
36 |
| - @test groupreduce(iseven, x -> x*2, +, 1:10; init=10) == dictionary(true => 70, false => 60) |
| 36 | + @test groupreduce(iseven, x -> x*2, +, 1:10; init=10) == dictionary([false => 60, true => 70]) |
37 | 37 |
|
38 |
| - @test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, 1:10; init=10) == dictionary(true => 120) |
39 |
| - @test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, [1,3,4,2,5,6,4,2,3,9]; init=10) == dictionary(true => 62, false => 52) |
| 38 | + @test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, 1:10; init=10) == dictionary([true => 120]) |
| 39 | + @test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, [1,3,4,2,5,6,4,2,3,9]; init=10) == dictionary([true => 62, false => 52]) |
40 | 40 |
|
41 |
| - @test groupcount(iseven, 1:10) == dictionary(true => 5, false => 5) |
42 |
| - @test groupsum(iseven, 1:10) == dictionary(true => 30, false => 25) |
43 |
| - @test groupprod(iseven, 1:10) == dictionary(true => 2*4*6*8*10, false => 1*3*5*7*9) |
44 |
| - @test groupfirst(iseven, 1:10) == dictionary(true => 2, false => 1) |
45 |
| - @test grouplast(iseven, 1:10) == dictionary(true => 10, false => 9) |
| 41 | + @test groupcount(iseven, 1:10) == dictionary([false => 5, true => 5]) |
| 42 | + @test groupsum(iseven, 1:10) == dictionary([false => 25, true => 30]) |
| 43 | + @test groupprod(iseven, 1:10) == dictionary([false => 1*3*5*7*9, true => 2*4*6*8*10]) |
| 44 | + @test groupfirst(iseven, 1:10) == dictionary([false => 1, true => 2]) |
| 45 | + @test grouplast(iseven, 1:10) == dictionary([false => 9, true => 10]) |
46 | 46 | end
|
0 commit comments