[Numpy-discussion] Beginer question about Boost Python Numeric

Yongning Zhu yongningbrg at gmail.com
Fri Jun 18 23:17:28 EDT 2010


Hi,

I am new to boost python, thanks for the list, and hopefully, I will
find some one to help me.
I am adding the boost python example:

#include <boost/python/numeric.hpp>
#include <boost/python/tuple.hpp>
// sets the first element in a 2d numeric array
void set_first_element(::boost::python::numeric::array& y, float value)
{
    y[::boost::python::make_tuple(0,0)] = value;
}

into quickstart project, and I belive it compiles and run without this function.

When I add this function, in python, I did:

a=array([1.])
set_first_element(a,3.)

and come up with the following error message:

Boost.Python.ArgumentError: Python argument types in
    extending.set_first_element(numpy.ndarray, float)
did not match C++ signature:
    set_first_element(boost::python::numeric::array {lvalue}, float)

Could any one please help me with what's wrong?

Thanks in advance!

Yong



More information about the NumPy-Discussion mailing list