[Numpy-discussion] [EXTERNAL] numpy.i and INPLACE_ARRAY1[ANY]

Bill Spotz wfspotz at sandia.gov
Fri Nov 22 17:40:20 EST 2013


Kaspar,

Yes, in order for numpy.i typemaps to work, you need to provide dimensions.  How is lilv_test(float*) supposed to know how large the float array is?  Is it actually a method where the class knows the size?  In cases where dimensions are not passed through the argument list, you have two options:

  1. Write a proxy function that does have dimension arguments and calls the original function, and then wrap that instead of the original function.

  2. Use the functions and macros in numpy.i to write new typemaps that work for your case.

-Bill

On Nov 22, 2013, at 3:30 PM, Kaspar Emanuel wrote:

> Hey,
> I am trying to improve the Lilv Python bindings to include numpy.i to allow for creation and verification of audio test buffers using NumPy.
> 
> I am just trying to get something working at the moment so I am tring to wrap a test function.
> 
> static inline void
> lilv_test(float* data_location){}
> 
> and I have in lilv.i:
> 
> %apply (float* INPLACE_ARRAY1) {(float* data_location)};
> This doesn’t produce any warnings or anything but when I try and use it from Python I get:
> 
> TypeError: in method 'lilv_test', argument 1 of type 'float *'
> What does work is if I have:
> 
> lilv_test(float* data_location, int n){}
> and
> 
> %apply (float* INPLACE_ARRAY1, int DIM1) {(float* data_location, int n)};
> but this doesn’t fit very well with the functions I eventually want to wrap, as they don’t have a dimension argument.
> 
> Is it not possible to use INPLACE_ARRAY1 without a dimension?
> 
> Thanks for any help,
> 
> Kaspar
> 
> 
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.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