|
9 | 9 |
|
10 | 10 | T = Map(1 => sin) |
11 | 11 | n, c = apply(T, t) |
12 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :sin_a) |
| 12 | + @test Tables.schema(n).names == (:sin_a,) |
13 | 13 | @test n.sin_a == sin.(t.a) |
14 | 14 |
|
15 | 15 | T = Map(:b => cos) |
16 | 16 | n, c = apply(T, t) |
17 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :cos_b) |
| 17 | + @test Tables.schema(n).names == (:cos_b,) |
18 | 18 | @test n.cos_b == cos.(t.b) |
19 | 19 |
|
20 | 20 | T = Map("c" => tan) |
21 | 21 | n, c = apply(T, t) |
22 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :tan_c) |
| 22 | + @test Tables.schema(n).names == (:tan_c,) |
23 | 23 | @test n.tan_c == tan.(t.c) |
24 | 24 |
|
25 | 25 | T = Map(:a => sin => :a) |
26 | 26 | n, c = apply(T, t) |
27 | | - @test Tables.schema(n).names == (:a, :b, :c, :d) |
| 27 | + @test Tables.schema(n).names == (:a,) |
28 | 28 | @test n.a == sin.(t.a) |
29 | 29 |
|
30 | 30 | T = Map(:a => sin => "a") |
31 | 31 | n, c = apply(T, t) |
32 | | - @test Tables.schema(n).names == (:a, :b, :c, :d) |
| 32 | + @test Tables.schema(n).names == (:a,) |
33 | 33 | @test n.a == sin.(t.a) |
34 | 34 |
|
35 | 35 | T = Map([2, 3] => ((b, c) -> 2b + c) => :op1) |
36 | 36 | n, c = apply(T, t) |
37 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :op1) |
| 37 | + @test Tables.schema(n).names == (:op1,) |
38 | 38 | @test n.op1 == @. 2 * t.b + t.c |
39 | 39 |
|
40 | 40 | T = Map([:a, :c] => ((a, c) -> 2a * 3c) => :op1) |
41 | 41 | n, c = apply(T, t) |
42 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :op1) |
| 42 | + @test Tables.schema(n).names == (:op1,) |
43 | 43 | @test n.op1 == @. 2 * t.a * 3 * t.c |
44 | 44 |
|
45 | 45 | T = Map(["c", "a"] => ((c, a) -> 3c / a) => :op1, "c" => tan) |
46 | 46 | n, c = apply(T, t) |
47 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :op1, :tan_c) |
| 47 | + @test Tables.schema(n).names == (:op1, :tan_c) |
48 | 48 | @test n.op1 == @. 3 * t.c / t.a |
49 | 49 | @test n.tan_c == tan.(t.c) |
50 | 50 |
|
51 | 51 | T = Map(r"[abc]" => ((a, b, c) -> a^2 - 2b + c) => "op1") |
52 | 52 | n, c = apply(T, t) |
53 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :op1) |
| 53 | + @test Tables.schema(n).names == (:op1,) |
54 | 54 | @test n.op1 == @. t.a^2 - 2 * t.b + t.c |
55 | 55 |
|
56 | 56 | # generated names |
57 | 57 | # normal function |
58 | 58 | T = Map([:c, :d] => hypot) |
59 | 59 | n, c = apply(T, t) |
60 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :hypot_c_d) |
| 60 | + @test Tables.schema(n).names == (:hypot_c_d,) |
61 | 61 | @test n.hypot_c_d == hypot.(t.c, t.d) |
62 | 62 |
|
63 | 63 | # anonymous function |
|
66 | 66 | colname = Symbol(fname, :_a) |
67 | 67 | T = Map(:a => f) |
68 | 68 | n, c = apply(T, t) |
69 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, colname) |
| 69 | + @test Tables.schema(n).names == (colname,) |
70 | 70 | @test Tables.getcolumn(n, colname) == f.(t.a) |
71 | 71 |
|
72 | 72 | # composed function |
73 | 73 | f = sin ∘ cos |
74 | 74 | T = Map(:b => f) |
75 | 75 | n, c = apply(T, t) |
76 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :sin_cos_b) |
| 76 | + @test Tables.schema(n).names == (:sin_cos_b,) |
77 | 77 | @test n.sin_cos_b == f.(t.b) |
78 | 78 |
|
79 | 79 | f = sin ∘ cos ∘ tan |
80 | 80 | T = Map(:c => sin ∘ cos ∘ tan) |
81 | 81 | n, c = apply(T, t) |
82 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :sin_cos_tan_c) |
| 82 | + @test Tables.schema(n).names == (:sin_cos_tan_c,) |
83 | 83 | @test n.sin_cos_tan_c == f.(t.c) |
84 | 84 |
|
85 | 85 | # Base.Fix1 |
86 | 86 | f = Base.Fix1(hypot, 2) |
87 | 87 | T = Map(:d => f) |
88 | 88 | n, c = apply(T, t) |
89 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :fix1_hypot_d) |
| 89 | + @test Tables.schema(n).names == (:fix1_hypot_d,) |
90 | 90 | @test n.fix1_hypot_d == f.(t.d) |
91 | 91 |
|
92 | 92 | # Base.Fix2 |
93 | 93 | f = Base.Fix2(hypot, 2) |
94 | 94 | T = Map(:a => f) |
95 | 95 | n, c = apply(T, t) |
96 | | - @test Tables.schema(n).names == (:a, :b, :c, :d, :fix2_hypot_a) |
| 96 | + @test Tables.schema(n).names == (:fix2_hypot_a,) |
97 | 97 | @test n.fix2_hypot_a == f.(t.a) |
98 | 98 |
|
99 | 99 | # error: cannot create Map transform without arguments |
|
0 commit comments