Not sure about the answers to your questions in general, but I thought you
might be able to cheat by using fused types. Unfortunately this seems not
to work:
In [32]: %%cython
...: cimport cython
...:
...: from cpython cimport bool
...:
...: import numpy as np
...: cimport numpy as np
...:
...: ctypedef np.float64_t float64_t
...:
...: ctypedef fused myarray:
...: float64_t[:,:]
...: float64_t[:,:,:]
...: #
...:
...: cpdef myarray nop(myarray array):
...: return array
...:
In [33]: nop(rand(2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-33-bbba0b03d22e> in <module>()
----> 1 nop(rand(2))
f.pyd in f.__pyx_fused_cpdef (f.c:2503)()
TypeError: No matching signature found
In [34]: nop(rand(2,2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-34-fa44702cf241> in <module>()
----> 1 nop(rand(2,2))
f.pyd in f.__pyx_fused_cpdef (Cf.c:2503)()
TypeError: No matching signature found
In [35]: nop(rand(2,2,2))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-35-c6b24e4d9bf8> in <module>()
----> 1 nop(rand(2,2,2))
f.pyd in f.__pyx_fused_cpdef f.c:2503)()
TypeError: No matching signature found
In [36]:
Is there any reason why this shouldn't work or is this a bug?
-Dave