Skip to content

Commit d568d25

Browse files
authored
Merge pull request #81 from queryverse/create-pull-request/patch
[AUTO] Format files using DocumentFormat
2 parents ace4e96 + d67c6da commit d568d25

File tree

13 files changed

+90
-90
lines changed

13 files changed

+90
-90
lines changed

benchmark/array/reduce.jl

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,22 @@ function profile_reduce_methods()
8787
prod,
8888
minimum,
8989
maximum,)
90-
(method)(Y, skipnull = true)
90+
(method)(Y, skipnull=true)
9191
println("Method: $method(A) (~half missing entries, skip=true)")
9292
print(" for NullableArray{Float64}: ")
93-
@time((method)(Y, skipnull = true))
94-
(method)(E, skipna = true)
93+
@time((method)(Y, skipnull=true))
94+
(method)(E, skipna=true)
9595
print(" for DataArray{Float64}: ")
96-
@time((method)(E, skipna = true))
96+
@time((method)(E, skipna=true))
9797
println()
9898

99-
(method)(f, Y, skipnull = true)
99+
(method)(f, Y, skipnull=true)
100100
println("Method: $method(f, A) (~half missing entries, skip=true)")
101101
print(" for NullableArray{Float64}: ")
102-
@time((method)(f, Y, skipnull = true))
103-
(method)(f, E, skipna = true)
102+
@time((method)(f, Y, skipnull=true))
103+
(method)(f, E, skipna=true)
104104
print(" for DataArray{Float64}: ")
105-
@time((method)(f, E, skipna = true))
105+
@time((method)(f, E, skipna=true))
106106
println()
107107
end
108108

@@ -135,13 +135,13 @@ function profile_reduce_methods()
135135

136136
for method in (sumabs,
137137
sumabs2)
138-
(method)(Y, skipnull = true)
138+
(method)(Y, skipnull=true)
139139
println("Method: $method(A) (~half missing entries, skip=true)")
140140
print(" for NullableArray{Float64}: ")
141-
@time((method)(Y, skipnull = true))
142-
(method)(E, skipna = true)
141+
@time((method)(Y, skipnull=true))
142+
(method)(E, skipna=true)
143143
print(" for DataArray{Float64}: ")
144-
@time((method)(E, skipna = true))
144+
@time((method)(E, skipna=true))
145145
println()
146146
end
147147
end
@@ -170,12 +170,12 @@ function profile_mapreduce(A, X, Y, D, E)
170170
println()
171171

172172
println("Method: mapreduce(f, op, A) (~half missing entries, skip=true)")
173-
mapreduce(f, Base.(:+), Y, skipnull = true)
173+
mapreduce(f, Base.(:+), Y, skipnull=true)
174174
print(" for NullableArray{Float64}: ")
175-
@time(mapreduce(f, Base.(:+), Y, skipnull = true))
176-
mapreduce(f, Base.(:+), E, skipna = true)
175+
@time(mapreduce(f, Base.(:+), Y, skipnull=true))
176+
mapreduce(f, Base.(:+), E, skipna=true)
177177
print(" for DataArray{Float64}: ")
178-
@time(mapreduce(f, Base.(:+), E, skipna = true))
178+
@time(mapreduce(f, Base.(:+), E, skipna=true))
179179
println()
180180
end
181181

@@ -202,12 +202,12 @@ function profile_reduce(A, X, Y, D, E)
202202
println()
203203

204204
println("Method: reduce(f, op, A) (~half missing entries, skip=true)")
205-
reduce(Base.(:+), Y, skipnull = true)
205+
reduce(Base.(:+), Y, skipnull=true)
206206
print(" for NullableArray{Float64}: ")
207-
@time(reduce(Base.(:+), Y, skipnull = true))
208-
reduce(Base.(:+), E, skipna = true)
207+
@time(reduce(Base.(:+), Y, skipnull=true))
208+
reduce(Base.(:+), E, skipna=true)
209209
print(" for DataArray{Float64}: ")
210-
@time(reduce(Base.(:+), E, skipna = true))
210+
@time(reduce(Base.(:+), E, skipna=true))
211211
println()
212212
end
213213

