List Info

Thread: datastructure to numpy and back




datastructure to numpy and back
country flaguser name
Austria
2007-10-15 13:07:37
Hallo!

I know this was discussed quite some times, but I did find
that many 
workarounds and not really a common way how to do that with
Boost.Python 
... so I am a little bit confused ...

My problem: I have a class with some (big) custom C++ matrix
types and I 
want to write some getters/setters for them to/from numpy
arrays, where 
I want to avoid copies of the data.

So is there a common way to do this ?
(e.g. num_util from 
http://www.eos.u
bc.ca/research/clouds/software/pythonlibs/num_util/num_util_
release2/Readme.html 
?)

Or can maybe someone link me to some docu or examples which
already did 
this ? (it must be quite common ...)

Many thanks for any hint,
LG
Georg
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: datastructure to numpy and back
country flaguser name
Austria
2007-10-16 10:45:49
Hallo again !

I still did not get it working with boost (after quite some
reading and 
searching) ... aren't there any examples out there how to do
that ?

Or maybe is it better to use SWIG or directly the NumPy
C-API for that ?

Thanks,
LG
Georg

Georg Holzmann schrieb:
> Hallo!
> 
> I know this was discussed quite some times, but I did
find that many 
> workarounds and not really a common way how to do that
with Boost.Python 
> ... so I am a little bit confused ...
> 
> My problem: I have a class with some (big) custom C++
matrix types and I 
> want to write some getters/setters for them to/from
numpy arrays, where 
> I want to avoid copies of the data.
> 
> So is there a common way to do this ?
> (e.g. num_util from 
> http://www.eos.u
bc.ca/research/clouds/software/pythonlibs/num_util/num_util_
release2/Readme.html 
> ?)
> 
> Or can maybe someone link me to some docu or examples
which already did 
> this ? (it must be quite common ...)
> 
> Many thanks for any hint,
> LG
> Georg
> _______________________________________________
> C++-sig mailing list
> C++-sigpython.org
> http:
//mail.python.org/mailman/listinfo/c++-sig

_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

Re: datastructure to numpy and back
user name
2007-10-16 10:55:00
Hi,

I've written a swig wrapper around a structure that could be used for wrapping anything that needs to expose the __array_struct__ property (didn't had the time to try Boost with Albert';s wrappers). It is not available on the net, but it is based on some mails that were sent here and on the Pyrex example for the array interface.

Matthieu

2007/10/16, Georg Holzmann < grhmur.at">grhmur.at>;:
Hallo again !

I still did not get it working with boost (after quite some reading and
searching) ... aren't there any examples out there how to do that ?

Or maybe is it better to use SWIG or directly the NumPy C-API for that ?

Thanks,
LG
Georg

Georg Holzmann schrieb:
&gt; Hallo!
>;
> I know this was discussed quite some times, but I did find that many
> workarounds and not really a common way how to do that with Boost.Python
> ... so I am a little bit confused ...
>
&gt; My problem: I have a class with some (big) custom C++ matrix types and I
> want to write some getters/setters for them to/from numpy arrays, where
&gt; I want to avoid copies of the data.
>
> So is there a common way to do this ?
> (e.g. num_util from
> http://www.eos.ubc.ca/research/clouds/software/pythonlibs/num_util/num_util_release2/Readme.html
> ?)
>
&gt; Or can maybe someone link me to some docu or examples which already did
> this ? (it must be quite common ...)
>;
> Many thanks for any hint,
> LG
> Georg
> _______________________________________________
> C++-sig mailing list
> C++-sigpython.org">C++-sigpython.org
> http://mail.python.org/mailman/listinfo/c++-sig

_______________________________________________
C++-sig mailing list
C++-sigpython.org"> C++-sigpython.org
http://mail.python.org/mailman/listinfo/c++-sig

Re: datastructure to numpy and back
country flaguser name
Austria
2007-10-22 11:03:38
Hallo!

> I've written a swig wrapper around a structure that
could be used for 
> wrapping anything that needs to expose the
__array_struct__ property 
> (didn't had the time to try Boost with Albert's
wrappers). It is not 
> available on the net, but it is based on some mails
that were sent here 
> and on the Pyrex example for the array interface.

Thanks, I looked now through quite some SWIG examples and I
was able to 
get a matrix/array from numpy into C++ (with the very good
documentated 
examples in numpy-svn/numpy/doc/swig).

However, I did not manage to get an array out of C++ to
python without 
copying so far.
In the examples cited above it's only shown how to generate
a new one 
dimensional array and return that.

Do you maybe have some links (from the mails here and on)
where these 
features are explained ? Or modules which are examples for
such use-cases ?

Thanks for any hint,
LG
Georg
_______________________________________________
C++-sig mailing list
C++-sigpython.org
http:
//mail.python.org/mailman/listinfo/c++-sig

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )