nbara/python-meegkit

LinAlgError: SVD did not converge in Linear Least Squares

FarnoodF opened this issue · 1 comments

I get the following error the first time I run the ASR instance definition:

---------------------------------------------------------------------------
LinAlgError                               Traceback (most recent call last)
<ipython-input-17-f449c895e6b2> in <module>
----> 1 asrC = asr.ASR(sfreq=125)

c:\~\python\python38\lib\site-packages\meegkit\asr.py in __init__(self, sfreq, cutoff, blocksize, win_len, win_overlap, max_dropout_fraction, min_clean_fraction, name, method, **kwargs)
    124             80.0, (sfreq / 2.0) - 1.0), sfreq / 2.0]) * 2.0 / sfreq
    125         M = np.array([3, 0.75, 0.33, 0.33, 1, 1, 3, 3])
--> 126         B, A = yulewalk(8, F, M)
    127         self.ab_ = (A, B)
    128         self.cov_ = []

c:\~\python\python38\lib\site-packages\meegkit\utils\asr.py in yulewalk(order, F, M)
    260         (1 / 2, np.ones((1, int(n2 - 1))), np.zeros((1, int(n - n2)))),
    261         axis=None)
--> 262     A = polystab(denf(R, order))  # compute denominator
    263 
    264     # compute additive decomposition

c:\~\python\python38\lib\site-packages\meegkit\utils\asr.py in denf(R, na)
    521     Rhs = - R[na + 1:nr]
    522     A = np.concatenate(
--> 523         (1, linalg.lstsq(Rm, Rhs.T, rcond=None)[0].T), axis=None)
    524     return A

<__array_function__ internals> in lstsq(*args, **kwargs)

c:\~\python\python38\lib\site-packages\numpy\linalg\linalg.py in lstsq(a, b, rcond)
   2257         # lapack can't handle n_rhs = 0 - so allocate the array one larger in that axis
   2258         b = zeros(b.shape[:-2] + (m, n_rhs + 1), dtype=b.dtype)
-> 2259     x, resids, rank, s = gufunc(a, b, rcond, signature=signature, extobj=extobj)
   2260     if m == 0:
   2261         x[...] = 0

c:\~\python\python38\lib\site-packages\numpy\linalg\linalg.py in _raise_linalgerror_lstsq(err, flag)
    107 
    108 def _raise_linalgerror_lstsq(err, flag):
--> 109     raise LinAlgError("SVD did not converge in Linear Least Squares")
    110 
    111 def get_linalg_error_extobj(callback):

LinAlgError: SVD did not converge in Linear Least Squares

To reproduce the error, please run:

from meegkit import asr
asrC = asr.ASR(sfreq=125)

And my numpy version is 1.18.5, running python==3.8.6.

nbara commented

I cannot reproduce this error in master or in #18. I'm using numpy 1.18.5 as well.

See 761d443