Skip to content

Commit

Permalink
exporting with
Browse files Browse the repository at this point in the history
  • Loading branch information
pdeffebach committed Nov 1, 2023
1 parent a0bdcca commit aee6b50
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions test/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,32 +203,32 @@ end

x = [2, 1, 0]

@test @with(df, :A .+ 1) == df.A .+ 1
@test @with(df, :A .+ :B) == df.A .+ df.B
@test @with(df, :A .+ x) == df.A .+ x
@test DataFramesMeta.@with(df, :A .+ 1) == df.A .+ 1
@test DataFramesMeta.@with(df, :A .+ :B) == df.A .+ df.B
@test DataFramesMeta.@with(df, :A .+ x) == df.A .+ x

x = @with df begin
x = DataFramesMeta.@with df begin
res = 0.0
for i in 1:length(:A)
res += :A[i] * :B[i]
end
res
end
idx = :A
@test @with(df, $idx .+ :B) == df.A .+ df.B
@test DataFramesMeta.@with(df, $idx .+ :B) == df.A .+ df.B
idx2 = :B
@test @with(df, $idx .+ $idx2) == df.A .+ df.B
@test @with(df, $:A .+ $"B") == df.A .+ df.B
@test DataFramesMeta.@with(df, $idx .+ $idx2) == df.A .+ df.B
@test DataFramesMeta.@with(df, $:A .+ $"B") == df.A .+ df.B

@test_throws ArgumentError @with(df, :A + $2)
@test_throws ArgumentError DataFramesMeta.@with(df, :A + $2)

@test x == sum(df.A .* df.B)
@test @with(df, df[:A .> 1, ^([:B, :A])]) == df[df.A .> 1, [:B, :A]]
@test @with(df, DataFrame(a = :A * 2, b = :A .+ :B)) == DataFrame(a = df.A * 2, b = df.A .+ df.B)
@test DataFramesMeta.@with(df, df[:A .> 1, ^([:B, :A])]) == df[df.A .> 1, [:B, :A]]
@test DataFramesMeta.@with(df, DataFrame(a = :A * 2, b = :A .+ :B)) == DataFrame(a = df.A * 2, b = df.A .+ df.B)

@test @with(df, :A) === df.A
@test @with(df, $:A) === df.A
@test @with(df, $"A") === df.A
@test DataFramesMeta.@with(df, :A) === df.A
@test DataFramesMeta.@with(df, $:A) === df.A
@test DataFramesMeta.@with(df, $"A") === df.A
end


Expand Down

0 comments on commit aee6b50

Please sign in to comment.