ensemble_sift(): Index out of bounds error

Hello,

First of all great package and thank you for your work. However, I bounced on an index out of bounds error in the ensemble_sift() function for the maximum index due to some unfortunate python indexing.

EMD version 0.4.0

reprex:

np.random.seed(2021)
test_array = np.random.rand(24000)
emd_test = emd.sift.ensemble_sift(test_array, nensembles = 25, nprocesses = 8)

Should give:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-58-f67a9c7427a9> in <module>
      1 np.random.seed(2021)
      2 test_array = np.random.rand(24000)
----> 3 emd_test = emd.sift.ensemble_sift(test_array, nensembles = 25, nprocesses = 8)

~\Anaconda3\envs\phd-general\lib\site-packages\emd\logger.py in inner_verbose(*args, **kwargs)
    237 
    238         # Call function itself
--> 239         func_output = func(*args, **kwargs)
    240 
    241         if ('verbose' in kwargs) and (kwargs['verbose'] is not None):

~\Anaconda3\envs\phd-general\lib\site-packages\emd\logger.py in sift_logger(*args, **kwargs)
    206 
    207             # Call function itself
--> 208             func_output = func(*args, **kwargs)
    209 
    210             # Print number of IMFs, catching other outputs if they're returned

~\Anaconda3\envs\phd-general\lib\site-packages\emd\sift.py in ensemble_sift(X, nensembles, ensemble_noise, noise_mode, nprocesses, sift_thresh, max_imfs, verbose, imf_opts, envelope_opts, extrema_opts)
    625     imfs = np.zeros((X.shape[0], max_imfs))
    626     for ii in range(max_imfs):
--> 627         imfs[:, ii] = np.array([r[:, ii] for r in res]).mean(axis=0)
    628 
    629     return imfs

~\Anaconda3\envs\phd-general\lib\site-packages\emd\sift.py in <listcomp>(.0)
    625     imfs = np.zeros((X.shape[0], max_imfs))
    626     for ii in range(max_imfs):
--> 627         imfs[:, ii] = np.array([r[:, ii] for r in res]).mean(axis=0)
    628 
    629     return imfs


IndexError: index 10 is out of bounds for axis 1 with size 10

Note that when we set the max_imfs parameter in this case to < 10 or 11, the IndexError does not occur, however, from 12 onwards it does.

Thank you in advance!

Kind regards,

Bavo

Edited by BavoKempen