I am wrapping code using swig and extending it to use numpy.

One class method I wrap (let's call it myElements()) returns an array  
of ints, and I convert it to a numpy array with

     PyArray_SimpleNew(1,n,'i');

I obtain the data pointer, fill in the values and return it as the  
method return argument.

In python, it is common to want to loop over this array and treat its  
elements as integers:

     for row in map.myElements():
         matrix.setElements(row, [row-1,row,row+1], [-1.0,2.0,-1.0])

On a 32-bit machine, this has worked fine, but on a 64-bit machine, I  
get a type error:

     TypeError: in method 'setElements', argument 2 of type 'int'

because row is a <type 'int32scalar'>.

It would be nice if I could get the integer conversion to work  
automatically under the covers, but I'm not exactly sure how to make  
that work.

** Bill Spotz                                              **
** Sandia National Laboratories  Voice: (505)845-0170      **
** P.O. Box 5800                 Fax:   (505)284-5451      **
** Albuquerque, NM 87185-0370    Email: [EMAIL PROTECTED] **




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion

Reply via email to