2
2
# Licensed under the MIT License. See LICENSE in the project root.
3
3
# ------------------------------------------------------------------
4
4
5
- const ColSelector = Union{Vector{Symbol}, Regex}
5
+ const ColSpec = Union{Vector{Symbol}, Regex}
6
6
7
7
"""
8
8
Select(col₁, col₂, ..., colₙ)
@@ -11,10 +11,11 @@ const ColSelector = Union{Vector{Symbol}, Regex}
11
11
12
12
The transform that selects columns `col₁`, `col₂`, ..., `colₙ`.
13
13
14
- Select(Regex)
15
- Selects the columns that match with Regex.
14
+ Select(regex)
15
+
16
+ Selects the columns that match with `regex`.
16
17
"""
17
- struct Select{S<: ColSelector } <: Stateless
18
+ struct Select{S<: ColSpec } <: Stateless
18
19
cols:: S
19
20
end
20
21
@@ -31,14 +32,14 @@ Base.:(==)(a::Select, b::Select) = a.cols == b.cols
31
32
32
33
isrevertible (:: Type{<:Select} ) = true
33
34
34
- _selectedcols (cols:: Vector{Symbol} , allcols) = cols
35
- _selectedcols (cols:: Regex , allcols) =
35
+ _select (cols:: Vector{Symbol} , allcols) = cols
36
+ _select (cols:: Regex , allcols) =
36
37
filter (col -> occursin (cols, String (col)), allcols)
37
38
38
39
function apply (transform:: Select , table)
39
40
# retrieve relevant column names
40
41
allcols = collect (Tables. columnnames (table))
41
- select = _selectedcols (transform. cols, allcols)
42
+ select = _select (transform. cols, allcols)
42
43
reject = setdiff (allcols, select)
43
44
44
45
# keep track of indices to revert later
94
95
95
96
The transform that discards columns `col₁`, `col₂`, ..., `colₙ`.
96
97
97
- Reject(Regex)
98
- Discards the columns that match with Regex.
98
+ Reject(regex)
99
+
100
+ Discards the columns that match with `regex`.
99
101
"""
100
- struct Reject{S<: ColSelector } <: Stateless
102
+ struct Reject{S<: ColSpec } <: Stateless
101
103
cols:: S
102
104
end
103
105
@@ -116,7 +118,7 @@ isrevertible(::Type{<:Reject}) = true
116
118
117
119
function apply (transform:: Reject , table)
118
120
allcols = Tables. columnnames (table)
119
- reject = _selectedcols (transform. cols, allcols)
121
+ reject = _select (transform. cols, allcols)
120
122
select = setdiff (allcols, reject)
121
123
strans = Select (select)
122
124
newtable, scache = apply (strans, table)
0 commit comments