Skip to content

Commit

Permalink
Merge branch 'master' into 15_0_release
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Mar 1, 2024
2 parents 35821bd + 4f482da commit fced349
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function with_helper(d, body)
# complicated method of fun_to_vec
# in the case of QuoteNode
t = fun_to_vec(Expr(:block, body); no_dest=true)
:(DataFramesMeta.exec($d, $t))
:($exec($d, $t))
end

"""
Expand Down Expand Up @@ -2453,7 +2453,7 @@ function distinct_helper(x, args...)
x, exprs, outer_flags, kw = get_df_args_kwargs(x, args...; wrap_byrow = false)
t = (fun_to_vec(ex; no_dest = true, outer_flags=outer_flags) for ex in exprs)
quote
$DataFramesMeta.make_distinct($x, $(t...); $(kw...))
$make_distinct($x, $(t...); $(kw...))
end
end

Expand Down Expand Up @@ -2560,7 +2560,7 @@ function rdistinct_helper(x, args...)
x, exprs, outer_flags, kw = get_df_args_kwargs(x, args...; wrap_byrow = true)
t = (fun_to_vec(ex; no_dest = true, outer_flags=outer_flags) for ex in exprs)
quote
$DataFramesMeta.make_distinct($x, $(t...); $(kw...))
$make_distinct($x, $(t...); $(kw...))
end
end

Expand Down Expand Up @@ -2620,7 +2620,7 @@ function distinct!_helper(x, args...)
x, exprs, outer_flags, kw = get_df_args_kwargs(x, args...; wrap_byrow = false)
t = (fun_to_vec(ex; no_dest = true, outer_flags=outer_flags) for ex in exprs)
quote
$DataFramesMeta.make_distinct!($x, $(t...); $(kw...))
$make_distinct!($x, $(t...); $(kw...))
end
end

Expand Down Expand Up @@ -2732,7 +2732,7 @@ function rdistinct!_helper(x, args...)
x, exprs, outer_flags, kw = get_df_args_kwargs(x, args...; wrap_byrow = true)
t = (fun_to_vec(ex; no_dest = true, outer_flags=outer_flags) for ex in exprs)
quote
$DataFramesMeta.make_distinct!($x, $(t...); $(kw...))
$make_distinct!($x, $(t...); $(kw...))
end
end

Expand Down
6 changes: 3 additions & 3 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function args_to_selectors(v)
col
end

:(DataFramesMeta.make_source_concrete($(Expr(:vect, t...))))
:($make_source_concrete($(Expr(:vect, t...))))
end

is_macro_head(ex, name) = false
Expand Down Expand Up @@ -280,7 +280,7 @@ function get_source_fun(function_expr; exprflags = deepcopy(DEFAULT_FLAGS))
source = args_to_selectors(function_expr.args[2:end])
fun_t = function_expr.args[1]

# .+ to +
# .+ to Expr(:., +)
fun = fix_simple_dot(fun_t)
elseif is_simple_broadcast_call(function_expr)
# extract source symbols from quotenodes
Expand All @@ -296,7 +296,7 @@ function get_source_fun(function_expr; exprflags = deepcopy(DEFAULT_FLAGS))
membernames = Dict{Any, Symbol}()

body = replace_syms!(membernames, function_expr)
source = :(DataFramesMeta.make_source_concrete($(Expr(:vect, keys(membernames)...))))
source = :($make_source_concrete($(Expr(:vect, keys(membernames)...))))
inputargs = Expr(:tuple, values(membernames)...)
fun = quote
$inputargs -> begin
Expand Down
7 changes: 4 additions & 3 deletions src/parsing_astable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function replace_syms_astable!(inputs_to_function::AbstractDict,
return e.args[2]
end

println(e)
col = get_column_expr(e)
if col !== nothing
return conditionally_add_symbols!(inputs_to_function, lhs_assignments, col)
Expand All @@ -35,7 +36,7 @@ protect_replace_syms_astable!(inputs_to_function::AbstractDict,
lhs_assignments::OrderedCollections.OrderedDict, e) = e
protect_replace_syms_astable!(inputs_to_function::AbstractDict,
lhs_assignments::OrderedCollections.OrderedDict, e::Expr) =
replace_syms!(inputs_to_function, lhs_assignments, e)
replace_syms_astable!(inputs_to_function, lhs_assignments, e)

function replace_dotted_astable!(inputs_to_function::AbstractDict,
lhs_assignments::OrderedCollections.OrderedDict, e)
Expand Down Expand Up @@ -81,10 +82,10 @@ function get_source_fun_astable(ex; exprflags = deepcopy(DEFAULT_FLAGS))
replace_syms_astable!(inputs_to_function, lhs_assignments, arg)
end
end
source = :(DataFramesMeta.make_source_concrete($(Expr(:vect, keys(inputs_to_function)...))))
source = :($make_source_concrete($(Expr(:vect, keys(inputs_to_function)...))))

inputargs = Expr(:tuple, values(inputs_to_function)...)
nt_iterator = (:(DataFramesMeta.sym_or_str_to_sym($k) => $v) for (k, v) in lhs_assignments)
nt_iterator = (:($sym_or_str_to_sym($k) => $v) for (k, v) in lhs_assignments)
nt_expr = Expr(:tuple, Expr(:parameters, nt_iterator...))

body = Expr(:block, Expr(:block, exprs...), nt_expr)
Expand Down
14 changes: 14 additions & 0 deletions test/astable_flag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,18 @@ end
@test_throws ArgumentError @eval @transform df @astable cols(AsTable) = :y
end

@testset "Broadcasting bugfix #380" begin
df = DataFrame(x=["a","b"], y = [1, 2], z = [3, 4])
@transform df @astable :a = string.(:x, "c")
@transform df @astable :a = :y .+ :z
@transform df @astable :a = (+).(:y, :z)
@select df @astable begin
:a = string.(:x, "c")
:b = string.(:x, :y)
:c = string.(:x, $"y")
:d = :y .+ :z
:e = (+).(:y, :z)
end
end

end # module

0 comments on commit fced349

Please sign in to comment.