[SciPy-dev] How to use weave.ext_function() ?
Matthieu Brucher
matthieu.brucher at gmail.com
Wed Oct 10 17:07:58 EDT 2007
Hi again,
I'm trying to put together a simple sample for the use of weave.ext_function.
I was first amazed by the lack of the support_code argument, one has to go
through customize.
Here is the code I want to use :
#!/usr/bin/python
import scipy.weave
support_code="""
#include <numeric>
template<class Array>
float somme(const Array& array)
{
return std::accumulate(array.begin(), array.end(), ++array);
}
"""
code="""
return_val=somme(a)
"""
module = scipy.weave.ext_module("weave_ext_module")
fonction = scipy.weave.ext_function("somme", code, ['a'], type_converters=
scipy.weave.converters.blitz)
fonction.customize.add_support_code(support_code)
module.add_function(fonction)
module.compile()
import weave_ext_module
print dir(weave_ext_module)
import numpy
a = numpy.array(((1., 2., 3.), (4., 5., 6.)))
print weave_ext_module(a)
print weave_ext_module(a=a)
When it tries to compile the code, I have a KeyError in ext_tools line 421
for the variable a.
I didn't have a problem with inline or blitz, so why this error occurs there
?
Matthieu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20071010/62cb3b8a/attachment.html>
More information about the SciPy-Dev
mailing list