Python crash after using weave inline
Soren
soren.skou.nielsen at gmail.com
Wed Apr 18 16:21:36 EDT 2007
On Apr 18, 10:07 pm, Peter Wang <misterw... at gmail.com> wrote:
> Soren,
>
> For future reference, you might want to direct weave-related questions
> to the scipy-u... at scipy.org mailing list.
>
> > def cartPolFast(xlen, ylen, x_c, y_c):
>
> > res = zeros((xlen,ylen))
>
> > code = """
> > {
> > int xlen, ylen, x_c, y_c;
>
> This line is unnecessary, because weave exposes those variables inside
> the local scope of your code. This also makes the braces at the top
> and bottom of the code block unnecessary.
>
> > for( x = 0; x == xlen; x++)
> > for( y = 0; y == ylen; y++)
> > rel_x = x-x_c;
> > rel_y = y_c-y;
>
> > res(x,y) = rel_y*rel_y;
> > }
>
> Two things:
> 1. You need to put curly braces around the three lines of the inner
> loop.
> 2. You need to change "x == xlen" and "y == ylen" to "x < xlen" and "y
> < ylen".
>
> I made these modifications to your code and it runs fine on my machine
> (macbook pro, OS 10.4, scipy 0.5.2.dev2314).
>
> -peter
Thanks alot Peter!
I'm a bit rusty on the C! :)
Soren
More information about the Python-list
mailing list