Skip to content

Commit 3050fb6

Browse files
authored
Merge pull request #171 from JuliaML/auto-juliaformatter-pr
[AUTO] JuliaFormatter.jl run
2 parents ffd4ffb + 7ee43fd commit 3050fb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+333
-381
lines changed

docs/make.jl

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ using DocumenterTools: Themes
33

44
using TransformsBase
55

6-
Themes.compile(joinpath(@__DIR__,"src/assets/light.scss"), joinpath(@__DIR__,"src/assets/themes/documenter-light.css"))
7-
Themes.compile(joinpath(@__DIR__,"src/assets/dark.scss"), joinpath(@__DIR__,"src/assets/themes/documenter-dark.css"))
6+
Themes.compile(
7+
joinpath(@__DIR__, "src/assets/light.scss"),
8+
joinpath(@__DIR__, "src/assets/themes/documenter-light.css")
9+
)
10+
Themes.compile(joinpath(@__DIR__, "src/assets/dark.scss"), joinpath(@__DIR__, "src/assets/themes/documenter-dark.css"))
811

912
DocMeta.setdocmeta!(TableTransforms, :DocTestSetup, :(using TableTransforms); recursive=true)
1013

@@ -19,17 +22,12 @@ makedocs(;
1922
format=Documenter.HTML(;
2023
prettyurls=get(ENV, "CI", "false") == "true",
2124
canonical="https://JuliaML.github.io/TableTransforms.jl",
22-
assets=["assets/favicon.ico", asset("https://fonts.googleapis.com/css?family=Montserrat|Source+Code+Pro&display=swap", class=:css)]
25+
assets=[
26+
"assets/favicon.ico",
27+
asset("https://fonts.googleapis.com/css?family=Montserrat|Source+Code+Pro&display=swap", class=:css)
28+
]
2329
),
24-
pages=[
25-
"Home" => "index.md",
26-
"Transforms" => "transforms.md",
27-
"Related" => "related.md"
28-
]
30+
pages=["Home" => "index.md", "Transforms" => "transforms.md", "Related" => "related.md"]
2931
)
3032

31-
deploydocs(;
32-
repo="github.com/JuliaML/TableTransforms.jl",
33-
devbranch="master",
34-
push_preview=true
35-
)
33+
deploydocs(; repo="github.com/JuliaML/TableTransforms.jl", devbranch="master", push_preview=true)

src/TableTransforms.jl

+5-2
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,12 @@ export
6767
Quantile,
6868
Functional,
6969
EigenAnalysis,
70-
PCA, DRS, SDS,
70+
PCA,
71+
DRS,
72+
SDS,
7173
ProjectionPursuit,
7274
RowTable,
7375
ColTable,
74-
,
76+
,
77+
7578
end

src/assertions.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ struct SciTypeAssertion{T,S<:ColSpec}
1111
colspec::S
1212
end
1313

14-
SciTypeAssertion{T}(colspec::S) where {T,S<:ColSpec} =
15-
SciTypeAssertion{T,S}(colspec)
14+
SciTypeAssertion{T}(colspec::S) where {T,S<:ColSpec} = SciTypeAssertion{T,S}(colspec)
1615

1716
SciTypeAssertion{T}() where {T} = SciTypeAssertion{T}(AllSpec())
1817

src/distributions.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ function cdf(d::EmpiricalDistribution{T}, x::T) where {T<:Real}
4848
return (pu - pl) * (x - l) / (u - l) + pl
4949
end
5050
end
51-
end
51+
end

src/tableselection.jl

+6-10
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,14 @@ struct TableSelection{T,C}
2020
end
2121

2222
function Base.:(==)(a::TableSelection, b::TableSelection)
23-
a.names != b.names && return false
23+
a.names != b.names && return false
2424
a.onames != b.onames && return false
2525
all(nm -> Tables.getcolumn(a, nm) == Tables.getcolumn(b, nm), a.names)
2626
end
2727

2828
function Base.show(io::IO, t::TableSelection)
2929
println(io, "TableSelection")
30-
pretty_table(io, t,
31-
vcrop_mode=:middle,
32-
newline_at_end=false
33-
)
30+
pretty_table(io, t, vcrop_mode=:middle, newline_at_end=false)
3431
end
3532

3633
# Tables.jl interface
@@ -49,13 +46,12 @@ function Tables.getcolumn(t::TableSelection, nm::Symbol)
4946
Tables.getcolumn(t.cols, t.mapnames[nm])
5047
end
5148

52-
Tables.materializer(t::TableSelection) =
53-
Tables.materializer(t.table)
49+
Tables.materializer(t::TableSelection) = Tables.materializer(t.table)
5450

5551
function Tables.schema(t::TableSelection)
5652
schema = Tables.schema(t.cols)
57-
names = schema.names
58-
types = schema.types
59-
inds = indexin(t.onames, collect(names))
53+
names = schema.names
54+
types = schema.types
55+
inds = indexin(t.onames, collect(names))
6056
Tables.Schema(t.names, types[inds])
6157
end

src/tabletraits.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ divide(table) = table, nothing
1616
Combine a table with `features` and a `metadata`
1717
object into a special type of `table`.
1818
"""
19-
attach(features, ::Nothing) = features
19+
attach(features, ::Nothing) = features

src/transforms.jl

+13-15
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ function revert(transform::FeatureTransform, newtable, cache)
150150
@assert isrevertible(transform) "Transform is not revertible"
151151

152152
newfeat, newmeta = divide(newtable)
153-
fcache, mcache = cache
153+
fcache, mcache = cache
154154

155155
feat = revertfeat(transform, newfeat, fcache)
156156
meta = revertmeta(transform, newmeta, mcache)
@@ -159,7 +159,7 @@ function revert(transform::FeatureTransform, newtable, cache)
159159
end
160160

161161
function reapply(transform::FeatureTransform, table, cache)
162-
feat, meta = divide(table)
162+
feat, meta = divide(table)
163163
fcache, mcache = cache
164164

165165
for assertion in assertions(transform)
@@ -180,22 +180,20 @@ reapplymeta(::FeatureTransform, meta, mcache) = meta
180180
# STATELESS FALLBACKS
181181
# --------------------
182182

183-
reapply(transform::StatelessTableTransform, table, cache) =
184-
apply(transform, table) |> first
183+
reapply(transform::StatelessTableTransform, table, cache) = apply(transform, table) |> first
185184

186-
reapply(transform::StatelessFeatureTransform, table, cache) =
187-
apply(transform, table) |> first
185+
reapply(transform::StatelessFeatureTransform, table, cache) = apply(transform, table) |> first
188186

189187
# ------------------
190188
# COLWISE FALLBACKS
191189
# ------------------
192190

193191
function applyfeat(transform::ColwiseFeatureTransform, feat, prep)
194192
# retrieve column names and values
195-
cols = Tables.columns(feat)
196-
names = Tables.columnnames(cols)
193+
cols = Tables.columns(feat)
194+
names = Tables.columnnames(cols)
197195
snames = choose(transform.colspec, names)
198-
196+
199197
# function to transform a single column
200198
function colfunc(n)
201199
x = Tables.getcolumn(cols, n)
@@ -225,11 +223,11 @@ end
225223

226224
function revertfeat(transform::ColwiseFeatureTransform, newfeat, fcache)
227225
# transformed columns
228-
cols = Tables.columns(newfeat)
226+
cols = Tables.columns(newfeat)
229227
names = Tables.columnnames(cols)
230-
228+
231229
caches, snames = fcache
232-
230+
233231
# function to transform a single column
234232
function colfunc(i)
235233
n = names[i]
@@ -248,11 +246,11 @@ end
248246

249247
function reapplyfeat(transform::ColwiseFeatureTransform, feat, fcache)
250248
# retrieve column names and values
251-
cols = Tables.columns(feat)
249+
cols = Tables.columns(feat)
252250
names = Tables.columnnames(cols)
253251

254252
caches, snames = fcache
255-
253+
256254
# check that cache is valid
257255
@assert length(names) == length(caches) "invalid caches for feat"
258256

@@ -296,4 +294,4 @@ include("transforms/eigenanalysis.jl")
296294
include("transforms/projectionpursuit.jl")
297295
include("transforms/rowtable.jl")
298296
include("transforms/coltable.jl")
299-
include("transforms/parallel.jl")
297+
include("transforms/parallel.jl")

src/transforms/center.jl

+2-3
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ end
3333

3434
Center() = Center(AllSpec())
3535
Center(spec) = Center(colspec(spec))
36-
Center(cols::C...) where {C<:Col} =
37-
Center(colspec(cols))
36+
Center(cols::C...) where {C<:Col} = Center(colspec(cols))
3837

3938
assertions(transform::Center) = [SciTypeAssertion{Continuous}(transform.colspec)]
4039

4140
isrevertible(::Type{<:Center}) = true
4241

4342
colcache(::Center, x) = mean(x)
4443

45-
colapply(::Center, x, μ) = @. x - μ
44+
colapply(::Center, x, μ) = @. x - μ
4645

4746
colrevert(::Center, y, μ) = @. y + μ

src/transforms/coalesce.jl

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ end
4040

4141
Coalesce(; value) = Coalesce(AllSpec(), value)
4242
Coalesce(spec; value) = Coalesce(colspec(spec), value)
43-
Coalesce(cols::C...; value) where {C<:Col} =
44-
Coalesce(colspec(cols), value)
43+
Coalesce(cols::C...; value) where {C<:Col} = Coalesce(colspec(cols), value)
4544

4645
isrevertible(::Type{<:Coalesce}) = true
4746

src/transforms/coerce.jl

+5-8
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,27 @@ struct Coerce{P} <: FeatureTransform
2222
verbosity::Int
2323
end
2424

25-
Coerce(pair::Pair{Symbol,<:Type}...; tight=false, verbosity=1) =
26-
Coerce(pair, tight, verbosity)
25+
Coerce(pair::Pair{Symbol,<:Type}...; tight=false, verbosity=1) = Coerce(pair, tight, verbosity)
2726

2827
isrevertible(::Type{<:Coerce}) = true
2928

3029
function applyfeat(transform::Coerce, feat, prep)
31-
newtable = coerce(feat, transform.pairs...;
32-
tight=transform.tight,
33-
verbosity=transform.verbosity)
30+
newtable = coerce(feat, transform.pairs...; tight=transform.tight, verbosity=transform.verbosity)
3431

3532
types = Tables.schema(feat).types
36-
33+
3734
newtable, types
3835
end
3936

4037
function revertfeat(::Coerce, newfeat, fcache)
4138
cols = Tables.columns(newfeat)
4239
names = Tables.columnnames(cols)
43-
40+
4441
oldcols = map(zip(fcache, names)) do (T, n)
4542
x = Tables.getcolumn(cols, n)
4643
collect(T, x)
4744
end
48-
45+
4946
𝒯 = (; zip(names, oldcols)...)
5047
𝒯 |> Tables.materializer(newfeat)
5148
end

src/transforms/eigenanalysis.jl

+12-16
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ struct EigenAnalysis <: FeatureTransform
5151
end
5252
end
5353

54-
EigenAnalysis(proj; maxdim=nothing, pratio=1.0) =
55-
EigenAnalysis(proj, maxdim, pratio)
54+
EigenAnalysis(proj; maxdim=nothing, pratio=1.0) = EigenAnalysis(proj, maxdim, pratio)
5655

5756
assertions(::Type{EigenAnalysis}) = [SciTypeAssertion{Continuous}()]
5857

@@ -130,10 +129,10 @@ _maxdim(::Nothing, Y) = size(Y, 2)
130129

131130
function outdim(transform, Y, λ)
132131
pratio = transform.pratio
133-
csums = cumsum(λ)
132+
csums = cumsum(λ)
134133
ratios = csums ./ last(csums)
135-
mdim = _maxdim(transform.maxdim, Y)
136-
pdim = findfirst((pratio), ratios)
134+
mdim = _maxdim(transform.maxdim, Y)
135+
pdim = findfirst((pratio), ratios)
137136
min(mdim, pdim)
138137
end
139138

@@ -144,15 +143,15 @@ function eigenmatrices(transform, Y)
144143
λ, V = eigen(Σ, sortby=λ -> -real(λ))
145144

146145
if proj == :V
147-
S = V
146+
S = V
148147
S⁻¹ = transpose(V)
149148
elseif proj == :VD
150-
Λ = Diagonal(sqrt.(λ))
151-
S = V * inv(Λ)
149+
Λ = Diagonal(sqrt.(λ))
150+
S = V * inv(Λ)
152151
S⁻¹ = Λ * transpose(V)
153152
elseif proj == :VDV
154-
Λ = Diagonal(sqrt.(λ))
155-
S = V * inv(Λ) * transpose(V)
153+
Λ = Diagonal(sqrt.(λ))
154+
S = V * inv(Λ) * transpose(V)
156155
S⁻¹ = V * Λ * transpose(V)
157156
end
158157

@@ -177,8 +176,7 @@ PCA(pratio=0.86)
177176
PCA(maxdim=2, pratio=0.86)
178177
```
179178
"""
180-
PCA(; maxdim=nothing, pratio=1.0) =
181-
ZScore() EigenAnalysis(:V, maxdim, pratio)
179+
PCA(; maxdim=nothing, pratio=1.0) = ZScore() EigenAnalysis(:V, maxdim, pratio)
182180

183181
"""
184182
DRS(; maxdim=nothing, pratio=1.0)
@@ -196,8 +194,7 @@ DRS(pratio=0.87)
196194
DRS(maxdim=3, pratio=0.87)
197195
```
198196
"""
199-
DRS(; maxdim=nothing, pratio=1.0) =
200-
ZScore() EigenAnalysis(:VD, maxdim, pratio)
197+
DRS(; maxdim=nothing, pratio=1.0) = ZScore() EigenAnalysis(:VD, maxdim, pratio)
201198

202199
"""
203200
SDS(; maxdim=nothing, pratio=1.0)
@@ -216,5 +213,4 @@ SDS(pratio=0.88)
216213
SDS(maxdim=4, pratio=0.88)
217214
```
218215
"""
219-
SDS(; maxdim=nothing, pratio=1.0) =
220-
ZScore() EigenAnalysis(:VDV, maxdim, pratio)
216+
SDS(; maxdim=nothing, pratio=1.0) = ZScore() EigenAnalysis(:VDV, maxdim, pratio)

src/transforms/filter.jl

+8-11
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ Filter(row -> row.a == true && row.b < 30)
1919
* The schema of the table is preserved by the transform.
2020
"""
2121
struct Filter{F} <: StatelessFeatureTransform
22-
func::F
22+
func::F
2323
end
2424

2525
isrevertible(::Type{<:Filter}) = true
2626

2727
function preprocess(transform::Filter, table)
2828
# lazy row iterator
29-
rows = Tables.rows(table)
29+
rows = Tables.rows(table)
3030

3131
# selected indices
3232
sinds, nrows = Int[], 0
@@ -107,16 +107,13 @@ DropMissing() = DropMissing(AllSpec())
107107

108108
DropMissing(spec) = DropMissing(colspec(spec))
109109

110-
DropMissing(cols::T...) where {T<:Col} =
111-
DropMissing(colspec(cols))
110+
DropMissing(cols::T...) where {T<:Col} = DropMissing(colspec(cols))
112111

113112
isrevertible(::Type{<:DropMissing}) = true
114113

115-
_ftrans(::DropMissing{AllSpec}, cols) =
116-
Filter(row -> all(!ismissing, row))
114+
_ftrans(::DropMissing{AllSpec}, cols) = Filter(row -> all(!ismissing, row))
117115

118-
_ftrans(::DropMissing, cols) =
119-
Filter(row -> all(!ismissing, getindex.(Ref(row), cols)))
116+
_ftrans(::DropMissing, cols) = Filter(row -> all(!ismissing, getindex.(Ref(row), cols)))
120117

121118
# nonmissing
122119
_nonmissing(::Type{T}, x) where {T} = x
@@ -125,10 +122,10 @@ _nonmissing(x) = _nonmissing(eltype(x), x)
125122

126123
function preprocess(transform::DropMissing, table)
127124
schema = Tables.schema(table)
128-
names = schema.names
125+
names = schema.names
129126
snames = choose(transform.colspec, names)
130127
ftrans = _ftrans(transform, snames)
131-
fprep = preprocess(ftrans, table)
128+
fprep = preprocess(ftrans, table)
132129
ftrans, fprep, snames
133130
end
134131

@@ -138,7 +135,7 @@ function applyfeat(::DropMissing, feat, prep)
138135
newfeat, ffcache = applyfeat(ftrans, feat, fprep)
139136

140137
# drop Missing type
141-
cols = Tables.columns(newfeat)
138+
cols = Tables.columns(newfeat)
142139
names = Tables.columnnames(cols)
143140
ncols = map(names) do n
144141
x = Tables.getcolumn(cols, n)

0 commit comments

Comments
 (0)