Skip to content

Commit 9cbcddf

Browse files
Format files using DocumentFormat
1 parent fde3bcd commit 9cbcddf

21 files changed

+269
-269
lines changed

docs/make.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Documenter, QueryOperators
22

33
makedocs(
4-
modules = [QueryOperators],
5-
sitename = "QueryOperators.jl",
4+
modules=[QueryOperators],
5+
sitename="QueryOperators.jl",
66
analytics="UA-132838790-1",
7-
pages = [
7+
pages=[
88
"Introduction" => "index.md"
99
]
1010
)
1111

1212
deploydocs(
13-
repo = "github.com/queryverse/QueryOperators.jl.git"
13+
repo="github.com/queryverse/QueryOperators.jl.git"
1414
)

src/NamedTupleUtilities.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ julia> QueryOperators.NamedTupleUtilities.select((a=1,b=2,c=3),Val(:a))
88
(a = 1,)
99
```
1010
"""
11-
@generated function select(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
11+
@generated function select(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
1212
names = ((i for i in an if i == bn)...,)
1313
types = Tuple{(fieldtype(a, n) for n in names)...}
1414
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -23,7 +23,7 @@ julia> QueryOperators.NamedTupleUtilities.remove((a=1,b=2,c=3),Val(:c))
2323
(a = 1, b = 2)
2424
```
2525
"""
26-
@generated function remove(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
26+
@generated function remove(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
2727
names = ((i for i in an if i != bn)...,)
2828
types = Tuple{(fieldtype(a, n) for n in names)...}
2929
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -40,7 +40,7 @@ julia> QueryOperators.NamedTupleUtilities.range((a=1,b=2,c=3),Val(:a),Val(:b))
4040
(a = 1, b = 2)
4141
```
4242
"""
43-
@generated function range(a::NamedTuple{an}, ::Val{bn}, ::Val{cn}) where {an, bn, cn}
43+
@generated function range(a::NamedTuple{an}, ::Val{bn}, ::Val{cn}) where {an,bn,cn}
4444
rangeStarted = false
4545
names = Symbol[]
4646
for n in an
@@ -74,7 +74,7 @@ julia> QueryOperators.NamedTupleUtilities.rename((a = 1, b = 2, c = 3),Val(:a),V
7474
ERROR: duplicate field name in NamedTuple: "c" is not unique
7575
```
7676
"""
77-
@generated function rename(a::NamedTuple{an}, ::Val{bn}, ::Val{cn}) where {an, bn, cn}
77+
@generated function rename(a::NamedTuple{an}, ::Val{bn}, ::Val{cn}) where {an,bn,cn}
7878
names = Symbol[]
7979
typesArray = DataType[]
8080
vals = Expr[]
@@ -99,7 +99,7 @@ julia> QueryOperators.NamedTupleUtilities.startswith((abc=1,bcd=2,cde=3),Val(:a)
9999
(abc = 1,)
100100
```
101101
"""
102-
@generated function startswith(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
102+
@generated function startswith(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
103103
names = ((i for i in an if Base.startswith(String(i), String(bn)))...,)
104104
types = Tuple{(fieldtype(a, n) for n in names)...}
105105
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -114,7 +114,7 @@ julia> QueryOperators.NamedTupleUtilities.not_startswith((abc=1,bcd=2,cde=3),Val
114114
(bcd = 2, cde = 3)
115115
```
116116
"""
117-
@generated function not_startswith(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
117+
@generated function not_startswith(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
118118
names = ((i for i in an if !Base.startswith(String(i), String(bn)))...,)
119119
types = Tuple{(fieldtype(a, n) for n in names)...}
120120
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -129,7 +129,7 @@ julia> QueryOperators.NamedTupleUtilities.not_endswith((abc=1,bcd=2,cde=3),Val(:
129129
(abc = 1, cde = 3)
130130
```
131131
"""
132-
@generated function endswith(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
132+
@generated function endswith(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
133133
names = ((i for i in an if Base.endswith(String(i), String(bn)))...,)
134134
types = Tuple{(fieldtype(a, n) for n in names)...}
135135
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -144,7 +144,7 @@ julia> QueryOperators.NamedTupleUtilities.endswith((abc=1,bcd=2,cde=3),Val(:d))
144144
(bcd = 2,)
145145
```
146146
"""
147-
@generated function not_endswith(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
147+
@generated function not_endswith(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
148148
names = ((i for i in an if !Base.endswith(String(i), String(bn)))...,)
149149
types = Tuple{(fieldtype(a, n) for n in names)...}
150150
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -159,7 +159,7 @@ julia> QueryOperators.NamedTupleUtilities.occursin((abc=1,bcd=2,cde=3),Val(:d))
159159
(bcd = 2, cde = 3)
160160
```
161161
"""
162-
@generated function occursin(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
162+
@generated function occursin(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
163163
names = ((i for i in an if Base.occursin(String(bn), String(i)))...,)
164164
types = Tuple{(fieldtype(a, n) for n in names)...}
165165
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -174,7 +174,7 @@ julia> QueryOperators.NamedTupleUtilities.not_occursin((abc=1,bcd=2,cde=3),Val(:
174174
(abc = 1,)
175175
```
176176
"""
177-
@generated function not_occursin(a::NamedTuple{an}, ::Val{bn}) where {an, bn}
177+
@generated function not_occursin(a::NamedTuple{an}, ::Val{bn}) where {an,bn}
178178
names = ((i for i in an if !Base.occursin(String(bn), String(i)))...,)
179179
types = Tuple{(fieldtype(a, n) for n in names)...}
180180
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]
@@ -193,7 +193,7 @@ julia> QueryOperators.NamedTupleUtilities.oftype((a = [4,5,6], b = [3.,2.,1.], c
193193
NamedTuple()
194194
```
195195
"""
196-
@generated function oftype(a::NamedTuple{an}, ::Val{b}) where {an, b}
196+
@generated function oftype(a::NamedTuple{an}, ::Val{b}) where {an,b}
197197
names = ((i for i in an if fieldtype(a, i) <: b)...,)
198198
types = Tuple{(fieldtype(a, n) for n in names)...}
199199
vals = Expr[:(getfield(a, $(QuoteNode(n)))) for n in names]

src/enumerable/enumerable.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ abstract type Enumerable end
33
Base.IteratorSize(::Type{T}) where {T <: Enumerable} = Base.SizeUnknown()
44
IteratorInterfaceExtensions.isiterable(x::Enumerable) = true
55

6-
haslength(S) = Base.IteratorSize(S) isa Union{Base.HasLength, Base.HasShape} ? Base.HasLength() : Base.IteratorSize(S)
6+
haslength(S) = Base.IteratorSize(S) isa Union{Base.HasLength,Base.HasShape} ? Base.HasLength() : Base.IteratorSize(S)

src/enumerable/enumerable_count.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ function count(source::Enumerable, filter::Function, filter_expr::Expr)
33
end
44

55
function count(source::Enumerable)
6-
return Base.count(i->true, source)
6+
return Base.count(i -> true, source)
77
end

src/enumerable/enumerable_defaultifempty.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ Base.eltype(iter::Type{EnumerableDefaultIfEmpty{T,S}}) where {T,S} = T
77

88
_default_value_expr(::Type{T}) where {T} = :( DataValues.DataValue{$T}() )
99

10-
_default_value_expr(::Type{T}) where {T<:DataValues.DataValue} = :( $T() )
10+
_default_value_expr(::Type{T}) where {T <: DataValues.DataValue} = :( $T() )
1111

12-
function _default_value_expr(::Type{T}) where {T<:NamedTuple}
13-
return :( NamedTuple{$(fieldnames(T))}( ($( (_default_value_expr(fieldtype(T,i)) for i in 1:length(fieldnames(T)))... ),)) )
12+
function _default_value_expr(::Type{T}) where {T <: NamedTuple}
13+
return :( NamedTuple{$(fieldnames(T))}(($( (_default_value_expr(fieldtype(T, i)) for i in 1:length(fieldnames(T)))... ),)) )
1414
end
1515

1616
@generated function default_if_empty(source::S) where {S}
@@ -32,7 +32,7 @@ end
3232

3333
function default_if_empty(source::S, default_value::TD) where {S,TD}
3434
T = eltype(source)
35-
if T!=TD
35+
if T != TD
3636
error("The default value must have the same type as the elements from the source.")
3737
end
3838
return EnumerableDefaultIfEmpty{T,S}(source, default_value)
@@ -41,18 +41,18 @@ end
4141
function Base.iterate(iter::EnumerableDefaultIfEmpty{T,S}) where {T,S}
4242
s = iterate(iter.source)
4343

44-
if s===nothing
44+
if s === nothing
4545
return iter.default_value, nothing
4646
else
47-
return convert(T,s[1]), s[2]
47+
return convert(T, s[1]), s[2]
4848
end
4949
end
5050

5151
function Base.iterate(iter::EnumerableDefaultIfEmpty{T,S}, state) where {T,S}
52-
state===nothing && return nothing
52+
state === nothing && return nothing
5353

5454
s = iterate(iter.source, state)
55-
if s===nothing
55+
if s === nothing
5656
return nothing
5757
else
5858
return convert(T, s[1]), s[2]

src/enumerable/enumerable_drop.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ Base.IteratorSize(::Type{EnumerableDrop{T,S}}) where {T,S} = (Base.IteratorSize(
1313

1414
Base.eltype(::Type{EnumerableDrop{T,S}}) where {T,S} = T
1515

16-
Base.length(iter::EnumerableDrop{T,S}) where {T,S} = max(length(iter.source)-iter.n,0)
16+
Base.length(iter::EnumerableDrop{T,S}) where {T,S} = max(length(iter.source) - iter.n, 0)
1717

1818
function Base.iterate(iter::EnumerableDrop{T,S}) where {T,S}
1919
ret = iterate(iter.source)
2020
for i in 1:iter.n
21-
if ret===nothing
21+
if ret === nothing
2222
return nothing
2323
else
2424
ret = iterate(iter.source, ret[2])

src/enumerable/enumerable_filter.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# T is the type of the elements produced by this iterator
2-
struct EnumerableFilter{T,S,Q<:Function} <: Enumerable
2+
struct EnumerableFilter{T,S,Q <: Function} <: Enumerable
33
source::S
44
filter::Q
55
end
@@ -16,7 +16,7 @@ end
1616
function Base.iterate(iter::EnumerableFilter{T,S,Q}, state...) where {T,S,Q}
1717
ret = iterate(iter.source, state...)
1818

19-
while ret!==nothing
19+
while ret !== nothing
2020
if iter.filter(ret[1])
2121
return ret
2222
end

src/enumerable/enumerable_gather.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct Not{T}
1111
val::T
1212
end
1313

14-
function gather(source::Enumerable, args...; key::Symbol = :key, value::Symbol = :value)
14+
function gather(source::Enumerable, args...; key::Symbol=:key, value::Symbol=:value)
1515
fields = fieldnames(eltype(source))
1616
if length(args) > 0
1717
indexFields_vector = Vector{Symbol}(undef, 0)
@@ -39,24 +39,24 @@ function gather(source::Enumerable, args...; key::Symbol = :key, value::Symbol =
3939
valueTypes = (fieldtype(eltype(source), indexField) for indexField in indexFields)
4040
valueType = reduce(promote_type, valueTypes)
4141

42-
T = NamedTuple{(savedFields..., key, value), Tuple{savedFieldsType..., Symbol, valueType}}
43-
return EnumerableGather{T, typeof(source), typeof(fields), typeof(indexFields), typeof(savedFields)}(source,
42+
T = NamedTuple{(savedFields..., key, value),Tuple{savedFieldsType...,Symbol,valueType}}
43+
return EnumerableGather{T,typeof(source),typeof(fields),typeof(indexFields),typeof(savedFields)}(source,
4444
fields, indexFields, savedFields, key, value)
4545
end
4646

47-
function Base.iterate(iter::EnumerableGather{T, S, F, I, A}) where {T, S, F, I, A}
47+
function Base.iterate(iter::EnumerableGather{T,S,F,I,A}) where {T,S,F,I,A}
4848
source_iterate = iterate(iter.source)
4949
if source_iterate == nothing || length(iter.indexFields) == 0
5050
return nothing
5151
end
5252
key = iter.indexFields[1]
5353
current_source_row = source_iterate[1]
5454
value = current_source_row[key]
55-
return (T((Base.map(n->current_source_row[n], iter.savedFields)..., key, value)),
56-
(current_source_row=current_source_row, source_state=source_iterate[2], current_index_field_index=1))
55+
return (T((Base.map(n -> current_source_row[n], iter.savedFields)..., key, value)),
56+
(current_source_row = current_source_row, source_state = source_iterate[2], current_index_field_index = 1))
5757
end
5858

59-
function Base.iterate(iter::EnumerableGather{T, S, F, I, A}, state) where {T, S, F, I, A}
59+
function Base.iterate(iter::EnumerableGather{T,S,F,I,A}, state) where {T,S,F,I,A}
6060
current_index_field_index = state.current_index_field_index + 1
6161
if current_index_field_index > length(iter.indexFields)
6262
source_iterate = iterate(iter.source, state.source_state)
@@ -72,10 +72,10 @@ function Base.iterate(iter::EnumerableGather{T, S, F, I, A}, state) where {T, S,
7272
end
7373
key = iter.indexFields[current_index_field_index]
7474
value = current_source_row[key]
75-
return (T((Base.map(n->current_source_row[n], iter.savedFields)..., key, value)),
76-
(current_source_row=current_source_row, source_state=source_state, current_index_field_index=current_index_field_index))
75+
return (T((Base.map(n -> current_source_row[n], iter.savedFields)..., key, value)),
76+
(current_source_row = current_source_row, source_state = source_state, current_index_field_index = current_index_field_index))
7777
end
7878

79-
function Base.eltype(iter::EnumerableGather{T, S, F, I, A}) where {T, S, F, I, A}
79+
function Base.eltype(iter::EnumerableGather{T,S,F,I,A}) where {T,S,F,I,A}
8080
return T
8181
end

src/enumerable/enumerable_groupby.jl

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
struct EnumerableGroupBySimple{T,TKey,TS,SO,ES<:Function} <: Enumerable
1+
struct EnumerableGroupBySimple{T,TKey,TS,SO,ES <: Function} <: Enumerable
22
source::SO
33
elementSelector::ES
44
end
@@ -19,14 +19,14 @@ function Base.size(gcav::GroupColumnArrayView)
1919
end
2020

2121
function Base.getindex(gcav::GroupColumnArrayView{T,G,INDEX}, i::Int) where {T,G,INDEX}
22-
return getproperty(gcav.grouping[i],INDEX)
22+
return getproperty(gcav.grouping[i], INDEX)
2323
end
2424

2525
Base.IndexStyle(::Type{GroupColumnArrayView}) = IndexLinear()
2626

2727
function Base.getproperty(g::Grouping{TKey,T}, name::Symbol) where {TKey,T}
2828

29-
return GroupColumnArrayView{fieldtype(T,name),Grouping{TKey,T},name}(g)
29+
return GroupColumnArrayView{fieldtype(T, name),Grouping{TKey,T},name}(g)
3030
end
3131

3232
Base.size(A::Grouping{TKey,T}) where {TKey,T} = size(getfield(A, :elements))
@@ -45,42 +45,42 @@ function groupby(source::Enumerable, f_elementSelector::Function, elementSelecto
4545

4646
ES = typeof(f_elementSelector)
4747

48-
return EnumerableGroupBySimple{T,TKey,TS,SO,ES}(source,f_elementSelector)
48+
return EnumerableGroupBySimple{T,TKey,TS,SO,ES}(source, f_elementSelector)
4949
end
5050

5151
function Base.iterate(iter::EnumerableGroupBySimple{T,TKey,TS,SO,ES}) where {T,TKey,TS,SO,ES}
5252
result = OrderedDict{TKey,T}()
5353
for i in iter.source
5454
key = iter.elementSelector(i)
5555
if !haskey(result, key)
56-
result[key] = T(key,Array{TS}(undef, 0))
56+
result[key] = T(key, Array{TS}(undef, 0))
5757
end
58-
push!(getfield(result[key], :elements),i)
58+
push!(getfield(result[key], :elements), i)
5959
end
6060

6161
groups = collect(values(result))
62-
if length(groups)==0
62+
if length(groups) == 0
6363
return nothing
6464
else
6565
return groups[1], (groups, 2)
6666
end
6767
end
6868

6969
function Base.iterate(iter::EnumerableGroupBySimple{T,TKey,TS,SO,ES}, state) where {T,TKey,TS,SO,ES}
70-
if state[2]>length(state[1])
70+
if state[2] > length(state[1])
7171
return nothing
7272
else
73-
return state[1][state[2]], (state[1], state[2]+1)
73+
return state[1][state[2]], (state[1], state[2] + 1)
7474
end
7575
end
7676

77-
struct EnumerableGroupBy{T,TKey,TR,SO,ES<:Function,RS<:Function} <: Enumerable
77+
struct EnumerableGroupBy{T,TKey,TR,SO,ES <: Function,RS <: Function} <: Enumerable
7878
source::SO
7979
elementSelector::ES
8080
resultSelector::RS
8181
end
8282

83-
Base.eltype(::Type{EnumerableGroupBy{T,TKey,TR,SO,ES, RS}}) where {T,TKey,TR,SO,ES,RS} = T
83+
Base.eltype(::Type{EnumerableGroupBy{T,TKey,TR,SO,ES,RS}}) where {T,TKey,TR,SO,ES,RS} = T
8484

8585
function groupby(source::Enumerable, f_elementSelector::Function, elementSelector::Expr, f_resultSelector::Function, resultSelector::Expr)
8686
TS = eltype(source)
@@ -95,31 +95,31 @@ function groupby(source::Enumerable, f_elementSelector::Function, elementSelecto
9595
ES = typeof(f_elementSelector)
9696
RS = typeof(f_resultSelector)
9797

98-
return EnumerableGroupBy{T,TKey,TR,SO,ES,RS}(source,f_elementSelector,f_resultSelector)
98+
return EnumerableGroupBy{T,TKey,TR,SO,ES,RS}(source, f_elementSelector, f_resultSelector)
9999
end
100100

101101
function Base.iterate(iter::EnumerableGroupBy{T,TKey,TR,SO,ES}) where {T,TKey,TR,SO,ES}
102102
result = OrderedDict{TKey,T}()
103103
for i in iter.source
104104
key = iter.elementSelector(i)
105105
if !haskey(result, key)
106-
result[key] = T(key,Array{TR}(undef,0))
106+
result[key] = T(key, Array{TR}(undef, 0))
107107
end
108-
push!(getfield(result[key], :elements),iter.resultSelector(i))
108+
push!(getfield(result[key], :elements), iter.resultSelector(i))
109109
end
110110

111111
groups = collect(values(result))
112-
if length(groups)==0
112+
if length(groups) == 0
113113
return nothing
114114
else
115115
return groups[1], (groups, 2)
116116
end
117117
end
118118

119119
function Base.iterate(iter::EnumerableGroupBy{T,TKey,TR,SO,ES}, state) where {T,TKey,TR,SO,ES}
120-
if state[2]>length(state[1])
120+
if state[2] > length(state[1])
121121
return nothing
122122
else
123-
return state[1][state[2]], (state[1], state[2]+1)
123+
return state[1][state[2]], (state[1], state[2] + 1)
124124
end
125125
end

0 commit comments

Comments
 (0)