Skip to content

Commit

Permalink
parallel_map: don't return the result as an array
Browse files Browse the repository at this point in the history
Sometimes the results list is inhomogeneous and conversion to an
array type fails for this reason.
  • Loading branch information
manu-mannattil committed Mar 6, 2024
1 parent b71b5bc commit ccd9fab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
32 changes: 18 additions & 14 deletions nolitsa/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@ def afn(x, dim=[1], tau=1, metric='chebyshev', window=10, maxnum=None,
else:
processes = 1

return utils.parallel_map(_afn, dim, (x,), {
'tau': tau,
'metric': metric,
'window': window,
'maxnum': maxnum
}, processes).T
r = utils.parallel_map(_afn, dim, (x,), {
'tau': tau,
'metric': metric,
'window': window,
'maxnum': maxnum
}, processes)

return np.asarray(r).T


def _fnn(d, x, tau=1, R=10.0, A=2.0, metric='euclidean', window=10,
Expand Down Expand Up @@ -182,11 +184,13 @@ def fnn(x, dim=[1], tau=1, R=10.0, A=2.0, metric='euclidean', window=10,
else:
processes = 1

return utils.parallel_map(_fnn, dim, (x,), {
'tau': tau,
'R': R,
'A': A,
'metric': metric,
'window': window,
'maxnum': maxnum
}, processes).T
r = utils.parallel_map(_fnn, dim, (x,), {
'tau': tau,
'R': R,
'A': A,
'metric': metric,
'window': window,
'maxnum': maxnum
}, processes)

return np.asarray(r).T
2 changes: 1 addition & 1 deletion nolitsa/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def parallel_map(func, values, args=tuple(), kwargs=dict(),
pool.close()
pool.join()

return np.asarray([result.get() for result in results])
return [result.get() for result in results]


def reconstruct(x, dim=1, tau=1):
Expand Down

0 comments on commit ccd9fab

Please sign in to comment.