We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df32d77 commit 84219d9Copy full SHA for 84219d9
ot/lp/__init__.py
@@ -78,7 +78,7 @@ def emd(a, b, M):
78
79
return emd_c(a, b, M)
80
81
-def emd2(a, b, M,processes=None):
+def emd2(a, b, M,processes=multiprocessing.cpu_count()):
82
"""Solves the Earth Movers distance problem and returns the loss
83
84
.. math::
@@ -149,9 +149,11 @@ def emd2(a, b, M,processes=None):
149
else:
150
nb=b.shape[1]
151
ls=[(a,b[:,k],M) for k in range(nb)]
152
+ def f(l):
153
+ return emd2(l[0],l[1],l[2])
154
# run emd in multiprocessing
- res=parmap(emd2, ls,processes)
- np.array(res)
155
+ res=parmap(f, ls,processes)
156
+ return np.array(res)
157
# with Pool(processes) as p:
158
# res=p.map(f, ls)
159
# return np.array(res)
@@ -164,7 +166,7 @@ def fun(f, q_in, q_out):
164
166
break
165
167
q_out.put((i, f(x)))
168
-def parmap(f, X, nprocs):
169
+def parmap(f, X, nprocs=multiprocessing.cpu_count()):
170
q_in = multiprocessing.Queue(1)
171
q_out = multiprocessing.Queue()
172
0 commit comments