Skip to content

Instantly share code, notes, and snippets.

@pijyoi
Created June 13, 2015 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pijyoi/b5e29d342ace1eec9068 to your computer and use it in GitHub Desktop.
Save pijyoi/b5e29d342ace1eec9068 to your computer and use it in GitHub Desktop.
cython fused types problem with spyder user module deleter
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
from distutils.core import setup, Extension
from Cython.Build import cythonize
ext_module = Extension(
"fused",
["fused.pyx"])
setup(ext_modules = cythonize(ext_module))
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