From e396f01c340c200aab9403d1d703bff24d2b2b4c Mon Sep 17 00:00:00 2001
From: Peter Deffebach
Date: Wed, 20 Dec 2023 11:23:21 -0500
Subject: [PATCH] tests pass
---
src/macros.jl | 4 ++++
src/parsing.jl | 8 +++++---
test/dataframes.jl | 8 ++++----
test/grouping.jl | 4 ++--
4 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/macros.jl b/src/macros.jl
index 08867216..055cb4a2 100644
--- a/src/macros.jl
+++ b/src/macros.jl
@@ -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
diff --git a/src/parsing.jl b/src/parsing.jl
index 39d6622a..a8211304 100644
--- a/src/parsing.jl
+++ b/src/parsing.jl
@@ -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
@@ -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
"""
diff --git a/test/dataframes.jl b/test/dataframes.jl
index 5393b25e..23072531 100644
--- a/test/dataframes.jl
+++ b/test/dataframes.jl
@@ -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
@@ -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
diff --git a/test/grouping.jl b/test/grouping.jl
index 35ea8df2..0db08b6e 100644
--- a/test/grouping.jl
+++ b/test/grouping.jl
@@ -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
@@ -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