[Numpy-discussion] swig numpy2carray converters

Bill Spotz wfspotz at sandia.gov
Thu Nov 29 23:16:42 EST 2007


I have just committed the latest version of numpy.i (a swig interface  
file for bridging between C arrays and numerical python) to the numpy  
svn repository.  There are three relatively new features that are now  
supported:

* It is now possible to wrap functions that expect integer arguments  
and have swig
   generate wrappers that allow you to provide numpy array scalars.

* A new ARGOUTVIEW suite of typemaps is provided that allows your  
wrapped function
   to provide a pointer to internal data and that returns a numpy  
array encapsulating
   it.  This is potentially dangerous, but necessary in some  
situations for very
   large data buffers.

* New typemaps are provided that correctly handle FORTRAN ordered 2D  
and 3D arrays.

Tests for the ARGOUTVIEW and FORTRAN ordered arrays have also been  
added, and the documentation (doc/numpy_swig.*) has been updated to  
reflect all of these changes.

On Nov 26, 2007, at 3:52 PM, Christopher Barker wrote:

> Bill Spotz wrote:
>> First, my plan is to add to numpy.i, typemaps for signatures like the
>> following:
>>
>>      %typemap(argout) (double** ARGOUT_ARRAY1, int* DIM1)
>>
>> It is important to note that even though the same argument *names*
>> are used, this is a different typemap signature than
>>
>>      %typemap(argout) (double* ARGOUT_ARRAY1, int DIM1)
>>
>> and thus can have (logically) different implementations.
>
> maybe it's a good idea to give the arguments different names, though,
> just for clarity.
>
>> As for having a COPY version of the first typemap signature (in
>> addition to the non-copy, or "view" version), I currently do not plan
>> to do this.
>
> I think you've got it right.
>
> Thanks for all this!
>
> -Chris
>
> -- 
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker at noaa.gov
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>

** Bill Spotz                                              **
** Sandia National Laboratories  Voice: (505)845-0170      **
** P.O. Box 5800                 Fax:   (505)284-0154      **
** Albuquerque, NM 87185-0370    Email: wfspotz at sandia.gov **







More information about the NumPy-Discussion mailing list