[Cython] Failure with asarray(memoryview) on Python 2.4
Hi, This doesn't work on Python 2.4 (works on >= 2.5): cimport numpy as np import numpy as np def _foo(): cdef double[:] a a = np.array([1.0]) return np.asarray(a) def foo(): print _foo() Spotted when using Cython 1.6 in Scipy. Results to: Python 2.4.6 (#1, Nov 20 2010, 00:52:41) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import fail >>> fail.foo() Traceback (most recent call last): File "", line 1, in ? File "fail.pyx", line 10, in fail.foo (fail.c:1776) print _foo() File "fail.pyx", line 7, in fail._foo (fail.c:1715) return np.asarray(a) File "/usr/local/stow/python-easy-install//lib/python2.4/site-packages/numpy/core/numeric.py", line 235, in asarray return array(a, dtype, copy=False, order=order) File "stringsource", line 366, in View.MemoryView.memoryview.__getitem__ (fail.c:5975) File "stringsource", line 650, in View.MemoryView._unellipsify (fail.c:9236) TypeError: Cannot index with type '' ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
[Cython] Cython 1.6 & compilation failure on MinGW?
Hi, We ran with Scipy to a compilation failure on MinGW in Cython code: http://projects.scipy.org/scipy/ticket/1673 interpnd.c:10580: error: initializer element is not constant interpnd.c:10580: error: (near initialization for `__pyx_CyFunctionType_type.tp_call') Can be fixed like this: ... +static PyObject *__Pyx_PyCFunction_Call_wrap(PyObject *a, PyObject *b, PyObject *c) +{ +return __Pyx_PyCFunction_Call(a, b, c); +} static PyTypeObject __pyx_CyFunctionType_type = { PyVarObject_HEAD_INIT(0, 0) __Pyx_NAMESTR("cython_function_or_method"), @@ -10577,7 +10581,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { 0, 0, 0, -__Pyx_PyCFunction_Call, +__Pyx_PyCFunction_Call_wrap, 0, 0, 0, ... It's a bit surprising to me that you cannot use the function from the Python headers as a static initializer on that platform... -- Pauli Virtanen ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Failure with asarray(memoryview) on Python 2.4
On 11 June 2012 20:08, Pauli Virtanen wrote: > Hi, > > This doesn't work on Python 2.4 (works on >= 2.5): > > > cimport numpy as np > import numpy as np > > def _foo(): > cdef double[:] a > a = np.array([1.0]) > return np.asarray(a) > > def foo(): > print _foo() > > > Spotted when using Cython 1.6 in Scipy. Results to: > > Python 2.4.6 (#1, Nov 20 2010, 00:52:41) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. import fail fail.foo() > Traceback (most recent call last): > File "", line 1, in ? > File "fail.pyx", line 10, in fail.foo (fail.c:1776) > print _foo() > File "fail.pyx", line 7, in fail._foo (fail.c:1715) > return np.asarray(a) > File > "/usr/local/stow/python-easy-install//lib/python2.4/site-packages/numpy/core/numeric.py", > line 235, in asarray > return array(a, dtype, copy=False, order=order) > File "stringsource", line 366, in > View.MemoryView.memoryview.__getitem__ (fail.c:5975) > File "stringsource", line 650, in View.MemoryView._unellipsify > (fail.c:9236) > TypeError: Cannot index with type '' > > ___ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel Hey Pauli, Yeah, there was some weird bug with PyIndex_Check() not operating properly. Could you retry with the latest master? Mark ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Cython 1.6 & compilation failure on MinGW?
On 11 June 2012 20:12, Pauli Virtanen wrote: > Hi, > > We ran with Scipy to a compilation failure on MinGW in Cython code: > > http://projects.scipy.org/scipy/ticket/1673 > > interpnd.c:10580: error: initializer element is not constant > interpnd.c:10580: error: (near initialization for > `__pyx_CyFunctionType_type.tp_call') > > Can be fixed like this: > > ... > +static PyObject *__Pyx_PyCFunction_Call_wrap(PyObject *a, PyObject *b, > PyObject *c) > +{ > + return __Pyx_PyCFunction_Call(a, b, c); > +} > static PyTypeObject __pyx_CyFunctionType_type = { > PyVarObject_HEAD_INIT(0, 0) > __Pyx_NAMESTR("cython_function_or_method"), > @@ -10577,7 +10581,7 @@ static PyTypeObject __pyx_CyFunctionType_type = { > 0, > 0, > 0, > - __Pyx_PyCFunction_Call, > + __Pyx_PyCFunction_Call_wrap, > 0, > 0, > 0, > ... > > > It's a bit surprising to me that you cannot use the function from the > Python headers as a static initializer on that platform... > > -- > Pauli Virtanen > > ___ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel Thanks, could you provide a pull request? That makes it easier to merge and assign credit. ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Failure with asarray(memoryview) on Python 2.4
Hi, 11.06.2012 21:16, mark florisson kirjoitti: [clip] > Yeah, there was some weird bug with PyIndex_Check() not operating > properly. Could you retry with the latest master? Doesn't seem to work in 5a0effd0 :( Traceback (most recent call last): File "", line 1, in ? File "fail.pyx", line 10, in fail.foo (fail.c:1807) print _foo() File "fail.pyx", line 7, in fail._foo (fail.c:1747) return np.asarray(a) File "/usr/local/stow/python-easy-install//lib/python2.4/site-packages/numpy/core/numeric.py", line 235, in asarray return array(a, dtype, copy=False, order=order) File "stringsource", line 366, in View.MemoryView.memoryview.__getitem__ (fail.c:6019) File "stringsource", line 650, in View.MemoryView._unellipsify (fail.c:9199) TypeError: Cannot index with type '' Cheers, Pauli ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Cython 1.6 & compilation failure on MinGW?
11.06.2012 21:17, mark florisson kirjoitti: [clip] > Thanks, could you provide a pull request? That makes it easier to > merge and assign credit. Ok, I'll try to not only just complain :) BRB, Pauli ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Cython 1.6 & compilation failure on MinGW?
11.06.2012 21:17, mark florisson kirjoitti: [clip] > Thanks, could you provide a pull request? That makes it easier to > merge and assign credit. Ok, this one seemed to already have been fixed in Cython master. Pauli ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Failure with asarray(memoryview) on Python 2.4
11.06.2012 21:23, Pauli Virtanen kirjoitti: > Hi, > > 11.06.2012 21:16, mark florisson kirjoitti: > [clip] >> Yeah, there was some weird bug with PyIndex_Check() not operating >> properly. Could you retry with the latest master? > > Doesn't seem to work in 5a0effd0 :( [clip] Uhh, Numpy header arrayobject.h -> npy_common.h contains this #if (PY_VERSION_HEX < 0x0205) ... #undef PyIndex_Check #define PyIndex_Check(op) 0 ... which nicely overrides the fixed PyIndex_Check defined by Cython. Time to fix that, I guess. I don't see reasonable ways to work around this in Cython... Pauli ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel
Re: [Cython] Failure with asarray(memoryview) on Python 2.4
On 11 June 2012 20:55, Pauli Virtanen wrote: > 11.06.2012 21:23, Pauli Virtanen kirjoitti: >> Hi, >> >> 11.06.2012 21:16, mark florisson kirjoitti: >> [clip] >>> Yeah, there was some weird bug with PyIndex_Check() not operating >>> properly. Could you retry with the latest master? >> >> Doesn't seem to work in 5a0effd0 :( > [clip] > > Uhh, Numpy header arrayobject.h -> npy_common.h contains this > > #if (PY_VERSION_HEX < 0x0205) > ... > #undef PyIndex_Check > #define PyIndex_Check(op) 0 > ... > > which nicely overrides the fixed PyIndex_Check defined by Cython. > Time to fix that, I guess. > > I don't see reasonable ways to work around this in Cython... > > Pauli > > ___ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel Ah, thanks! Stefan and I were kind of baffled by PyIndex_Check failing, I guess we should have run cpp on our source :) ___ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel