I am doing a project that needs this library (pylibol). link: https://github.com/billhhh/pylibol. When i build setup.py,it shows C method 'get_weight' not previously declared in definition part of extension type 'SOL'.
> Error compiling Cython file:
> ------------------------------------------------------------ ...
> dict: mapping of string to string
> """
> params = dict()
> sol_GetModelParameters(self._c_model, get_parameter, <void*>params)
> return params
> cpdef np.ndarray[float, ndim=1, mode="c"] get_weight(self, cls_id=0):
> ^
> ------------------------------------------------------------
>
> python/pysol.pyx:141:10: C method 'get_weight' not previously declared
> in definition part of extension type 'SOL'
The problem is happened in pysol.pyx. So i checked pysol.pyx and add cdef get_weight in pysol.pdx.
pysol.pyx:
def get_params(self):
"""Get Model Parameters
Returns
-------
dict: mapping of string to string
"""
params = dict()
sol_GetModelParameters(self._c_model, get_parameter, <void*>params)
return params
cpdef np.ndarray[float, ndim=1, mode="c"] get_weight(self, cls_id=0):
"""Get Model Weight,
input cls_id: the id of classifier, in range 0 to cls_num-1
output an numpy array of classifier for the cls_id 's class.
for binary classifier, cls_id is 0 and cls_num=1
"""
d=sol_Getw_dime(self._c_model, cls_id)
cdef np.ndarray[float, ndim=1, mode="c"] w = np.zeros((d,),dtype=np.float32)
sol_Getw(self._c_model, cls_id,&w[0])
return w
pysol.pdx:
cdef class SOL:
cdef void* _c_model
cdef void* _c_data_iter
cdef const char* algo
cdef int class_num
cdef bint verbose
cdef get_weight
But this is happened:
AttributeError: 'PyObjectType' object has no attribute 'exception_check'
any idea why this happened? I'm working on ubuntu and using python 2.7.