You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running this code under Python 3.8 produced the following traceback. Note that it seems that max_n=10**7 is related to this bug, because it didn't happen before I used that.
Traceback (most recent call last):
File "heapz.py", line 115, in <module>
best, others = big_o.big_o(heapify, data_generator_heapify, max_n=10**6)
File "C:\Program Files\Python38\lib\site-packages\big_o\big_o.py", line 157, in big_o
return infer_big_o_class(ns, time, classes, verbose=verbose)
File "C:\Program Files\Python38\lib\site-packages\big_o\big_o.py", line 97, in infer_big_o_class
residuals = inst.fit(ns, time)
File "C:\Program Files\Python38\lib\site-packages\big_o\complexities.py", line 38, in fit
return residuals[0]
IndexError: index 0 is out of bounds for axis 0 with size 0
The text was updated successfully, but these errors were encountered:
I did some debugging and testing. Like you mentioned this happens at larger max_n, as in the error message it also happens with max_n=10**7. I tried remove different classes and I think the error seems to occur specifically for the Cubic class, for others not. If you follow the error precisely, you see that coeff, residuals, rank, s = np.linalg.lstsq(x, y, rcond=-1) (here) we get an empty numpy vector for the residual for the Cubic case when max_n is large, the reason being that the rank of x is too small (see the relevant numpy docs) and thus numpy gives one an empty array. I think you should be able to compute the residual doing something like np.linalg.norm(y - x @ coeff) which would still work in this case, however, doing that give different residual from numpy.
Why this specifically happens for the Cubic case, I cannot tell you. I tried this also for another case that I made up and again for large max_n specifically the Cubic case has this problem.
Running this code under Python 3.8 produced the following traceback. Note that it seems that
max_n=10**7
is related to this bug, because it didn't happen before I used that.The text was updated successfully, but these errors were encountered: