Boost python : get the shape of a numpy ndarray in C++ code.
TG
girodt at gmail.com
Wed May 9 11:08:46 EDT 2007
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 ?
* are the dimensions corresponding to map's width / height ?
* is array field with floats or ints ?
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.
More information about the Python-list
mailing list