From ccd9fab08a88fbc6ff63f0fae28730ccb74754de Mon Sep 17 00:00:00 2001 From: Manu Mannattil Date: Wed, 6 Mar 2024 12:06:06 +0200 Subject: [PATCH] parallel_map: don't return the result as an array Sometimes the results list is inhomogeneous and conversion to an array type fails for this reason. --- nolitsa/dimension.py | 32 ++++++++++++++++++-------------- nolitsa/utils.py | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/nolitsa/dimension.py b/nolitsa/dimension.py index ced8713..9a3a559 100644 --- a/nolitsa/dimension.py +++ b/nolitsa/dimension.py @@ -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, @@ -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 diff --git a/nolitsa/utils.py b/nolitsa/utils.py index e4bb208..bbf1b71 100644 --- a/nolitsa/utils.py +++ b/nolitsa/utils.py @@ -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):