From matusvalo at gmail.com Sun Apr 23 07:14:08 2023 From: matusvalo at gmail.com (matus valo) Date: Sun, 23 Apr 2023 13:14:08 +0200 Subject: [Cython] fused type error changed in Cython 3 Message-ID: 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 "", line 1, in 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 "", line 1, in 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dw-git at d-woods.co.uk Sun Apr 23 07:54:35 2023 From: dw-git at d-woods.co.uk (da-woods) Date: Sun, 23 Apr 2023 12:54:35 +0100 Subject: [Cython] fused type error changed in Cython 3 In-Reply-To: References: Message-ID: <0bcedf9f-e03e-756e-6f22-66e346b10c66@d-woods.co.uk> Hi Matus, I made a change to optimize dispatch of fused memoryview types. I suspect that's inadvertently caused the change. I have a reasonable idea what needs to be fixed, but would need to investigate properly. I don't think it's an intended change. David On 23/04/2023 12:14, matus valo wrote: > 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 "", line 1, in > ? 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 "", line 1, in > ? 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 > > > > _______________________________________________ > cython-devel mailing list > cython-devel at python.org > https://mail.python.org/mailman/listinfo/cython-devel -------------- next part -------------- An HTML attachment was scrubbed... URL: From matusvalo at gmail.com Fri Apr 28 02:10:03 2023 From: matusvalo at gmail.com (matus valo) Date: Fri, 28 Apr 2023 08:10:03 +0200 Subject: [Cython] PR review request Message-ID: 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: