Skip to content

Commit 6548ed9

Browse files
Format files using DocumentFormat
1 parent aeb6ab3 commit 6548ed9

27 files changed

+721
-721
lines changed

benchmark/Rdatatable.jl

+179-179
Large diffs are not rendered by default.

benchmark/benchmarks.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ using DataTables
1313
@bench "one column" @from i in $dt begin
1414
@group i.A by i.B into g
1515
@select {m = mean(g)}
16-
@collect
16+
@collect
1717
end
18-
18+
1919
@bench "two columns" @from i in $dt begin
2020
@group {i.A, i.B} by i.B into g
2121
@select {m = mean(g.A)}
22-
@collect
22+
@collect
2323
end
2424

2525
@bench "three columns" @from i in $dt begin
2626
@group {i.A, i.B, i.C} by i.B into g
2727
@select {m = mean(g.A)}
28-
@collect
28+
@collect
2929
end
3030
end
3131

@@ -68,7 +68,7 @@ end
6868
@bench "IntegerTest" @from i in $dt begin
6969
@group i.A by i.A into g
7070
@select g
71-
@collect
71+
@collect
7272
end
7373
end
7474

docs/make.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ using Documenter, Query, DataFrames
33
makedocs(
44
modules = [Query],
55
sitename = "Query.jl",
6-
analytics="UA-132838790-1",
6+
analytics = "UA-132838790-1",
77
pages = [
88
"Introduction" => "index.md",
99
"Getting Started" => "gettingstarted.md",

example/01-DataFrame.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,5,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,5,2])
55

66
x = @from i in df begin
7-
@where i.age>30. && i.children > 2
8-
@select {Name=lowercase(i.name)}
7+
@where i.age > 30. && i.children > 2
8+
@select {Name = lowercase(i.name)}
99
@collect DataFrame
1010
end
1111

example/02-Dict.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
using Query
22
using DataFrames
33

4-
source = Dict("John"=>34., "Sally"=>56.)
4+
source = Dict("John" => 34., "Sally" => 56.)
55

66
result = @from i in source begin
7-
@where i.second>36.
8-
@select {Name=lowercase(i.first)}
9-
@collect DataFrame
7+
@where i.second > 36.
8+
@select {Name = lowercase(i.first)}
9+
@collect DataFrame
1010
end
1111

1212
println(result)
1313

1414
result = @from i in source begin
15-
@where i.second>36.
16-
@select {Name=lowercase(i.first)}
17-
@collect
15+
@where i.second > 36.
16+
@select {Name = lowercase(i.first)}
17+
@collect
1818
end
1919

2020
println(result)

example/03-Array.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ push!(source, Person("John", ["Sally", "Miles", "Frank"]))
1111
push!(source, Person("Sally", ["Don", "Martin"]))
1212

1313
result = @from i in source begin
14-
@where length(i.Friends) > 2
15-
@select {i.Name, Friendcount=length(i.Friends)}
16-
@collect
14+
@where length(i.Friends) > 2
15+
@select {i.Name, Friendcount = length(i.Friends)}
16+
@collect
1717
end
1818

1919
println(result)
2020

2121
result = @from i in source begin
22-
@where length(i.Friends) > 2
23-
@select {i.Name, Friendcount=length(i.Friends)}
24-
@collect DataFrame
22+
@where length(i.Friends) > 2
23+
@select {i.Name, Friendcount = length(i.Friends)}
24+
@collect DataFrame
2525
end
2626

2727
println(result)

example/05-NA.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", missing, "Kirk"], age=[23., 42., 59.], children=[3,5,2])
4+
df = DataFrame(name = ["John", missing, "Kirk"], age = [23., 42., 59.], children = [3,5,2])
55

66
x = @from i in df begin
7-
@where i.age>30 && i.children >2
8-
@select {Name=lowercase(i.name)}
7+
@where i.age > 30 && i.children > 2
8+
@select {Name = lowercase(i.name)}
99
@collect DataFrame
1010
end
1111

example/08-join.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using DataFrames, Query
22

3-
df1 = DataFrame(a=[1,2,3], b=[1.,2.,3.])
4-
df2 = DataFrame(c=[2.,4.,2.], d=["John", "Jim","Sally"])
3+
df1 = DataFrame(a = [1,2,3], b = [1.,2.,3.])
4+
df2 = DataFrame(c = [2.,4.,2.], d = ["John", "Jim","Sally"])
55

66
x = @from i in df1 begin
7-
@join j in df2 on i.a equals convert(Int,j.c)
8-
@select {i.a,i.b,j.c,j.d,e="Name: $(j.d)"}
7+
@join j in df2 on i.a equals convert(Int, j.c)
8+
@select {i.a,i.b,j.c,j.d,e = "Name: $(j.d)"}
99
@collect DataFrame
1010
end
1111

example/09-let.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,5,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,5,2])
55

66
x = @from i in df begin
77
@let count = length(i.name)
88
@let kids_per_year = i.children / i.age
99
@where count > 4
10-
@select {Name=i.name, Count=count, KidsPerYear=kids_per_year}
10+
@select {Name = i.name, Count = count, KidsPerYear = kids_per_year}
1111
@collect DataFrame
1212
end
1313

example/10-orderby.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,5,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,5,2])
55

66
x = @from i in df begin
77
@orderby i.age
8-
@select {Name=lowercase(i.name)}
8+
@select {Name = lowercase(i.name)}
99
@collect DataFrame
1010
end
1111

1212
println(x)
1313

1414
x = @from i in df begin
1515
@orderby descending(i.age)
16-
@select {Name=lowercase(i.name)}
16+
@select {Name = lowercase(i.name)}
1717
@collect DataFrame
1818
end
1919

2020
println(x)
2121

2222
x = @from i in df begin
2323
@orderby ascending(i.age)
24-
@select {Name=lowercase(i.name)}
24+
@select {Name = lowercase(i.name)}
2525
@collect DataFrame
2626
end
2727

example/13-selectmany.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using DataFrames, Query
22

3-
df1 = DataFrame(a=[1,2,3], b=[1.,2.,3.])
4-
df2 = DataFrame(c=[2.,4.,2.], d=["John", "Jim","Sally"])
3+
df1 = DataFrame(a = [1,2,3], b = [1.,2.,3.])
4+
df2 = DataFrame(c = [2.,4.,2.], d = ["John", "Jim","Sally"])
55

66
q = @from i in df1 begin
77
@from j in df2
@@ -11,11 +11,11 @@ end
1111

1212
println(q)
1313

14-
source_dict = Dict(:a=>[1,2,3], :b=>[4,5])
14+
source_dict = Dict(:a => [1,2,3], :b => [4,5])
1515

1616
q = @from i in source_dict begin
1717
@from j in i.second
18-
@select {Key=i.first,Value=j}
18+
@select {Key = i.first,Value = j}
1919
@collect DataFrame
2020
end
2121

example/14-groupby.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,2,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,2,2])
55

66
x = @from i in df begin
77
@group i.name by i.children

example/15-groupinto.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,2,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,2,2])
55

66
x = @from i in df begin
77
@group i by i.children into g
8-
@select {Key=key(g),Count=length(g)}
8+
@select {Key = key(g),Count = length(g)}
99
@collect DataFrame
1010
end
1111

example/16-selectinto.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,2,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,2,2])
55

66
x = @from i in df begin
77
@select i into j

example/17-groupjoin.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using DataFrames, Query
22

3-
df1 = DataFrame(a=[1,2,3], b=[1.,2.,3.])
4-
df2 = DataFrame(c=[2.,4.,2.], d=["John", "Jim","Sally"])
3+
df1 = DataFrame(a = [1,2,3], b = [1.,2.,3.])
4+
df2 = DataFrame(c = [2.,4.,2.], d = ["John", "Jim","Sally"])
55

66
x = @from i in df1 begin
7-
@join j in df2 on i.a equals convert(Int,j.c) into k
8-
@where i.a>1
9-
@select {t1=i,t2=k}
7+
@join j in df2 on i.a equals convert(Int, j.c) into k
8+
@where i.a > 1
9+
@select {t1 = i,t2 = k}
1010
@collect DataFrame
1111
end
1212

example/18-orderby-nested.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(a=[2,1,1,2,1,3],b=[2,2,1,1,3,2])
4+
df = DataFrame(a = [2,1,1,2,1,3], b = [2,2,1,1,3,2])
55

66
x = @from i in df begin
77
@orderby descending(i.a), i.b

example/23-dict-sink.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using Query
22
using DataFrames
33

4-
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,5,2])
4+
df = DataFrame(name = ["John", "Sally", "Kirk"], age = [23., 42., 59.], children = [3,5,2])
55

