You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using numpy's C types for ufunc declarations raises a very long error.
Compiling /home/mnoethe/test/cython/test_numpy_ufunc.pyx because it changed.
[1/1] Cythonizing /home/mnoethe/test/cython/test_numpy_ufunc.pyx
Error compiling Cython file:
------------------------------------------------------------
...
from stdlib.stdint import int64_t
np.import_array()
@cython.ufunc
cdef np.int64_t add_one(np.int64_t x):
^
------------------------------------------------------------
test_numpy_ufunc.pyx:9:5: Type 'int64_t' cannot be used as a ufunc argument
...
Code to reproduce the behaviour:
#cython: language_level=3
cimport cython
cimport numpy as np
np.import_array()
@cython.ufunc
cdef np.int64_t add_one(np.int64_t x):
return x +1
Expected behaviour
Numpy ufuncs work with numpy data types.
OS
Linux, Ubuntu 22.04
Python version
3.11
Cython version
cython 3.0.10 py311hb755f60_0 conda-forge
Additional context
No response
The text was updated successfully, but these errors were encountered:
Thanks for the report. It's good to know what people are trying this and finding the obvious deficiencies :-)
It's slightly harder than it looks. Cython doesn't actually know a lot about integer typedefs - mostly just that it's "some integer" and whether it's signed or not. However, it needs to tell Numpy exactly what type is actually being used. So it either needs some special-casing for these Numpy typedefs, or it needs a clever runtime mechanism to work out what to tell Numpy.
Describe the bug
Using numpy's C types for ufunc declarations raises a very long error.
Code to reproduce the behaviour:
Expected behaviour
Numpy ufuncs work with numpy data types.
OS
Linux, Ubuntu 22.04
Python version
3.11
Cython version
cython 3.0.10 py311hb755f60_0 conda-forge
Additional context
No response
The text was updated successfully, but these errors were encountered: