Skip to content

Commit cfc37e2

Browse files
committed
Use 'Distributed.pmap' in 'ParallelTableTransform'
1 parent 56e0add commit cfc37e2

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"
99
CoDa = "5900dafe-f573-5c72-b367-76665857777b"
1010
ColumnSelectors = "9cc86067-7e36-4c61-b350-1ac9833d277f"
1111
DataScienceTraits = "6cb2f572-2d2b-4ba6-bdb3-e710fa044d6c"
12+
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
1213
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1314
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
1415
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -28,6 +29,7 @@ CategoricalArrays = "0.10"
2829
CoDa = "1.2"
2930
ColumnSelectors = "0.1"
3031
DataScienceTraits = "0.3"
32+
Distributed = "1.9"
3133
Distributions = "0.25"
3234
InverseFunctions = "0.1"
3335
LinearAlgebra = "1.9"

src/TableTransforms.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ using Distributions: ContinuousUnivariateDistribution, Normal
2424
using InverseFunctions: NoInverse, inverse as invfun
2525
using StatsBase: AbstractWeights, Weights, sample
2626
using Transducers: tcollect
27+
using Distributed: pmap
2728
using NelderMead: optimise
2829

2930
import Distributions: quantile, cdf

src/transforms/parallel.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ isrevertible(p::ParallelTableTransform) = any(isrevertible, p.transforms)
4141

4242
function apply(p::ParallelTableTransform, table)
4343
# apply transforms in parallel
44-
f(transform) = apply(transform, table)
45-
vals = tcollect(f(t) for t in p.transforms)
44+
vals = pmap(t -> apply(t, table), p.transforms)
4645

4746
# retrieve tables and caches
4847
tables = first.(vals)
@@ -122,9 +121,7 @@ function reapply(p::ParallelTableTransform, table, cache)
122121
caches = cache[1]
123122

124123
# reapply transforms in parallel
125-
f(t, c) = reapply(t, table, c)
126-
itr = zip(p.transforms, caches)
127-
tables = tcollect(f(t, c) for (t, c) in itr)
124+
tables = pmap((t, c) -> reapply(t, table, c), p.transforms, caches)
128125

129126
# features and metadata
130127
splits = divide.(tables)

0 commit comments

Comments
 (0)