471,337 Members | 1,465 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

get the shape of a numpy ndarray in C++ code [boost.python]

[sorry is half a post appeared earlier. Bloody Google groups...]

Hello,

I'm trying to use a numpy array in C++ (win2000) using boost.python.

Test code:
void test( numeric::array& nsP)
{
object shape = nsP.getshape();
int rows = extract<int>(shape[0]);
int cols = extract<int>(shape[1]);
}

At first, running it in Python got me this message:

ArgumentError: Python argument types in
d3d.wr_conn(numpy.ndarray)
did not match C++ signature:
wr_conn(class boost::python::numeric::array {lvalue})

I fixed this using this line:

numeric::array::set_module_and_type( "numpy", "ndarray");

[was that right?]
At least it got me one step further; the array is accepted. Now the
message is this:

AttributeError: 'numpy.ndarray' object has no attribute 'getshape'

Now I'm stumped. The only thing I can find is
http://www.thescripts.com/forum/showthread.php?t=644270

which regrettably ends with the same question. What's wrong here?

greets,
Marc

Nov 9 '07 #1
0 1341

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Duncan Smith | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.