ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> cpp-sig
cpp-sig
[C++-sig] How to call reshape((M,N),order='F') ?
by Michele De Stefano other posts by this author
Oct 26 2009 9:38AM messages near this date
Re: [C++-sig] function with >15 args yields get_signature error | Re: [C++-sig] How to call reshape((M,N),order='F') ?
Hello to everyone.

I have this problem.

Assume I'm building a to-Python converter for a 3x2 matrix type,
FORTRAN storage (these are not the real dimensions of my problem, but
I give these numbers only to simplify the discussion).

Into the "convert" C++ method, first, I build a list with all the
matrix elements (lout);
then, I instantiate a boost::python::numeric::array in this way (note:
I had previously used
set_module_and_type("numpy","ndarray"), for using the NumPy's array):

boost::python::numeric::array   v(lout)

Finally, I'd like to call "reshape" on this array, in this way

v.attr("reshape")(make_tuple(3,2),"F");

But it does not work. It builds, but, on runtime, I obtain the error:

Traceback (most recent call last):
  File "<stdin> ", line 1, in ?
TypeError: an integer is required

I tried to build and re-shape a matrix entirely from Python and I
discovered that, when using reshape,
you are forced to give the second parameter as

order = 'C' or 'F'

Now the question is: is it possible to specify a named parameter from
the C++ code ?
If the answer is "yes", how ?

Thank you in advance,
Michele

-- 
Michele De Stefano
http://www.linkedin.com/in/micdestefano
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@[...].org
http://mail.python.org/mailman/listinfo/cplusplus-sig
Thread:
Michele De Stefano
Sebastian Walter
Michele De Stefano

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved