Created
June 13, 2015 07:19
-
-
Save pijyoi/b5e29d342ace1eec9068 to your computer and use it in GitHub Desktop.
cython fused types problem with spyder user module deleter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cython cimport floating | |
def add_fused(floating [:] ain): | |
cdef int r | |
for r in range(ain.size): | |
ain[r] += 1 | |
def add_f64(double [:] ain): | |
cdef int r | |
for r in range(ain.size): | |
ain[r] += 1 | |
def add_f32(float [:] ain): | |
cdef int r | |
for r in range(ain.size): | |
ain[r] += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distutils.core import setup, Extension | |
from Cython.Build import cythonize | |
ext_module = Extension( | |
"fused", | |
["fused.pyx"]) | |
setup(ext_modules = cythonize(ext_module)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import fused | |
a = np.arange(10, dtype=np.float32) | |
b = np.arange(10, dtype=np.float64) | |
if 0: | |
fused.add_f32(a) | |
fused.add_f64(b) | |
else: | |
fused.add_fused(a) | |
fused.add_fused(b) | |
print(a) | |
print(b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment