Hi, it looks like no-one replied to is so far, so here's a response.
Pauli Virtanen, 18.03.2014 23:56: > Here are the fused types + memoryview signature resolution failures I > promised earlier (Cython 0.20.1): > > > (A) > > TypeError: No matching signature > > ----------------------------- asd.pyx > cimport numpy as cnp > > ctypedef fused value_t: > cnp.float32_t > cnp.float64_t > > cpdef foo(value_t x): > pass > ----------------------------- quux.py > import numpy as np > import asd > asd.foo(np.float32(1.0)) > ----------------------------- I don't actually know how NumPy represents its types at the Python level, but my guess is that it would be tricky to match these two without teaching Cython itself something about NumPy (and how it wraps basic C types here). I'd rather like to avoid that and live with the above. > (B) > > ValueError: Buffer dtype mismatch, expected 'int64_t' but got 'double' > > ----------------------------- asd.pyx > cimport numpy as cnp > > ctypedef fused idx_t: > cnp.int32_t > cnp.int64_t > > ctypedef fused value_t: > cnp.int64_t > cnp.float64_t > > cpdef foo(idx_t[:,:] i, idx_t[:,:] j, value_t[:,:] x): > pass > ----------------------------- quux.py > import numpy as np > import asd > i = np.zeros((3, 3), np.int64) > j = np.zeros((3, 3), np.int64) > x = np.zeros((3, 3), np.float64) > asd.foo(i, j, x) > ----------------------------- This looks like a bug to me at first sight. > (C) > > Then some nasty platform-dependent failures: > > https://github.com/scipy/scipy/issues/3461 > > The relevant code is: > > https://github.com/scipy/scipy/blob/master/scipy/sparse/_csparsetools.pyx#L202 > > The code looks nothing special. However, call to `lil_fancy_get` fails > with "TypeError: No matching signature found" when the inputs have types > > <class 'int'> <class 'int'> <class 'numpy.ndarray'> > <class 'numpy.ndarray'> <class 'numpy.ndarray'> <class 'numpy.ndarray'> > <class 'numpy.ndarray'> <class 'numpy.ndarray'> > > with ndarray dtypes: object object object object int32 int32 > > The failure occurs only on Christoph Gohlke's Win64 build, but not on > Linux/OSX/MINGW32. This sounds like some integer size combination > issue, but I'm far from sure. > > Unfortunately, I'm not easily able to isolate/understand what's going > wrong here. Generally speaking, I think that the signature matching algorithm has some room for improvements, especially the one that matches Python signatures at runtime. We should take a look at how other implementations do this dispatch. There are multiple "generic functions" implementations for Python that do similar things. Stefan _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel