Skip to content

Commit

Permalink
tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Dec 20, 2023
1 parent 3983aa6 commit e396f01
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1859,6 +1859,10 @@ To select many columns at once use the tools `Not`, `Between`, `All`, and `Cols`
* `@select df Cols(...)` can be used to combine many different selectors, as well as use
regular expressions. For example `Cols(r"a")` selects all columns that start with `"a"`.
Expressions inside `Not(...)`, `Between(...)` etc. are untouched by DataFramesMeta's
parsing. To refer to a variable `x` which represents a column inside `Not`, write `Not(x)`,
rather than `Not($(DOLLAR)x)`.
$ASTABLE_MACRO_FLAG_DOCS
$ASTABLE_RHS_SELECT_TRANSFORM_DOCS
Expand Down
8 changes: 5 additions & 3 deletions src/parsing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,9 @@ function fun_to_vec(ex::Expr;
if allow_multicol
exhead = ex.head
if ex.head === :call
exhead === :All || exhead === :Not || exhead === :Cols || exhead === :Between
return ex
if exhead === :All || exhead === :Not || exhead === :Cols || exhead === :Between
return ex
end
end
end

Expand Down Expand Up @@ -427,7 +428,8 @@ end
fun_to_vec(ex::QuoteNode;
no_dest::Bool=false,
gensym_names::Bool=false,
outer_flags::Union{NamedTuple, Nothing}=nothing) = ex
outer_flags::Union{NamedTuple, Nothing}=nothing,
allow_multicol::Bool = false) = ex


"""
Expand Down
8 changes: 4 additions & 4 deletions test/dataframes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ s = [:i, :g]
# not part of DataFramesMeta.
@test_throws LoadError @eval @transform(df, [:i, :g])
@test_throws LoadError @eval @transform(df, All())
@test_throws LoadError @eval @transform(df, Between(:i, :t)).Between == df.i
@test_throws LoadError @eval @transform(df, Not(:i)).Not == df.i
@test_throws LoadError @eval @transform(df, Between(:i, :t))
@test_throws LoadError @eval @transform(df, Not(:i))
@test_throws LoadError @eval @transform(df, Not([:i, :g]))
@test_throws MethodError @eval @transform(df, :n = sum(Between(:i, :t)))
@test_throws LoadError @eval @transform(df, :n = sum(Between(:i, :t)))
end

@testset "@select" begin
Expand Down Expand Up @@ -550,7 +550,7 @@ cr = "c"
@test_throws LoadError @eval @select(df, Between(:i, :t)).Between == df.i
@test_throws LoadError @eval @select(df, Not(:i)).Not == df.i
@test_throws LoadError @eval @select(df, Not([:i, :g]))
@test_throws MethodError @eval @select(df, :n = sum(Between(:i, :t)))
@test_throws LoadError @eval @select(df, :n = sum(Between(:i, :t)))
end

@testset "with" begin
Expand Down
4 changes: 2 additions & 2 deletions test/grouping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ gd = groupby(df, :g)
newvar = :n

@testset "Limits of @combine" begin
@test_throws MethodError @eval @combine(gd, :n = sum(Between(:i, :t)))
@test_throws LoadError @eval @combine(gd, :n = sum(Between(:i, :t)))
@test_throws ArgumentError @eval @combine(gd, :n = mean(:i) + mean(cols(1)))
end

Expand Down Expand Up @@ -287,7 +287,7 @@ gd = groupby(df, :g)
newvar = :n

@testset "limits of @by" begin
@test_throws MethodError @eval @by(df, :g, :n = sum(Between(:i, :t)))
@test_throws LoadError @eval @by(df, :g, :n = sum(Between(:i, :t)))
@test_throws ArgumentError @eval @by(df, :g, :n = mean(:i) + mean(cols(1)))
end

Expand Down

0 comments on commit e396f01

Please sign in to comment.