[Numpy-discussion] Beginer question about Boost Python Numeric

Yongning Zhu yongningbrg@gmail....
Sat Jun 19 13:07:10 CDT 2010


Hi,

I think I figured out by using
numeric::array::set_module_and_type( "numpy", "ndarray");
thanks!

yong

On Fri, Jun 18, 2010 at 8:17 PM, Yongning Zhu <yongningbrg@gmail.com> wrote:
> 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