Numba TypingError: No implementation of function Function(<intrinsic exception_match>) found for signature
Numba TypingError: No implementation of function Function(<intrinsic exception_match>) found for signature
我在使用 numba
时面对 TypingError
。
我的函数在没有 @jit(nopython=True)
的情况下工作正常,但是有了它,它会引发 TypingError
。
错误
TypingError: No implementation of function Function(<intrinsic exception_match>) found for signature:
exception_match(none, ValueError)
There are 2 candidate implementations:
- Of which 2 did not match due to:
Intrinsic in function 'exception_match': File: numba\core\unsafe\eh.py: Line 47.
With argument(s): '(none, ValueError)':
Rejected as the implementation raised a specific error:
UnsupportedError: Exception matching is limited to <class 'Exception'>
raised from C:\Users\Admin\anaconda3\envs\env\lib\site-packages\numba\core\unsafe\eh.py:55
During: resolving callee type: Function(<intrinsic exception_match>)
During: typing of call at <ipython-input-19-6b44dd15c90f> (6)
代码
import numpy as np
from math import factorial
from numba import jit
import pandas as pd
@jit(nopython=True)
def savitzky_golay(y, window_size, order, deriv=0, rate=1):
try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
except ValueError :
raise ValueError("window size & order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
raise TypeError("window_size size must be a positive odd number")
if window_size < order + 2:
raise TypeError("window_size is too small for the polynomials order")
order_range = range(order+1)
half_window = (window_size -1) // 2
b = np.mat([[k**i for i in order_range] for k in range(-half_window,
half_window+1)])
m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv)
firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
y = np.concatenate((firstvals, y, lastvals))
return np.convolve( m[::-1], y, mode='valid')
yaw = np.array(pd.read_csv('D:\datasets\df.csv')['yaw'])
sg_yaw = savitzky_golay(yaw , window_size =3 , order = 1, deriv=0, rate=1)
留言
UnsupportedError: Exception matching is limited to <class 'Exception'>
表示您必须使用 Exception
,而不是其派生的 classes 之一。
复制自 docs:
try .. except
结构得到部分支持。支持以下形式:
捕获所有异常的 bare except:
try:
...
except:
...
在 except 子句中完全使用异常 class:
try:
...
except Exception:
...
我在使用 numba
时面对 TypingError
。
我的函数在没有 @jit(nopython=True)
的情况下工作正常,但是有了它,它会引发 TypingError
。
错误
TypingError: No implementation of function Function(<intrinsic exception_match>) found for signature:
exception_match(none, ValueError)
There are 2 candidate implementations:
- Of which 2 did not match due to:
Intrinsic in function 'exception_match': File: numba\core\unsafe\eh.py: Line 47.
With argument(s): '(none, ValueError)':
Rejected as the implementation raised a specific error:
UnsupportedError: Exception matching is limited to <class 'Exception'>
raised from C:\Users\Admin\anaconda3\envs\env\lib\site-packages\numba\core\unsafe\eh.py:55
During: resolving callee type: Function(<intrinsic exception_match>)
During: typing of call at <ipython-input-19-6b44dd15c90f> (6)
代码
import numpy as np
from math import factorial
from numba import jit
import pandas as pd
@jit(nopython=True)
def savitzky_golay(y, window_size, order, deriv=0, rate=1):
try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
except ValueError :
raise ValueError("window size & order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
raise TypeError("window_size size must be a positive odd number")
if window_size < order + 2:
raise TypeError("window_size is too small for the polynomials order")
order_range = range(order+1)
half_window = (window_size -1) // 2
b = np.mat([[k**i for i in order_range] for k in range(-half_window,
half_window+1)])
m = np.linalg.pinv(b).A[deriv] * rate**deriv * factorial(deriv)
firstvals = y[0] - np.abs( y[1:half_window+1][::-1] - y[0] )
lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
y = np.concatenate((firstvals, y, lastvals))
return np.convolve( m[::-1], y, mode='valid')
yaw = np.array(pd.read_csv('D:\datasets\df.csv')['yaw'])
sg_yaw = savitzky_golay(yaw , window_size =3 , order = 1, deriv=0, rate=1)
留言
UnsupportedError: Exception matching is limited to <class 'Exception'>
表示您必须使用 Exception
,而不是其派生的 classes 之一。
复制自 docs:
try .. except
结构得到部分支持。支持以下形式:
捕获所有异常的 bare except:
try: ... except: ...
在 except 子句中完全使用异常 class:
try: ... except Exception: ...