Skip to content

Commit d4a3520

Browse files
authored
Format files using DocumentFormat
1 parent e36d8af commit d4a3520

24 files changed

+384
-384
lines changed

benchmark/Rdatatable.jl

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

docs/make.jl

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

33
makedocs(
4-
modules = [Query],
5-
sitename = "Query.jl",
4+
modules=[Query],
5+
sitename="Query.jl",
66
analytics="UA-132838790-1",
7-
pages = [
7+
pages=[
88
"Introduction" => "index.md",
99
"Getting Started" => "gettingstarted.md",
1010
"Standalone Query Commands" => "standalonequerycommands.md",
@@ -16,5 +16,5 @@ makedocs(
1616
)
1717

1818
deploydocs(
19-
repo = "github.com/queryverse/Query.jl.git"
19+
repo="github.com/queryverse/Query.jl.git"
2020
)

example/01-DataFrame.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using DataFrames
44
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

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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)}
7+
@where i.second > 36.
8+
@select {Name = lowercase(i.first)}
99
@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)}
15+
@where i.second > 36.
16+
@select {Name = lowercase(i.first)}
1717
@collect
1818
end
1919

example/03-Array.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ push!(source, Person("Sally", ["Don", "Martin"]))
1212

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

1919
println(result)
2020

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

example/05-NA.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ using DataFrames
44
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ df1 = DataFrame(a=[1,2,3], b=[1.,2.,3.])
44
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -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/15-groupinto.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,
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/17-groupjoin.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ df1 = DataFrame(a=[1,2,3], b=[1.,2.,3.])
44
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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using DataFrames
44
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
@@ -2,7 +2,7 @@ module Query
22

33
import IterableTables
44
using DataValues
5-
using MacroTools: postwalk
5+
using MacroTools:postwalk
66
using QueryOperators
77

88
export @from, @query, @count, Grouping, key
@@ -23,25 +23,25 @@ include("standalone_query_macros.jl")
2323
include("table_query_macros.jl")
2424

2525
macro from(range::Expr, body::Expr)
26-
if range.head!=:call || (range.args[1]!=:in && range.args[1]!=in)
26+
if range.head != :call || (range.args[1] != :in && range.args[1] != in)
2727
error()
2828
end
2929

30-
if body.head!=:block
30+
if body.head != :block
3131
error()
3232
end
3333

34-
body.args = filter(i->!isa(i, LineNumberNode),body.args)
34+
body.args = filter(i -> !isa(i, LineNumberNode), body.args)
3535

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

3838
translate_query(body)
3939

4040
return body.args[1]
4141
end
4242

4343
macro query(range::Symbol, body::Expr)
44-
if body.head!=:block
44+
if body.head != :block
4545
error()
4646
end
4747

src/query_utils.jl

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

66
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)
7+
isa(ex, Expr) && ex.head == :call && ex.args[1] == name &&
8+
(nargs == -1 || length(ex.args) == nargs + 1)

src/standalone_query_macros.jl

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ end
3535

3636
macro groupby(elementSelector)
3737
elementSelector_as_anonym_func = helper_replace_anon_func_syntax(elementSelector)
38-
resultSelector_as_anonym_func = :(i->i)
38+
resultSelector_as_anonym_func = :(i -> i)
3939

4040
q_elementSelector = Expr(:quote, elementSelector_as_anonym_func)
4141
q_resultSelector = Expr(:quote, resultSelector_as_anonym_func)
@@ -178,11 +178,11 @@ end
178178
macro map(f)
179179
f_as_anonym_func = helper_replace_anon_func_syntax(f)
180180
q = Expr(:quote, f_as_anonym_func)
181-
return :( i-> QueryOperators.map(QueryOperators.query(i), $(esc(f_as_anonym_func)), $(esc(q))) ) |>
181+
return :( i -> QueryOperators.map(QueryOperators.query(i), $(esc(f_as_anonym_func)), $(esc(q))) ) |>
182182
helper_namedtuples_replacement
183183
end
184184

185-
macro mapmany(source, collectionSelector,resultSelector)
185+
macro mapmany(source, collectionSelector, resultSelector)
186186
collectionSelector_as_anonym_func = helper_replace_anon_func_syntax(collectionSelector)
187187
resultSelector_as_anonym_func = helper_replace_anon_func_syntax(resultSelector)
188188

@@ -195,14 +195,14 @@ macro mapmany(source, collectionSelector,resultSelector)
195195
helper_namedtuples_replacement
196196
end
197197

198-
macro mapmany(collectionSelector,resultSelector)
198+
macro mapmany(collectionSelector, resultSelector)
199199
collectionSelector_as_anonym_func = helper_replace_anon_func_syntax(collectionSelector)
200200
resultSelector_as_anonym_func = helper_replace_anon_func_syntax(resultSelector)
201201

202202
collectionSelector_q = Expr(:quote, collectionSelector_as_anonym_func)
203203
resultSelector_q = Expr(:quote, resultSelector_as_anonym_func)
204204

205-
return :( i-> QueryOperators.mapmany(QueryOperators.query(i),
205+
return :( i -> QueryOperators.mapmany(QueryOperators.query(i),
206206
$(esc(collectionSelector_as_anonym_func)), $(esc(collectionSelector_q)),
207207
$(esc(resultSelector_as_anonym_func)), $(esc(resultSelector_q)))) |>
208208
helper_namedtuples_replacement
@@ -239,7 +239,7 @@ macro drop(n)
239239
end
240240

241241
macro unique()
242-
return :( i -> QueryOperators.unique(QueryOperators.query(i), q->q, :(q->q))) |>
242+
return :( i -> QueryOperators.unique(QueryOperators.query(i), q -> q, :(q -> q))) |>
243243
helper_namedtuples_replacement
244244
end
245245

src/table_query_macros.jl

+12-12
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ macro select(args...)
4141
elseif typeof(arg) == QuoteNode
4242
# select by name
4343
prev = :( merge($prev, QueryOperators.NamedTupleUtilities.select(_, Val($(arg)))) )
44-
elseif arg isa Expr && arg.head==:call && length(arg.args)==3 && arg.args[1]==Symbol(":")
44+
elseif arg isa Expr && arg.head == :call && length(arg.args) == 3 && arg.args[1] == Symbol(":")
4545
arg = string(arg)
4646
# select by range, with multiple syntaxes supported
4747
m_range = match(r"^:([^,:]+) *: *:([^,:]+)", arg)
@@ -184,7 +184,7 @@ macro mutate(args...)
184184
prev = :( Base.merge($prev, ($(arg.args[1]) = $(arg.args[2]),)) )
185185
end
186186

187-
return :( Query.@map( $prev ) ) |> esc
187+
return :( Query.@map( $prev ) ) |> esc
188188
end
189189

190190
our_get(x) = x
@@ -198,36 +198,36 @@ macro disallowna()
198198
end
199199

200200
macro disallowna(columns...)
201-
return :( Query.@mutate( $( ( :( $(columns[i].value) = our_get(_.$(columns[i].value)) ) for i=1:length(columns) )... ) ) )
201+
return :( Query.@mutate( $( ( :( $(columns[i].value) = our_get(_.$(columns[i].value)) ) for i = 1:length(columns) )... ) ) )
202202
end
203203

204204
# The following is a backwards compat fix
205205
macro dissallowna()
206206
return :( Query.@map(map(our_get, _)) )
207207
end
208208
macro dissallowna(columns...)
209-
return :( Query.@mutate( $( ( :( $(columns[i].value) = our_get(_.$(columns[i].value)) ) for i=1:length(columns) )... ) ) )
209+
return :( Query.@mutate( $( ( :( $(columns[i].value) = our_get(_.$(columns[i].value)) ) for i = 1:length(columns) )... ) ) )
210210
end
211211

212212
macro dropna()
213-
return :( i-> i |> Query.@filter(!any(isna, _)) |> Query.@disallowna() )
213+
return :( i -> i |> Query.@filter(!any(isna, _)) |> Query.@disallowna() )
214214
end
215215

216216
macro dropna(columns...)
217-
return :( i-> i |> Query.@filter(!any(($((:(isna(_.$(columns[i].value))) for i in 1:length(columns) )...),))) |> Query.@disallowna($(columns...)) )
217+
return :( i -> i |> Query.@filter(!any(($((:(isna(_.$(columns[i].value))) for i in 1:length(columns) )...),))) |> Query.@disallowna($(columns...)) )
218218
end
219219

220220
macro replacena(arg, args...)
221-
if length(args)==0 && !(arg isa Expr && arg.head==:call && length(arg.args)==3 && arg.args[1]==:(=>))
222-
return :( Query.@map(map(i->our_get(i, $arg), _)) )
221+
if length(args) == 0 && !(arg isa Expr && arg.head == :call && length(arg.args) == 3 && arg.args[1] == :(=>))
222+
return :( Query.@map(map(i -> our_get(i, $arg), _)) )
223223
else
224224
args = [arg; args...]
225225

226-
all(i isa Expr && i.head==:call && length(i.args)==3 && i.args[1]==:(=>) for i in args) || error("Invalid syntax.")
226+
all(i isa Expr && i.head == :call && length(i.args) == 3 && i.args[1] == :(=>) for i in args) || error("Invalid syntax.")
227227

228-
columns = map(i->i.args[2].value, args)
229-
replacement_values = map(i->i.args[3], args)
228+
columns = map(i -> i.args[2].value, args)
229+
replacement_values = map(i -> i.args[3], args)
230230

231-
return :( Query.@mutate( $( ( :( $(columns[i]) = our_get(_.$(columns[i]), $(replacement_values[i])) ) for i=1:length(columns) )... ) ) )
231+
return :( Query.@mutate( $( ( :( $(columns[i]) = our_get(_.$(columns[i]), $(replacement_values[i])) ) for i = 1:length(columns) )... ) ) )
232232
end
233233
end

0 commit comments

Comments
 (0)