From: Bill S. <wf...@sa...> - 2006-09-28 16:43:52
|
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: wf...@sa... ** |