@@ -218,43 +218,43 @@ function profile_skip(skip::Bool)
218218
println("f := identity, op := +")
219219
println("mapreduce(f, op, X; skipnull/skipNA=$skip) (0 missing entries)")
220220

221-
mapreduce(identity, +, X, skipnull = skip)
221+
mapreduce(identity, +, X, skipnull=skip)
222222
print(" for NullableArray{Float64}: ")
223-
@time(mapreduce(identity, +, X, skipnull = skip))
223+
@time(mapreduce(identity, +, X, skipnull=skip))
224224

225-
mapreduce(identity, +, D, skipna = skip)
225+
mapreduce(identity, +, D, skipna=skip)
226226
print(" for DataArray{Float64}: ")
227-
@time(mapreduce(identity, +, D, skipna = skip))
227+
@time(mapreduce(identity, +, D, skipna=skip))
228228

229229
println()
230230
println("reduce(op, X; skipnull/skipNA=$skip) (0 missing entries)")
231-
reduce(+, X, skipnull = skip)
231+
reduce(+, X, skipnull=skip)
232232
print(" for NullableArray{Float64}: ")
233-
@time(reduce(+, X, skipnull = skip))
233+
@time(reduce(+, X, skipnull=skip))
234234

235-
reduce(+, D, skipna = skip)
235+
reduce(+, D, skipna=skip)
236236
print(" for DataArray{Float64}: ")
237-
@time(reduce(+, D, skipna = skip))
237+
@time(reduce(+, D, skipna=skip))
238238

239239
println()
240240
println("mapreduce(f, op, X; skipnull/skipNA=$skip) (~half missing entries)")
241-
mapreduce(identity, +, Y, skipnull = skip)
241+
mapreduce(identity, +, Y, skipnull=skip)
242242
print(" for NullableArray{Float64}: ")
243-
@time(mapreduce(identity, +, Y, skipnull = skip))
243+
@time(mapreduce(identity, +, Y, skipnull=skip))
244244

245-
mapreduce(identity, +, E, skipna = skip)
245+
mapreduce(identity, +, E, skipna=skip)
246246
print(" for DataArray{Float64}: ")
247-
@time(mapreduce(identity, +, E, skipna = skip))
247+
@time(mapreduce(identity, +, E, skipna=skip))
248248

249249
println()
250250
println("reduce(op, X; skipnull/skipNA=$skip) (~half missing entries)")
251-
reduce(+, Y, skipnull = skip)
251+
reduce(+, Y, skipnull=skip)
252252
print(" for NullableArray{Float64}: ")
253-
@time(reduce(+, Y, skipnull = skip))
253+
@time(reduce(+, Y, skipnull=skip))
254254

255-
reduce(+, E, skipna = true)
255+
reduce(+, E, skipna=true)
256256
print(" for DataArray{Float64}: ")
257-
@time(reduce(+, E, skipna = true))
257+
@time(reduce(+, E, skipna=true))
258258
nothing
259259
end
260260

docs/make.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using Documenter, DataValues
22

3-
makedocs(modules = [DataValues],
4-
sitename = "DataValues.jl",
5-
analytics = "UA-132838790-1",
6-
pages = [
3+
makedocs(modules=[DataValues],
4+
sitename="DataValues.jl",
5+
analytics="UA-132838790-1",
6+
pages=[
77
"Introduction" => "index.md"
88
])
99

10-
deploydocs(repo = "github.com/queryverse/DataValues.jl.git")
10+
deploydocs(repo="github.com/queryverse/DataValues.jl.git")

examples/03-combined.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ using DataValues
22

33
A = [DataValue(9), DataValue(8), DataValue(15)]
44

5-
map(i->isna(i) ? false : get(i) % 3 == 0, A)
5+
map(i -> isna(i) ? false : get(i) % 3 == 0, A)
66

77
f(i) = isna(i) ? false : get(i) % 3 == 0
88

src/array/constructors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ end
5252
# The following method allows for the construction of zero-element
5353
# DataValueArrays by calling the parametrized type on zero arguments.
5454
function DataValueArray{T,N}() where {T,N}
55-
return DataValueArray{T}(ntuple(i->0, N))
55+
return DataValueArray{T}(ntuple(i -> 0, N))
5656
end
5757

5858
function DataValueArray{T,N}(data::AbstractArray{S,N}) where {S,T,N}

src/array/datavaluevector.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Remove the item at index `i` and return the removed item. Subsequent items
9696
are shifted down to fill the resulting gap. If specified, replacement values from
9797
an ordered collection will be spliced in place of the removed item.
9898
"""
99-
function Base.splice!(X::DataValueVector, i::Integer, ins = _default_splice)
99+
function Base.splice!(X::DataValueVector, i::Integer, ins=_default_splice)
100100
v = X[i]
101101
m = length(ins)
102102
if m == 0
@@ -125,7 +125,7 @@ place of the removed items.
125125
To insert `ins` before an index `n` without removing any items, use
126126
`splice!(X, n:n-1, ins)`.
127127
"""
128-
function Base.splice!(X::DataValueVector, rng::UnitRange{T}, ins = _default_splice) where {T <: Integer}
128+
function Base.splice!(X::DataValueVector, rng::UnitRange{T}, ins=_default_splice) where {T <: Integer}
129129
vs = X[rng]
130130
m = length(ins)
131131
if m == 0
@@ -250,7 +250,7 @@ Modify `X` by reversing the first `n` elements starting at index `s`
250250
(inclusive). If unspecified, `s` and `n` will default to `1` and `length(X)`,
251251
respectively.
252252
"""
253-
function Base.reverse!(X::DataValueVector, s = 1, n = length(X))
253+
function Base.reverse!(X::DataValueVector, s=1, n=length(X))
254254
if isbitstype(eltype(X)) || !any(isna, X)
255255
reverse!(X.values, s, n)
256256
reverse!(X.isna, s, n)
@@ -280,7 +280,7 @@ Return a copy of `X` with the first `n` elements starting at index `s`
280280
(inclusive) reversed. If unspecified, `s` and `n` will default to `1` and
281281
`length(X)`, respectively.
282282
"""
283-
function Base.reverse(X::DataValueVector, s = 1, n = length(X))
283+
function Base.reverse(X::DataValueVector, s=1, n=length(X))
284284
return reverse!(copy(X), s, n)
285285
end
286286

src/array/primitives.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function dropna(X::AbstractVector{T}) where {T}
180180
if !(DataValue <: T) && !(T <: DataValue)
181181
return copy(X)
182182
else
183-
Y = filter(x->!isna(x), X)
183+
Y = filter(x -> !isna(x), X)
184184
res = similar(Y, eltype(T))
185185
for i in eachindex(Y, res)
186186
@inbounds res[i] = isa(Y[i], DataValue) ? Y[i].value : Y[i]

src/array/reduce.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ behavior is enabled, `f` will be automatically lifted over the elements of `X`.
106106
Note that, in general, mapreducing over a `DataValueArray` will return a
107107
`DataValue` object regardless of whether `skipna` is set to `true` or `false`.
108108
"""
109-
function Base.mapreduce(f, op::Function, X::T; skipna::Bool = false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
109+
function Base.mapreduce(f, op::Function, X::T; skipna::Bool=false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
110110
if skipna
111111
return DataValue(mapreduce(f, op, dropna(X)))
112112
else
@@ -124,8 +124,8 @@ over the elements of `X`. Note that, in general, mapreducing over a
124124
`DataValueArray` will return a `DataValue` object regardless of whether `skipna`
125125
is set to `true` or `false`.
126126
"""
127-
function Base.reduce(op, X::T; skipna::Bool = false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
128-
return mapreduce(identity, op, X; skipna = skipna)
127+
function Base.reduce(op, X::T; skipna::Bool=false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
128+
return mapreduce(identity, op, X; skipna=skipna)
129129
end
130130

131131
# standard reductions
@@ -137,12 +137,12 @@ for (fn, op) in ((:(Base.sum), +),
137137
@eval begin
138138
# supertype(typeof(@functorize(abs))) returns Func{1} on Julia 0.4,
139139
# and Function on 0.5
140-
function $fn(f::Union{Function,Type}, X::T; skipna::Bool = false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
141-
return mapreduce(f, $op, X; skipna = skipna)
140+
function $fn(f::Union{Function,Type}, X::T; skipna::Bool=false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
141+
return mapreduce(f, $op, X; skipna=skipna)
142142
end
143143

144-
function $fn(X::T; skipna::Bool = false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
145-
return mapreduce(identity, $op, X; skipna = skipna)
144+
function $fn(X::T; skipna::Bool=false) where {N,S <: DataValue,T <: AbstractArray{S,N}}
145+
return mapreduce(identity, $op, X; skipna=skipna)
146146
end
147147
end
148148
end
@@ -191,7 +191,7 @@ end
191191
# return v
192192
# end
193193

194-
function Base.extrema(X::T; skipna::Bool = false) where {N,T2,T <: DataValueArray{T2,N}}
194+
function Base.extrema(X::T; skipna::Bool=false) where {N,T2,T <: DataValueArray{T2,N}}
195195
length(X) > 0 || throw(ArgumentError("collection must be non-empty"))
196196
vmin = DataValue{T2}()
197197
vmax = DataValue{T2}()
@@ -213,7 +213,7 @@ function Base.extrema(X::T; skipna::Bool = false) where {N,T2,T <: DataValueArra
213213
return (vmin, vmax)
214214
end
215215

216-
function Base.extrema(X::T; skipna::Bool = false) where {N,T2,S <: DataValue{T2},T <: AbstractArray{S,N}}
216+
function Base.extrema(X::T; skipna::Bool=false) where {N,T2,S <: DataValue{T2},T <: AbstractArray{S,N}}
217217
length(X) > 0 || throw(ArgumentError("collection must be non-empty"))
218218
vmin = DataValue{T2}()
219219
vmax = DataValue{T2}()

src/scalar/core.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ struct DataValue{T}
33
value::T
44

55
DataValue{T}() where {T} = new(false)
6-
DataValue{T}(value::T, hasvalue::Bool = true) where {T} = new(hasvalue, value)
6+
DataValue{T}(value::T, hasvalue::Bool=true) where {T} = new(hasvalue, value)
77
end
88

99
struct DataValueException <: Exception
1010
end
1111

1212
const NA = DataValue{Union{}}()
1313

14-
DataValue(value::T, hasvalue::Bool = true) where {T} = DataValue{T}(value, hasvalue)
14+
DataValue(value::T, hasvalue::Bool=true) where {T} = DataValue{T}(value, hasvalue)
1515
DataValue(value::Missing) = DataValue{Union{}}()
1616
DataValue{T}(::Missing) where T = DataValue{T}()
1717
DataValue() = DataValue{Union{}}()

src/scalar/operations.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ maptoTuple(f, a, b...) = Tuple{f(a),maptoTuple(f, b...).types...}
1111
_nullable_eltype(f, A, As...) =
1212
Base._return_type(f, maptoTuple(_unsafe_get_eltype, A, As...))
1313

14-
function Dates.DateTime(dt::DataValue{T}, format::AbstractString; locale::Dates.Locale = Dates.ENGLISH) where {T <: AbstractString}
15-
isna(dt) ? DataValue{DateTime}() : DataValue{DateTime}(DateTime(unsafe_get(dt), format, locale = locale))
14+
function Dates.DateTime(dt::DataValue{T}, format::AbstractString; locale::Dates.Locale=Dates.ENGLISH) where {T <: AbstractString}
15+
isna(dt) ? DataValue{DateTime}() : DataValue{DateTime}(DateTime(unsafe_get(dt), format, locale=locale))
1616
end
1717

18-
function Dates.Date(dt::DataValue{T}, format::AbstractString; locale::Dates.Locale = Dates.ENGLISH) where {T <: AbstractString}
19-
isna(dt) ? DataValue{Date}() : DataValue{Date}(Date(unsafe_get(dt), format, locale = locale))
18+
function Dates.Date(dt::DataValue{T}, format::AbstractString; locale::Dates.Locale=Dates.ENGLISH) where {T <: AbstractString}
19+
isna(dt) ? DataValue{Date}() : DataValue{Date}(Date(unsafe_get(dt), format, locale=locale))
2020
end
2121

2222
for f in (:(Base.abs), :(Base.abs2), :(Base.conj), :(Base.sign))

test/array/test_broadcast.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ using Test
1515
M3 = rand(Bool, 10, [dims; i]...)
1616
C3 = Array{Float64}(undef, 10, [dims; i]...)
1717

18-
m1 = broadcast((x, y)->x, M1, M2)
19-
m2 = broadcast((x, y)->x, M2, M3)
20-
R2 = reshape(Bool[ (x->(m1[x] | M2[x]))(i) for i in 1:length(M2) ], size(M2))
21-
R3 = reshape(Bool[ (x->(m2[x] | M3[x]))(i) for i in 1:length(M3) ], size(M3))
22-
r2 = broadcast((x, y)->x, R2, R3)
23-
Q3 = reshape(Bool[ (x->(r2[x] | R3[x]))(i) for i in 1:length(R3) ], size(M3))
18+
m1 = broadcast((x, y) -> x, M1, M2)
19+
m2 = broadcast((x, y) -> x, M2, M3)
20+
R2 = reshape(Bool[ (x -> (m1[x] | M2[x]))(i) for i in 1:length(M2) ], size(M2))
21+
R3 = reshape(Bool[ (x -> (m2[x] | M3[x]))(i) for i in 1:length(M3) ], size(M3))
22+
r2 = broadcast((x, y) -> x, R2, R3)
23+
Q3 = reshape(Bool[ (x -> (r2[x] | R3[x]))(i) for i in 1:length(R3) ], size(M3))
2424

2525
U1 = DataValueArray(A1)
2626
U2 = DataValueArray(A2)

test/array/test_primitives.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,14 @@ using DataValues
134134

135135
Y1 = reshape(copy(Y), length(Y), 1)
136136
@test size(Y1) == (length(Y), 1)
137-
@test all(i->isequal(Y1[i], Y[i]), 1:length(Y))
137+
@test all(i -> isequal(Y1[i], Y[i]), 1:length(Y))
138138
Y2 = reshape(Y1, 1, length(Y1))
139139
@test size(Y2) == (1, length(Y1))
140-
@test all(i->isequal(Y1[i], Y2[i]), 1:length(Y2))
140+
@test all(i -> isequal(Y1[i], Y2[i]), 1:length(Y2))
141141
# Test that arrays share the same data
142142
Y2.values[1] += 1
143143
Y2.isna[2] = true
144-
@test all(i->isequal(Y1[i], Y2[i]), 1:length(Y2))
144+
@test all(i -> isequal(Y1[i], Y2[i]), 1:length(Y2))
145145

146146
# ----- test Base.ndims ------------------------------------------------------#
147147

@@ -163,10 +163,10 @@ using DataValues
163163
# ----- test Base.find -------------------------------------------------------#
164164

165165
z = DataValueArray(rand(Bool, 10))
166-
@test (LinearIndices(z))[findall(x->x != 0, z)] == (LinearIndices(z.values))[findall(z.values)]
166+
@test (LinearIndices(z))[findall(x -> x != 0, z)] == (LinearIndices(z.values))[findall(z.values)]
167167

168168
z = DataValueArray([false, true, false, true, false, true])
169-
@test isequal((LinearIndices(z))[findall(x->x != 0, z)], [2, 4, 6])
169+
@test isequal((LinearIndices(z))[findall(x -> x != 0, z)], [2, 4, 6])
170170

171171
# ----- test dropna --------------------------------------------------------#
172172

@@ -207,11 +207,11 @@ using DataValues
207207

208208
# test that dropna! returns unwrapped values when DataValues are present
209209
X = [false, 1, :c, "string", DataValue("I am not null"), DataValue()]
210-
@test !any(x->isa(x, DataValue), dropna!(X))
211-
@test any(x->isa(x, DataValue), X)
210+
@test !any(x -> isa(x, DataValue), dropna!(X))
211+
@test any(x -> isa(x, DataValue), X)
212212
Y = Any[false, 1, :c, "string", DataValue("I am not null"), DataValue()]
213-
@test !any(x->isa(x, DataValue), dropna!(Y))
214-
@test any(x->isa(x, DataValue), Y)
213+
@test !any(x -> isa(x, DataValue), dropna!(Y))
214+
@test any(x -> isa(x, DataValue), Y)
215215

216216
# ----- test any(isna, X) --------------------------------------------------#
217217

0 commit comments

Comments
 (0)