Skip to content

Commit abb506e

Browse files
authored
Rename Parallel to ParallelTableTransform (#138)
1 parent 29bd21c commit abb506e

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

src/TableTransforms.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,5 @@ export
6767
PCA, DRS, SDS,
6868
RowTable,
6969
ColTable,
70-
Sequential,
71-
Parallel,
7270
,
7371
end

src/transforms/parallel.jl

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ------------------------------------------------------------------
44

55
"""
6-
Parallel(transforms)
6+
ParallelTableTransform(transforms)
77
88
A transform where `transforms` are applied in parallel.
99
@@ -14,25 +14,25 @@ Scale(low=0.3, high=0.6) ⊔ EigenAnalysis(:VDV)
1414
ZScore() ⊔ EigenAnalysis(:V)
1515
```
1616
"""
17-
struct Parallel <: TableTransform
17+
struct ParallelTableTransform <: TableTransform
1818
transforms::Vector{TableTransform}
1919
end
2020

2121
# AbstractTrees interface
22-
AbstractTrees.nodevalue(::Parallel) = Parallel
23-
AbstractTrees.children(p::Parallel) = p.transforms
22+
AbstractTrees.nodevalue(::ParallelTableTransform) = ParallelTableTransform
23+
AbstractTrees.children(p::ParallelTableTransform) = p.transforms
2424

25-
Base.show(io::IO, p::Parallel) =
25+
Base.show(io::IO, p::ParallelTableTransform) =
2626
print(io, join(p.transforms, ""))
2727

28-
function Base.show(io::IO, ::MIME"text/plain", p::Parallel)
28+
function Base.show(io::IO, ::MIME"text/plain", p::ParallelTableTransform)
2929
tree = repr_tree(p, context=io)
3030
print(io, tree[begin:end-1]) # remove \n at end
3131
end
3232

33-
isrevertible(p::Parallel) = any(isrevertible, p.transforms)
33+
isrevertible(p::ParallelTableTransform) = any(isrevertible, p.transforms)
3434

35-
function apply(p::Parallel, table)
35+
function apply(p::ParallelTableTransform, table)
3636
# apply transforms in parallel
3737
f(transform) = apply(transform, table)
3838
vals = tcollect(f(t) for t in p.transforms)
@@ -75,7 +75,7 @@ function apply(p::Parallel, table)
7575
newtable, (caches, rinfo)
7676
end
7777

78-
function revert(p::Parallel, newtable, cache)
78+
function revert(p::ParallelTableTransform, newtable, cache)
7979
# retrieve cache
8080
caches = cache[1]
8181
rinfo = cache[2]
@@ -110,7 +110,7 @@ function revert(p::Parallel, newtable, cache)
110110
attach(feat, meta)
111111
end
112112

113-
function reapply(p::Parallel, table, cache)
113+
function reapply(p::ParallelTableTransform, table, cache)
114114
# retrieve caches
115115
caches = cache[1]
116116

@@ -160,10 +160,14 @@ end
160160
"""
161161
transform₁ ⊔ transform₂ ⊔ ⋯ ⊔ transformₙ
162162
163-
Create a [`Parallel`](@ref) transform with
163+
Create a [`ParallelTableTransform`](@ref) transform with
164164
`[transform₁, transform₂, …, transformₙ]`.
165165
"""
166-
(t1::TableTransform, t2::TableTransform) = Parallel([t1, t2])
167-
(t1::TableTransform, t2::Parallel) = Parallel([t1; t2.transforms])
168-
(t1::Parallel, t2::TableTransform) = Parallel([t1.transforms; t2])
169-
(t1::Parallel, t2::Parallel) = Parallel([t1.transforms; t2.transforms])
166+
(t1::TableTransform, t2::TableTransform) =
167+
ParallelTableTransform([t1, t2])
168+
(t1::TableTransform, t2::ParallelTableTransform) =
169+
ParallelTableTransform([t1; t2.transforms])
170+
(t1::ParallelTableTransform, t2::TableTransform) =
171+
ParallelTableTransform([t1.transforms; t2])
172+
(t1::ParallelTableTransform, t2::ParallelTableTransform) =
173+
ParallelTableTransform([t1.transforms; t2.transforms])

test/shows.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
└─ Scale(all, 0, 1)"""
355355
end
356356

357-
@testset "Parallel" begin
357+
@testset "ParallelTableTransform" begin
358358
t1 = Scale(low=0.3, high=0.6)
359359
t2 = EigenAnalysis(:VDV)
360360
t3 = Functional(cos)
@@ -367,12 +367,12 @@
367367
# full mode
368368
iostr = sprint(show, MIME("text/plain"), pipeline)
369369
@test iostr == """
370-
Parallel
370+
ParallelTableTransform
371371
├─ Scale(all, 0.3, 0.6)
372372
├─ EigenAnalysis(:VDV, nothing, 1.0)
373373
└─ Functional(all, cos)"""
374374

375-
# Parallel with Sequential
375+
# parallel and sequential
376376
f1 = ZScore()
377377
f2 = Scale()
378378
f3 = Functional(cos)
@@ -386,7 +386,7 @@
386386
# full mode
387387
iostr = sprint(show, MIME("text/plain"), pipeline)
388388
@test iostr == """
389-
Parallel
389+
ParallelTableTransform
390390
├─ Sequential
391391
│ ├─ ZScore(all)
392392
│ └─ Scale(all, 0.25, 0.75)

test/transforms/parallel.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
tₒ = revert(T, n, c)
99
@test Tables.matrix(t) Tables.matrix(tₒ)
1010

11-
# check cardinality of Parallel
11+
# check cardinality of parallel transform
1212
x = rand(Normal(0, 10), 1500)
1313
y = x + rand(Normal(0, 2), 1500)
1414
z = y + rand(Normal(0, 5), 1500)
@@ -17,7 +17,7 @@
1717
n = T(t)
1818
@test length(Tables.columnnames(n)) == 6
1919

20-
# distributivity with respect to Sequential
20+
# distributivity with respect to sequential transform
2121
x = rand(Normal(0, 10), 1500)
2222
y = x + rand(Normal(0, 2), 1500)
2323
z = y + rand(Normal(0, 5), 1500)
@@ -31,7 +31,7 @@
3131
n₂ = P₂(t)
3232
@test Tables.matrix(n₁) Tables.matrix(n₂)
3333

34-
# reapply with Parallel transform
34+
# reapply with parallel transform
3535
t = Table(x=rand(1000))
3636
T = ZScore() Quantile()
3737
n1, c1 = apply(T, t)

0 commit comments

Comments
 (0)