[C++-sig] Trouble converting data from numpy.array to c++

Ger van Diepen diepen at astron.nl
Tue May 11 12:24:42 CEST 2010


Hi Jean-Charles,

AFAIK there are no standard converters for the numpy scalar types to C++
types.
In pyrap it is solved by having explicit converters for numpy scalar
types to C++ types (see pyrap.googlecode.com).

Cheers,
Ger

>>> QUILLET Jean-Charles  05/11/10 11:38 AM >>>
Hi,
 
I've got this problem I cannot solve. I've a c++ applicationfrom which I
create an array sending to python this string:
 
anArray = numpy.array((1, 2, 3))
 
After extracting the symbol "anArray" from thedirectory in a
boost::python::object, I'm trying to extract the values in C++:
 
int val = bp::extract(anArray[0]);
 
It doesn't work and raise the error:
 
"TypeError: No registered converter was able toproduce a C++ rvalue of
type int from this Python object of type numpy.int32"
 
What is going on ? I'm using python 2.6, last version ofNumpy 1.4.1 with
boost 1.38 on Linux. Looking on the list, it seems thatsomeone had this
very problem but he didn't get any answer. 
 
http://article.gmane.org/gmane.comp.python.c++/11279/match=typeerror+no+registered+converter+able+produce+c%2b%2b+rvalue+type+int+python+object+numpy+int32
 
Hopefully I'll have more chance !
Any idea greatly appreciated,
 
Jean-Charles
 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20100511/b58badb1/attachment.html>


More information about the Cplusplus-sig mailing list