[C++-sig] to Philip Austin:Re: Stuck on accessing numpy.ndarray in c extension

Qinfeng(Javen) Shi shiqinfeng at gmail.com
Tue Sep 26 08:02:48 CEST 2006


Hi Philip Austin,

Thanks! I added following lines as you told me to hello.cpp file. It didn't
crash but still had error. The interesting thing is that now running it
twice would get two different error informations.

/************hello.cpp**************/
namespace ar=boost::python::numeric;
namespace bp=boost::python;
import_array();
ar::array::set_module_and_type("numpy", "ndarray");

########## error report##########
>>> import hello
>>> import numpy
>>> a = numpy.arange(25).reshape((5,5));
>>> hello.testArray(a)                                    // first time
SystemError: new style getargs format but argument is not a tuple
>>> hello.testArray(a)                                   // second time
args is array type!                         //it means PyArray_Check(args)
successed this time.
getting input failed!                        //PyArg_ParseTuple() failed but
not crashed

Any idea?
-- 
Qinfeng(Javen) Shi

Research School of Information Sciences and Engineering
Australian National University
Locked Bag 8001
Canberra ACT 2601
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20060926/4a3ad2ac/attachment.htm>


More information about the Cplusplus-sig mailing list