Re: [C++-sig] Exposing members of members

2009-01-19 Thread Ralf W. Grosse-Kunstleve
I'd define to/from Python conversions for the std::pair, mapping to Python tuples, then use .add_property(). Alternatively, wrap std::pair the normal way via class_, then you can use .def_readwrite(). You need to handle each std::pair combination of A,B separately, like any other template class y

Re: [C++-sig] create boost array from a Numpy PyArray without copying data?

2009-01-19 Thread Ravi
On Monday 19 January 2009 07:16:10 Sebastian Walter wrote: > My question is: > How can I create a > boost::python::numeric::array from a Numpy Pyarray without copying data? See http://mail.python.org/pipermail/cplusplus-sig/2008-October/013825.html for a full solution. In particular, see the foll

[C++-sig] Exposing members of members

2009-01-19 Thread Ricardo Abreu
Hello, Suppose that I have a class A with a member of type std::pair, called a. If I want to expose class A to python while allowing read/write access to the object pointed to by a.first, what to I put in def_readwrite? I tried something like class("A").def_readwrite("a", &A::a::first); but

[C++-sig] create boost array from a Numpy PyArray without copying data?

2009-01-19 Thread Sebastian Walter
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, On the C++ side I have a raw pointer: double *x; I'd like to change its values from within Python by using Numpy. Example code can be found below. My approach is 1) make PyArray from existing data *x with PyArray_SimpleNewFromData 2) create a b