Моя функция numba:
import numpy as np
from numba import njit
import numba
min_sample_length = 0
step = 1
subset = np.random.rand(4800)
@njit
def numba_fun():
max_abs_t_value = -np.inf # Maximum abs t-value of b_1 coefficient among l values
max_t_value_index = None # Index with maximum t-value
for forward_window in np.arange(min_sample_length, subset.shape[0], step):
y = subset[:forward_window] # y{t}:y_{t+l}
X = np.ones((y.shape[0], 2))
X[:, 1] = np.arange(y.shape[0])
xy = X.transpose() @ y
xx = X.transpose() @ X
xx_inv = np.linalg.inv(xx)
return xx_inv# max_t_value_index
numba_fun()
возвращает ошибку:
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of Function() with argument(s) of type(s): (array(float64, 2d, C))
* parameterized
In definition 0:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
Type of #4 arg mismatch: i1 != i32
File "..\..\..\..\..\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py", line 800:
def inv_impl(a):
if F_layout:
acpy = np.copy(a)
^
[1] During: lowering "$52.4 = call $52.2(a, func=$52.2, args=[Var(a, C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py (792))], kws=(), vararg=None)" at C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py (800)
raised from C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\six.py:669
In definition 1:
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
Type of #4 arg mismatch: i1 != i32
File "..\..\..\..\..\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py", line 800:
def inv_impl(a):
if F_layout:
acpy = np.copy(a)
^
[1] During: lowering "$52.4 = call $52.2(a, func=$52.2, args=[Var(a, C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py (792))], kws=(), vararg=None)" at C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\targets\linalg.py (800)
raised from C:\Users\Mislav\AppData\Roaming\Python\Python37\site-packages\numba\six.py:669
This error is usually caused by passing an argument of a type that is unsupported by the named function.
[1] During: resolving callee type: Function()
[2] During: typing of call at c:\Users\Mislav\Documents\GitHub\trademl\trademl\modeling\sell_fear.py (3)
File "c:\Users\Mislav\Documents\GitHub\trademl\trademl\modeling\sell_fear.py", line 3:
def inv_nla_jit(A):
return np.linalg.inv(A)
^
[1] During: resolving callee type: type(CPUDispatcher())
[2] During: typing of call at c:\Users\Mislav\Documents\GitHub\trademl\trademl\modeling\sell_fear.py (20)
[3] During: resolving callee type: type(CPUDispatcher())
[4] During: typing of call at c:\Users\Mislav\Documents\GitHub\trademl\trademl\modeling\sell_fear.py (20)
File "c:\Users\Mislav\Documents\GitHub\trademl\trademl\modeling\sell_fear.py", line 20:
def numba_fun():
xx = X.transpose() @ X
xx_inv = inv_nla_jit(xx)
^
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.
To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html
For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile
If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.
To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/latest/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/latest/reference/numpysupported.html
For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile
If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new
Проблема в numpy обратной функции np.linalg.inv
, но в документации по numba говорится, что она поддерживается numpy функция для функции нумба.