[SciPy-user] Weave Documentation:

Greg Novak novak at ucolick.org
Tue Jun 8 00:20:51 CDT 2004


It seems that the Weave documentation is in serious need of attention.  In 
particular, the "Binary Search" example on the web page:
http://www.scipy.org/documentation/weave/weaveusersguide.html#Binary%20search
simply fails for me, with error messages given below.  If I change the 
example code to:

        # now the C code
        code = """
               #line 42 "binary_search.py"
               int val, m, min = 0;  
               int max = seq.length() - 1;
               PyObject *py_val; 
               for(;;)
               {
                   if (max < min  ) 
                   {
                       return_val = PyInt_FromLong(-1);                   
                       break;
                   }                   
                   m =  (min + max) /2;
                   val =  py_to_int(PyList_GetItem(py_seq,m),"val"); ;
                   if (val  < t) 
                       min = m  + 1;
                   else if (val >  t)
                       max = m - 1;
                   else
                   {
                       return_val = PyInt_FromLong(m);
                       break;
                   }
               }
               """

then it works.

I'm using gcc 3.2.2.  So... what's going on?

Thanks a bunch,
Greg

Error messages from online example:
-----------------------------------
>>> c_int_binary_search([1,2,3],3)
file changed
None
running build_ext
binary_search.py: In function `PyObject* compiled_func(PyObject*, 
PyObject*)':
binary_search.py:36: `Py' undeclared (first use this function)
binary_search.py:36: (Each undeclared identifier is reported only once for 
each 
   function it appears in.)
binary_search.py:36: parse error before `::' token
binary_search.py:40: no matching function for call to `py::list::ptr()'
binary_search.py:47: parse error before `::' token
binary_search.py: In function `PyObject* compiled_func(PyObject*, 
PyObject*)':
binary_search.py:36: `Py' undeclared (first use this function)
binary_search.py:36: (Each undeclared identifier is reported only once for 
each 
   function it appears in.)
binary_search.py:36: parse error before `::' token
binary_search.py:40: no matching function for call to `py::list::ptr()'
binary_search.py:47: parse error before `::' token
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "tst.py", line 99, in c_int_binary_search
    return weave.inline(code,['seq','t'],verbose=2)
  File "/usr/lib/python2.2/site-packages/weave/inline_tools.py", line 335, 
in inline
    auto_downcast = auto_downcast,
  File "/usr/lib/python2.2/site-packages/weave/inline_tools.py", line 439, 
in compile_function
    verbose=verbose, **kw)
  File "/usr/lib/python2.2/site-packages/weave/ext_tools.py", line 340, in 
compile
    verbose = verbose, **kw)
  File "/usr/lib/python2.2/site-packages/weave/build_tools.py", line 274, 
in build_extension
    setup(name = module_name, ext_modules = [ext],verbose=verb)
  File "/usr/lib/python2.2/site-packages/scipy_distutils/core.py", line 
72, in setup
    return old_setup(**new_attr)
  File "/usr/lib/python2.2/distutils/core.py", line 157, in setup
    raise SystemExit, "error: " + str(msg)
weave.build_tools.CompileError: error: Command "g++ -DNDEBUG -O2 -g -pipe 
-march=i386 -mcpu=i686 -D_GNU_SOURCE -fPIC -fPIC 
-I/usr/lib/python2.2/site-packages/weave 
-I/usr/lib/python2.2/site-packages/weave/scxx -I/usr/include/python2.2 -c 
/home/novak/.python22_compiled/sc_8599780ae275511179a480c1a126feda1.cpp -o 
/tmp/novak/python22_intermediate/compiler_c0261050efb392e52f3c1d0d86c2137d/sc_8599780ae275511179a480c1a126feda1.o" 
failed with exit status 1




More information about the SciPy-user mailing list