[Numpy-discussion] Anyone have a well-tested SWIG-based C++ STL valarray <=> numpy.array typemap to share?

Xavier Gnata gnata@obs.univ-lyon1...
Mon Sep 10 15:11:28 CDT 2007


Christopher Barker wrote:
> Xavier Gnata wrote:
>   
>> Here it is :) 
>>     
>
> Thanks, that's helpful. Am I reading it right? Are you running the 
> python process embedded in your C++ app? (rather than extending?)
>
>   
Yes! The point is this way I'm able to debug my C++ code plotting the 
array using matplotlib :)
That is cool ;).
>>   valarray < double >Data (NbData);
>>     
>
>   
>>   array = PyArray_SimpleNewFromData (NbDims, Dims, PyArray_DOUBLE, 
>> &Data[0]);
>>     
>
> OK, so you've now got a view of the data from the valarray. Nice to know 
> this works, but, of course, fragile if the valarray is re-sized or 
> anything, so it probably won't work for us.
>
>   

Yep it is not robust at all because the valarray can be modify.
However, it is a a quite great way to plot an array in a C++ code. 
Nothing more.
If you want to try with shared pointers, maybe you should have a look at 
the boost lib.

Xavier


-- 
############################################
Xavier Gnata
CRAL - Observatoire de Lyon
9, avenue Charles André
69561 Saint Genis Laval cedex
Phone: +33 4 78 86 85 28
Fax: +33 4 78 86 83 86
E-mail: gnata@obs.univ-lyon1.fr
############################################ 



More information about the Numpy-discussion mailing list