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
[BUG] ctuple declaration on inherited membed function when parent class imported .pxd yields "Signature not compatible with previous declaration" error
#6231
Open
raffienficiaud opened this issue
Jun 7, 2024
· 0 comments
When we declare a class that derives from another class, and some member functions are inherited, the return type of the inherited member does not accept a declaration as a ctuple. In that case cythonize returns an error indicating
Signature not compatible with previous declaration
It works perfectly with simpler types that do not have a parenthesis (such as tuple, double...) and it also works when the parent and child class are within the same .pyx file.
Code to reproduce the behaviour:
The following does not work parent.pxd
# cython: language_level=3
cdef class Parent:
cpdef (double, double) func(self, double[:] a, double[:] b)
and child.pyx
# cython: language_level=3from parent cimport Parent
cdef class Child(Parent):
cpdef (double, double) func(self, double[:] a, double[:] b):
return0,1
The following works:
parent.pxd
# cython: language_level=3
cdef class Parent:
cpdef tuple func(self, double[:] a, double[:] b)
and child.pyx
# cython: language_level=3from parent cimport Parent
cdef class Child(Parent):
cpdef tuple func(self, double[:] a, double[:] b):
return0,1
The following works:
child.pxd # note here this is "child.pxd" and not "parent.pxd"
# cython: language_level=3
cdef class Parent:
cpdef (double, double) func(self, double[:] a, double[:] b)
and child.pyx
# cython: language_level=3
cdef class Parent:
cpdef (double, double) func(self, double[:] a, double[:] b):
pass
cdef class Child(Parent):
cpdef (double, double) func(self, double[:] a, double[:] b):
return0,1
Expected behaviour
The return type of the inherited member function can always be ctuple even if/when we are spanning several cython modules.
OS
No response
Python version
3.11
Cython version
3.0.10
Additional context
The command for running is simply cythonize child.pyx
The text was updated successfully, but these errors were encountered:
Describe the bug
When we declare a class that derives from another class, and some member functions are inherited, the return type of the inherited member does not accept a declaration as a
ctuple
. In that casecythonize
returns an error indicatingIt works perfectly with simpler types that do not have a parenthesis (such as
tuple
,double
...) and it also works when the parent and child class are within the same.pyx
file.Code to reproduce the behaviour:
The following does not work
parent.pxd
and
child.pyx
The following works:
parent.pxd
and
child.pyx
The following works:
child.pxd
# note here this is "child.pxd" and not "parent.pxd"and
child.pyx
Expected behaviour
The return type of the inherited member function can always be
ctuple
even if/when we are spanning several cython modules.OS
No response
Python version
3.11
Cython version
3.0.10
Additional context
The command for running is simply
cythonize child.pyx
The text was updated successfully, but these errors were encountered: