Boost python : get the shape of a numpy ndarray in C++ code.
Roman Yakovenko
roman.yakovenko at gmail.com
Wed May 9 13:47:56 EDT 2007
On 9 May 2007 08:08:46 -0700, TG <girodt at gmail.com> wrote:
> Hi there.
>
> I'm strugling here with some boost python code (damn I hate C++) :
>
> All I want to do is to initialize the content of an array with a numpy
> ndarray parameter. I have this, which actually works. But I want to
> add some kind of data check such as :
>
> * is array two dimensional ?
This question has nothing to do with Boost.Python
> * are the dimensions corresponding to map's width / height ?
Same as above
> * is array field with floats or ints ?
Read "extract" documentation http://boost.org/libs/python/doc/v2/extract.html
> void
> Layer::set_potentials (numeric::array& array)
> {
> for (int h=0; h<map->height; h++){
> for (int w=0; w<map->width; w++){
> units[w+h*map->width]->potential =
> extract<float>(array[make_tuple(w,h)]);
> }
> }
> }
>
>
> Some help is very welcome here ... thanks.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Roman Yakovenko
C++ Python language binding
http://www.language-binding.net/
More information about the Python-list
mailing list