Boost logo

Boost Users :

Subject: [Boost-users] getting shape of numpy array
From: TheLonelyStar (nabble2_at_[hidden])
Date: 2009-11-09 18:36:17


Hi,

I am trying to interaface a numpy array using boost::python::numeric::array.

void function(numeric::array& a)
{
        tuple shape=extract<tuple>(a.getshape());
        double x;
        int i,j;
        for(i=0;i<shape[0];++i)
                for(j=0;j<shape[1];++j)
                        x=extract<double>(a[make_tuple(i,j)]);
}

Now I had to add
numeric::array::set_module_and_type("numpy", "ndarray");

to the module, hope that was correct.

When I call this function in python, I get:
AttributeError: 'numpy.ndarray' object has no attribute 'getshape'

What is the correct way to do it?

Thanks!
Nathan

-- 
View this message in context: http://old.nabble.com/getting-shape-of-numpy-array-tp26275771p26275771.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net