66
q = @from i in df begin
7-
@select i.name=>i.children
7+
@select i.name => i.children
88
@collect Dict
99
end
1010

example/25-ab-syntax.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ using Query
22
using DataFrames
33
using Statistics
44

5-
df = DataFrame(name=repeat(["John", "Sally", "Kirk"],inner=[1],outer=[2]),
6-
age=vcat([10., 20., 30.],[10., 20., 30.].+3),
7-
children=repeat([3,2,2],inner=[1],outer=[2]),state=[:a,:a,:a,:b,:b,:b])
5+
df = DataFrame(name = repeat(["John", "Sally", "Kirk"], inner = [1], outer = [2]),
6+
age = vcat([10., 20., 30.], [10., 20., 30.] .+ 3),
7+
children = repeat([3,2,2], inner = [1], outer = [2]),state = [:a,:a,:a,:b,:b,:b])
88

99
x = @from i in df begin
1010
@group i by i.state into g
11-
@select {group=key(g),mage=mean(g.age), oldest=maximum(g.age), youngest=minimum(g.age)}
11+
@select {group = key(g),mage = mean(g.age), oldest = maximum(g.age), youngest = minimum(g.age)}
1212
@collect DataFrame
1313
end
1414

example/prep_data.jl

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using DataFrames
22

3-
n=10_000_000
3+
n = 10_000_000
44

55
# Right now things only work columns of type Array, so
66
# we need this slighlty cumbersome DataFrame construction
77
# to prevent DataArray or NullableArray creation
88
# We are also skipping all Strings because of #14955 (I think)
9-
data_friends = fill(4,n)
10-
data_age = fill(38.2,n)
11-
data_children = fill(2,n)
9+
data_friends = fill(4, n)
10+
data_age = fill(38.2, n)
11+
data_children = fill(2, n)
1212

1313
columns = []
1414
push!(columns, data_friends)

src/Query.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ include("standalone_query_macros.jl")
2020
include("table_query_macros.jl")
2121

2222
macro from(range::Expr, body::Expr)
23-
if range.head!=:call || (range.args[1]!=:in && range.args[1]!=in)
23+
if range.head != :call || (range.args[1] != :in && range.args[1] != in)
2424
error()
2525
end
2626

27-
if body.head!=:block
27+
if body.head != :block
2828
error()
2929
end
3030

31-
body.args = filter(i->!isa(i, LineNumberNode),body.args)
31+
body.args = filter(i->!isa(i, LineNumberNode), body.args)
3232

33-
insert!(body.args,1,:( @from $(range.args[2]) in $(range.args[3]) ))
33+
insert!(body.args, 1, :( @from $(range.args[2]) in $(range.args[3]) ))
3434

3535
translate_query(body)
3636

3737
return body.args[1]
3838
end
3939

4040
macro query(range::Symbol, body::Expr)
41-
if body.head!=:block
41+
if body.head != :block
4242
error()
4343
end
4444

4545
f_arg = gensym()
46-
x = x = esc(:($f_arg -> $Query.@from $in($range, $f_arg) $body))
46+
x = x = esc(:($f_arg->$Query.@from $in($range, $f_arg) $body))
4747
return x
4848
end
4949

src/query_utils.jl

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
ismacro(ex, name::Symbol, nargs::Integer=-1) =
2-
isa(ex, Expr) && ex.head==:macrocall && ex.args[1]==name &&
3-
(nargs == -1 || length(ex.args) == nargs+1)
4-
ismacro(ex, name::String, nargs::Integer=-1) = ismacro(ex, Symbol(name), nargs)
1+
ismacro(ex, name::Symbol, nargs::Integer = -1) =
2+
isa(ex, Expr) && ex.head == :macrocall && ex.args[1] == name &&
3+
(nargs == -1 || length(ex.args) == nargs + 1)
4+
ismacro(ex, name::String, nargs::Integer = -1) = ismacro(ex, Symbol(name), nargs)
55

6-
iscall(ex, name::Symbol, nargs::Integer=-1) =
7-
isa(ex, Expr) && ex.head==:call && ex.args[1]==name &&
8-
(nargs == -1 || length(ex.args) == nargs+1)
6+
iscall(ex, name::Symbol, nargs::Integer = -1) =
7+
isa(ex, Expr) && ex.head == :call && ex.args[1] == name &&
8+
(nargs == -1 || length(ex.args) == nargs + 1)

0 commit comments

Comments
 (0)