Hi All,
I would like to request review of following PR:
https://github.com/cython/cython/pull/5386
PR is not complex and is important because of two reasons:
1. It blocks PR https://github.com/scipy/scipy/pull/18242. Hence, it will
allow us to have Cython 3 Beta in scipy which can help us test Cython 3
better (already 2 bugs were found during migration)
2. It seems it will break several libraries so I think it is better to have
it in master earlier to give users more time for fixing issues.
Thanks,
Matus
Hi All,
I am working on porting scipy to Cython3. The last missing part in order to
have a test suite is 2 tests failing [1]. When I investigated the issue, I
found out that Cython has changed the type of Exception. Consider following
example:
cimport numpy as cnp
import cython
ctypedef fused np_numeric_t:
cnp.int8_t
cnp.int16_t
cnp.int32_t
cnp.int64_t
cnp.uint8_t
cnp.uint16_t
cnp.uint32_t
cnp.uint64_t
cnp.float32_t
cnp.float64_t
cnp.longdouble_t
cnp.complex64_t
cnp.complex128_t
@cython.initializedcheck(False)
def bandwidth_c(np_numeric_t[:, ::1]A):
return
In cython 0.29.X I got following:
>>> import numpy as np
>>> zz = np.zeros([5, 5], dtype='M')
>>> import fused
>>> fused.bandwidth_c(zz)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fused.pyx", line 32, in fused.__pyx_fused_cpdef
def bandwidth_c(np_numeric_t[:, ::1]A):
TypeError: No matching signature found
And in Cython3 (master branch) I got following:
>>> import numpy as np
>>> zz = np.zeros([5, 5], dtype='M')
>>> import fused
>>> fused.bandwidth_c(zz)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "fused.pyx", line 31, in fused.__pyx_fused_cpdef
@cython.initializedcheck(False)
ValueError: cannot include dtype 'M' in a buffer
The question is does someone know why the exception changed in Cython3? I
was not able to find out. Is this a feature or is it a bug? Interestingly,
I was not able to replicate this behaviour in simple fused types containing
basic types (int, float etc...).
Thanks,
Matus
[1] https://github.com/scipy/scipy/pull/18242#issuecomment-1517459666