Skip to content

Commit c90e4aa

Browse files
committed
Apply suggestions
1 parent 9655615 commit c90e4aa

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/transforms/select.jl

+13-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Licensed under the MIT License. See LICENSE in the project root.
33
# ------------------------------------------------------------------
44

5-
const ColSelector = Union{Vector{Symbol}, Regex}
5+
const ColSpec = Union{Vector{Symbol}, Regex}
66

77
"""
88
Select(col₁, col₂, ..., colₙ)
@@ -11,10 +11,11 @@ const ColSelector = Union{Vector{Symbol}, Regex}
1111
1212
The transform that selects columns `col₁`, `col₂`, ..., `colₙ`.
1313
14-
Select(Regex)
15-
Selects the columns that match with Regex.
14+
Select(regex)
15+
16+
Selects the columns that match with `regex`.
1617
"""
17-
struct Select{S<:ColSelector} <: Stateless
18+
struct Select{S<:ColSpec} <: Stateless
1819
cols::S
1920
end
2021

@@ -31,14 +32,14 @@ Base.:(==)(a::Select, b::Select) = a.cols == b.cols
3132

3233
isrevertible(::Type{<:Select}) = true
3334

34-
_selectedcols(cols::Vector{Symbol}, allcols) = cols
35-
_selectedcols(cols::Regex, allcols) =
35+
_select(cols::Vector{Symbol}, allcols) = cols
36+
_select(cols::Regex, allcols) =
3637
filter(col -> occursin(cols, String(col)), allcols)
3738

3839
function apply(transform::Select, table)
3940
# retrieve relevant column names
4041
allcols = collect(Tables.columnnames(table))
41-
select = _selectedcols(transform.cols, allcols)
42+
select = _select(transform.cols, allcols)
4243
reject = setdiff(allcols, select)
4344

4445
# keep track of indices to revert later
@@ -94,10 +95,11 @@ end
9495
9596
The transform that discards columns `col₁`, `col₂`, ..., `colₙ`.
9697
97-
Reject(Regex)
98-
Discards the columns that match with Regex.
98+
Reject(regex)
99+
100+
Discards the columns that match with `regex`.
99101
"""
100-
struct Reject{S<:ColSelector} <: Stateless
102+
struct Reject{S<:ColSpec} <: Stateless
101103
cols::S
102104
end
103105

@@ -116,7 +118,7 @@ isrevertible(::Type{<:Reject}) = true
116118

117119
function apply(transform::Reject, table)
118120
allcols = Tables.columnnames(table)
119-
reject = _selectedcols(transform.cols, allcols)
121+
reject = _select(transform.cols, allcols)
120122
select = setdiff(allcols, reject)
121123
strans = Select(select)
122124
newtable, scache = apply(strans, table)

0 commit comments

Comments
 (0)