I am trying to execute Cythonize this code ( GDTest.pyx):
cimport numpy as np
import numpy as np
DTYPE = np.float64
ctypedef np.float64_t DTYPE_t
def GenerateDirich(np.ndarray alpha):
assert alpha.dtype==np.float64
cdef double fuzz = pow(10,-200)
cdef np.ndarray g=np.zeros((alpha.shape[0],alpha.shape[1]), dtype=DTYPE)
cdef np.ndarray gSum
g[:,:] = np.maximum(np.random.gamma(alpha[:,:]),fuzz)
gSum = np.sum(g,axis=1)
gSum = gSum[:,np.newaxis]
g = np.copy(g/(np.kron(np.ones((1,alpha.shape[1])),gSum)))
g=np.copy(g/np.repeat(gSum,alpha.shape[1]).reshape((gSum.shape[0],alpha.shape[1])))
return g
Here is mine setup.py:
from distutils.core import setup
from Cython.Build import cythonize
import numpy
setup(
ext_modules=cythonize('GDTest.pyx'),
include_dirs=[numpy.get_include()]
)
When I run the line:
python setup.py -c mingw64 --inplace
I get a bunch of warnings (legacy numpy APIs and a few related ones _Pyx_RaiseTooManyValuesError), but then it creates GDTest.pyd. When I try to import it, I get an error message:
ImportError:DLL Load Failed: A dynamic link library (DLL) initialization routine failed.
I launched a walking walking element, and this is what he listed as missing:
API-MS-WIN-CORE-KERNEL32-PRIVATE-L1-1-1.DLL
API-MS-WIN-CORE-PRIVATEPROFILE-L1-1-1.DLL
API-MS-WIN-SERVICE-PRIVATE-L1-1-1.DLL
MSVCR90.DLL
API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL
IESHIMS.DLL
It is strange that if I try to import it a second time ( import GDTest), this will work. Any thoughts on how to fix this problem?
Thank!