Vineet Jain | 1 Oct 20:17 2010
Picon

[Cython] cython compiler crash

Last night while trying out the following cython example:

    http://dpinte.wordpress.com/2010/04/22/interfacing-ta-lib-with-cython/

I got the following crash in the cython compiler (cython version 0.13):

Compiler crash traceback from this point on:
  File "Visitor.py", line 179, in
Cython.Compiler.Visitor.TreeVisitor.visitchild
(/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:3407)
  File "Visitor.py", line 28, in
Cython.Compiler.Visitor.BasicVisitor.visit
(/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:1178)
  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
Cython/Compiler/Buffer.py",
line 106, in visit_FuncDefNode
    self.handle_scope(node, node.local_scope)
  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
Cython/Compiler/Buffer.py",
line 61, in handle_scope
    if entry.type.dtype.is_ptr:
AttributeError: 'NoneType' object has no attribute 'is_ptr'
building 'talib' extension

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC
-I/usr/local/lib/python2.6/dist-packages/numpy/core/include
-I/usr/local/include/ta-lib/ -I/usr/include/python2.6 -c talib.c -o
build/temp.linux-x86_64-2.6/talib.o
(Continue reading)

Vineet Jain | 1 Oct 20:18 2010
Picon

[Cython] cython types for numpy array types

I'm trying to get my head around how to let cython know the type of
the numpy array. I've seen a few examples with:

from cimport numpy as np
p.ndarray[np.float_t, mdim=1]

while numpy's documentation has float64 float32, from the following
link. Is there a mapping between numpy types and cython numpy types?

    http://docs.scipy.org/doc/numpy/user/basics.types.html

Thanks,

Vineet
Matěj Laitl | 1 Oct 20:47 2010
Picon

Re: [Cython] cython types for numpy array types

On 1. 10. 2010 Vineet Jain wrote:
> I'm trying to get my head around how to let cython know the type of
> the numpy array. I've seen a few examples with:
> 
> from cimport numpy as np
> p.ndarray[np.float_t, mdim=1]
> 
> while numpy's documentation has float64 float32, from the following
> link. Is there a mapping between numpy types and cython numpy types?

Yes, look at numpy.pxd and ctypedefs there (distributed with cython, for me 
for example in /usr/lib/python2.6/site-packages/Cython/Includes/numpy.pxd)

	Matěj
_______________________________________________
Cython-dev mailing list
Cython-dev <at> codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev
Lisandro Dalcin | 1 Oct 22:36 2010
Picon

Re: [Cython] cython compiler crash

On 1 October 2010 15:17, Vineet Jain <vinjvinj <at> gmail.com> wrote:
> Last night while trying out the following cython example:
>
>    http://dpinte.wordpress.com/2010/04/22/interfacing-ta-lib-with-cython/
>
> I got the following crash in the cython compiler (cython version 0.13):
>
> Compiler crash traceback from this point on:
>  File "Visitor.py", line 179, in
> Cython.Compiler.Visitor.TreeVisitor.visitchild
> (/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:3407)
>  File "Visitor.py", line 28, in
> Cython.Compiler.Visitor.BasicVisitor.visit
> (/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:1178)
>  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
> Cython/Compiler/Buffer.py",
> line 106, in visit_FuncDefNode
>    self.handle_scope(node, node.local_scope)
>  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
> Cython/Compiler/Buffer.py",
> line 61, in handle_scope
>    if entry.type.dtype.is_ptr:
> AttributeError: 'NoneType' object has no attribute 'is_ptr'
> building 'talib' extension
>
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
> -Wstrict-prototypes -fPIC
> -I/usr/local/lib/python2.6/dist-packages/numpy/core/include
> -I/usr/local/include/ta-lib/ -I/usr/include/python2.6 -c talib.c -o
> build/temp.linux-x86_64-2.6/talib.o
(Continue reading)

Vineet Jain | 1 Oct 23:00 2010
Picon

Re: [Cython] cython compiler crash

Problem was a typo:

cdef np.ndarray[np, ndim=1] outreal = numpy.zeros_like(inreal)

should have been:

cdef np.ndarray[np.float_t, ndim=1] outreal = numpy.zeros_like(inreal)

Which caused the compiler to crash.

