I am trying to connect a small C function that I made in python using SWIG and Numpy typemaps
This function is defined as follows
void nw(int* D, int Dx, int Dy, int* mat, int mx, int my, char *xstr, int xL,char *ystr, int yL);
And my interface file is as follows
%module nw %{ #define SWIG_FILE_WITH_INIT #include "nw.h" %} %include "numpy.i" %init %{ import_array(); %} %apply (int* INPLACE_ARRAY2, int DIM1, int DIM2) {(int* D, int Dx, int Dy)} %apply (int* IN_ARRAY2, int DIM1, int DIM2) {(int* mat, int mx, int my)} %apply (char* IN_ARRAY, int DIM1){(char *xstr, int xL),(char *ystr, int yL)} %include "nw.h"
To check this, I used the following input
D = numpy.zeros((5,5),numpy.int) mat = numpy.array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]],numpy.int) x = numpy.array(list("ABCD")) y = numpy.array(list("ABCD")) import nw nw.nw(D,mat,x,y)
But when I run it, I get the following
TypeError: nw() takes exactly 6 arguments (4 given)
I'm really confused about how these arguments are defined. Does anyone have an idea why there are 6 arguments and what are these arguments? Thanks!