Re: [Boost-users] Numpy ndarray as argument or return value using boost python
On Mon, Nov 30, 2009 at 1:34 PM, Nyiro Gergo
- Hide quoted text - - Show quoted text - http://groups.google.com/group/boost-list/browse_thread/thread/b491f5eb8cc83...
On Mon, Oct 12, 2009 at 7:09 AM, Pim Schellart
http://groups.google.com/groups/unlock?_done=/group/boost-list/browse_thread/thread/b491f5eb8cc836c5&msg=a69011d99e445aef@gmail.com> wrote: Hi Everyone,
I tried to find a good example for this but after spending two days on google and one day getting pyublas to compile I decided to call for help. I want to give a numpy ndarray as an argument to a c++ method, calculate something and return the output as an ndarray to Python. I would prefer not to use another library (such as PyUblas) for this so I do not have to add another dependency to my program. Since the latest information on boost python is quite outdated (uses numeric) I would like to know the following.
1. Is boost python still maintained or should I switch to another tool. 2. Is numpy supported, and if so, 3. can someone give me a basic example of how to use it.
1. Yes, Boost.Python is still maintained and works find. 2. Yes, Boost.Python supports any and all libraries that communicate through python, you would just use the ndarray just like any other Python Object. 3. Give an example of how you use it in Python and we can give you an example of how you would do it from the C++ side, it is a pretty direct 1-to-1 mapping (have you gone through the Boost.Python tutorials and documentation yet?).
Hello,
I read that post above on Boost-users mailing list, but I have no permission required to post. To answer to the 3. point could you give me an example how to solve this python code snippet in C++:
parser = cParser('FileName') # that would be the C++ class (already implemented) TimeAndSignal = parser.getSignal('SignalName') # and this the questionable member function type(TimeAndSignal)
len(TimeAndSignal) 2 type(TimeAndSignal[0]) type(TimeAndSignal[1]) import pylab pylab.plot(TimeAndSignal[0], TimeAndSignal[1]); pylab.show() Time, Signal = parser.getSignal('SignalName') # and this must work too pylab.plot(Time, Signal); pylab.show() Thanks for your help in advance.
You should forward this to the Boost list. I am not home right now so cannot give a good example, so you would probably get a much better example from there. I am forwarding this response back to the Boost list. If I notice this later when I have free time, I will come up with examples for the above, but it really is very simple, should look at the examples included with Boost.Python.
participants (1)
-
OvermindDL1