On Fri, Oct 1, 2010 at 4:36 PM, Lisandro Dalcin <dalcinl@...> wrote:
> On 1 October 2010 15:17, Vineet Jain <vinjvinj@...> wrote:
>> Last night while trying out the following cython example:
>>
>>    http://dpinte.wordpress.com/2010/04/22/interfacing-ta-lib-with-cython/
>>
>> I got the following crash in the cython compiler (cython version 0.13):
>>
>> Compiler crash traceback from this point on:
>>  File "Visitor.py", line 179, in
>> Cython.Compiler.Visitor.TreeVisitor.visitchild
>> (/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:3407)
>>  File "Visitor.py", line 28, in
>> Cython.Compiler.Visitor.BasicVisitor.visit
>> (/tmp/easy_install-fEGaFj/Cython-0.13/Cython/Compiler/Visitor.c:1178)
>>  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
>> Cython/Compiler/Buffer.py",
>> line 106, in visit_FuncDefNode
>>    self.handle_scope(node, node.local_scope)
>>  File "/usr/local/lib/python2.6/dist-packages/Cython-0.13-py2.6-linux-x86_64.egg/
(Continue reading)

Lisandro Dalcin | 1 Oct 23:05 2010
Picon

Re: [Cython] cython compiler crash

On 1 October 2010 18:00, Vineet Jain <vinjvinj@...> wrote:
> Problem was a typo:
>
> cdef np.ndarray[np, ndim=1] outreal = numpy.zeros_like(inreal)
>
> should have been:
>
> cdef np.ndarray[np.float_t, ndim=1] outreal = numpy.zeros_like(inreal)
>
> Which caused the compiler to crash.
>

OK, now all is clear. Anyway, Cython should not crash. We should fix this.

--

-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169
Robert Bradshaw | 3 Oct 08:51 2010

Re: [Cython] cython compiler crash

On Fri, Oct 1, 2010 at 2:05 PM, Lisandro Dalcin <dalcinl@...> wrote:
> On 1 October 2010 18:00, Vineet Jain <vinjvinj@...> wrote:
>> Problem was a typo:
>>
>> cdef np.ndarray[np, ndim=1] outreal = numpy.zeros_like(inreal)
>>
>> should have been:
>>
>> cdef np.ndarray[np.float_t, ndim=1] outreal = numpy.zeros_like(inreal)
>>
>> Which caused the compiler to crash.
>>
>
> OK, now all is clear. Anyway, Cython should not crash. We should fix this.

Fixed. http://trac.cython.org/cython_trac/ticket/579

When trying to write a test case, I noticed that buffers are not very
good at continuing once they hit an error... This should be improved.

- Robert
Vineet Jain | 3 Oct 15:14 2010
Picon

[Cython] Cython distutils does not recompile files if a pxd file changes.

Not a big deal, but thought I would just mention it. If a pxd file
changes and you run setup.py build it will not rebuild the package.
You have to change the corresponding pyx file for the module to be
rebuilt.

Vineet
Stéfan van der Walt | 3 Oct 20:29 2010
Picon
Picon

[Cython] Unroll power expressions?

Hi all,

I got bitten tonight by the following behaviour:

x**4

translates to

  __pyx_r = (pow(__pyx_v_x, 4.0);

which, in my case, is roughly 10x slower than x*x*x*x.

Maybe a neat feature for the new type inferencer would be to
automatically expand the power operator for integer powers below a
certain threshold?

Regards
Stéfan
Matěj Laitl | 3 Oct 20:59 2010
Picon

Re: [Cython] Cython distutils does not recompile files if a pxd file changes.

On 3. 10. 2010 Vineet Jain wrote:
> Not a big deal, but thought I would just mention it. If a pxd file
> changes and you run setup.py build it will not rebuild the package.
> You have to change the corresponding pyx file for the module to be
> rebuilt.

+1

The reason behind this is that cython.Distutils' build_ext does it's own "is-
source-newer-than-target" checks. It doesn't parse pyx file for dependencies, 
but it relies on you specifying all dependencies in Extension source files 
declaration, e.g:

setup(... ext_modules(Extension('module', ['module.pyx', 'module.pxd', 
'dependency.pxd'])))

But I also find it suboptimal. Cython distutils can be changed to use cython 
compiler to do dependency mtime checking, I may post a patch in a couple
of days.

	Matěj
_______________________________________________
Cython-dev mailing list
Cython-dev <at> codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Gmane