473,390 Members | 1,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 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...]


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
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

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


Nov 9 '07 #1
0 1411

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Duncan Smith | last post by:
Hello, Since moving to numpy I've had a few problems with my existing code. It basically revolves around the numpy scalar types. e.g. ------------------------------------------------ array(,...
by: TG | last post by:
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...
by: devnew | last post by:
hi i am looking for some info about mapping btw values in an array and corresponding columns of a matrix i have an numpy array= and a numpy matrix object= matrix((, , , ))
by: Travis Oliphant | last post by:
I wanted to point anybody interested to a blog post that describes a useful pattern for having a NumPy array that points to the memory created by a different memory manager than the standard one...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.