[SciPy-user] Can someone shed light on this simple weave inline test

Michael ODonnell odonnems at yahoo.com
Sat Dec 8 23:00:52 EST 2007


I am trying to do some testing and I can not get the following test to work. The code is compiled and the values returned are:
>>> <weave: compiling>
creating c:\temp\Michael\python25_intermediate\compiler_12e837eb1ea3ab5199fbcc0e83015e3f
0 0 0 0 0 0 0 0 0 0

I am able to return an array using a similar method, but this is not working for some reason. 

Is there any documentation that may help me with passing multiple variables and arrays?


Thanks,
Michael


winx = 10
winy = 10
kernel = numpy.random.randint(1,10, (10,10)) #Values between 0 and 10 for an array with 10 x 10 shape
#Now make it floating
#kernel * 1.0
nullValue = -10000
ND=NNW=WNW=WSW=SSW=SSE=ESE=ENE=NNE=Flat=0

code = r"""
        #include "Python.h"
        //int ND, NNW, WNW, WSW, SSW, SSE, ESE, ENE, NNE, Flat;
        
        //Cycle through kernel and calculate the frequency of each compass direction           
        //Change row in kernel
        for (int k=0; k<winy; k++) {
            //Change column in kernel
            for (int l=0; l<winx; l++) {
                if (kernel(k,l) == nullValue)  //or written as numpy.take(kernel, [0]) == [0]
                    ND++;  //Null Data so not evaluating; or written as ND++ in C++
                else if (kernel(k,l) == 1)
                    NNW++;
                else if (kernel(k,l) == 2)
                    WNW++;
                else if (kernel(k,l) == 3)
                    WSW++;
                else if (kernel(k,l) == 4)
                    SSW++;
                else if (kernel(k,l) == 5)
                    SSE++;
                else if (kernel(k,l) == 6)
                    ESE++;
                else if (kernel(k,l) == 7)
                    ENE++;
                else if (kernel(k,l) == 8)
                    NNE++;
                else if (kernel(k,l) == 9)
                    Flat++;
            }
        }
        """
weave.inline(code,['winy', 'winx', 'nullValue', 'kernel', 'ND', 'NNW', 'WNW', 'WSW', 'SSW', 'SSE', 'ESE', 'ENE', 'NNE', 'Flat'], type_converters=converters.blitz, compiler='gcc')

print ND, NNW, WNW, WSW,SSW, SSE, ESE, ENE, NNE, Flat





      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20071208/b5045a11/attachment.html>


More information about the SciPy-User mailing list