|
6 | 6 | result = QueryOperators.pivot_longer(data, (:US, :EU, :CN)) |> collect |
7 | 7 |
|
8 | 8 | @test length(result) == 6 |
9 | | - @test eltype(result) == NamedTuple{(:variable, :value), Tuple{Symbol, Int64}} |
| 9 | + @test eltype(result) == NamedTuple{(:variable, :value), Tuple{Symbol, Int}} |
10 | 10 | @test result[1] == (variable=:US, value=1) |
11 | 11 | @test result[2] == (variable=:EU, value=2) |
12 | 12 | @test result[3] == (variable=:CN, value=3) |
|
19 | 19 | result2 = QueryOperators.pivot_longer(data2, (:US, :EU)) |> collect |
20 | 20 |
|
21 | 21 | @test length(result2) == 4 |
22 | | - @test eltype(result2) == NamedTuple{(:year, :variable, :value), Tuple{Int64, Symbol, Int64}} |
| 22 | + @test eltype(result2) == NamedTuple{(:year, :variable, :value), Tuple{Int, Symbol, Int}} |
23 | 23 | @test result2[1] == (year=2017, variable=:US, value=1) |
24 | 24 | @test result2[2] == (year=2017, variable=:EU, value=2) |
25 | 25 | @test result2[3] == (year=2018, variable=:US, value=3) |
|
28 | 28 | # Custom names_to and values_to |
29 | 29 | result3 = QueryOperators.pivot_longer(data2, (:US, :EU); names_to=:country, values_to=:sales) |> collect |
30 | 30 |
|
31 | | - @test eltype(result3) == NamedTuple{(:year, :country, :sales), Tuple{Int64, Symbol, Int64}} |
| 31 | + @test eltype(result3) == NamedTuple{(:year, :country, :sales), Tuple{Int, Symbol, Int}} |
32 | 32 | @test result3[1] == (year=2017, country=:US, sales=1) |
33 | 33 |
|
34 | 34 | # Type promotion: mixing Int and Float |
35 | 35 | data3 = QueryOperators.query([(id=1, a=1, b=2.0)]) |
36 | 36 | result4 = QueryOperators.pivot_longer(data3, (:a, :b)) |> collect |
37 | 37 |
|
38 | | - @test eltype(result4) == NamedTuple{(:id, :variable, :value), Tuple{Int64, Symbol, Float64}} |
| 38 | + @test eltype(result4) == NamedTuple{(:id, :variable, :value), Tuple{Int, Symbol, Float64}} |
39 | 39 | @test result4[1] == (id=1, variable=:a, value=1.0) |
40 | 40 | @test result4[2] == (id=1, variable=:b, value=2.0) |
41 | 41 |
|
|
97 | 97 | @test length(result) == 2 |
98 | 98 | T = eltype(result) |
99 | 99 | @test fieldnames(T) == (:year, :US, :EU) |
100 | | - @test fieldtype(T, :US) == DataValue{Int64} |
| 100 | + @test fieldtype(T, :US) == DataValue{Int} |
101 | 101 | @test result[1].year == 2017 |
102 | 102 | @test result[1].US == DataValue(1) |
103 | 103 | @test result[1].EU == DataValue(2) |
|
0 commit comments