I'm using python 2.4 under linux (centos 5.1).
I need to pass an array of doubles to a c function
but am getting an error, shown near the bottom of
this post.
----------------------------------------------------
my swig interface file looks like this

* File: rug520.i */
%module rug520
%include "typemaps.i"
%include "carrays.i"
%array_class(double, doubleArray);
%{
#define SWIG_FILE_WITH_INIT
#include "rug520.h"
extern double[] nCmiArray;
%}


%apply int *OUTPUT {     char *sRugHier,
                         char * sRugMax, 
                         int * iRugHier,
                         int * iRugMax, 
                         double * nCmiValueHier,
                         double * nCmiValueMax, 
                         int * iAdlSum,
                         int * iCpsCode, 
                         char * sRugsVersion,
                         char * sDllVersion, 
                         int * iError };


int RugCalc( char * sMdsRecord, 
             char * sRehabType, 
             char * sModel, 
             int iQuarterlyFlag, 
             double nCmiArray[], 

              char * sRugHier,
             char * sRugMax, 
             int * iRugHier,
             int * iRugMax, 
             double * nCmiValueHier,
             double * nCmiValueMax, 
             int * iAdlSum,
             int * iCpsCode, 
             char * sRugsVersion,
             char * sDllVersion, 
             int * iError );

------------------------------------------------------------------ 
my test code looks like this:
import sys, os, rug520
cmi=[0.0] *59

def getrug(mds):
    results = rug520.RugCalc(mds, 'mcare', '34', 0, cmi)
    print 'results', results

datafile = open('mdsdata.txt')
for d in datafile:
    if d[0]=='B':
        getrug(d)
------------------------------------------------------------------------
I get this error message
File "testrug520.py", line 11, in ?
    getrug(d)
  File "testrug520.py", line 5, in getrug
    results = rug520.RugCalc(mds, 'mcare', '34', 0, cmi)
TypeError: in method 'RugCalc', argument 5 of type 'double []'

--------------------------------------------------------------------------

I'm guessing that I am not passing a double array to the c code.  I cannot 
change
the c code due to politics.  I could write a c "wrapper" if I had to, but would 
rather
stay within python or the swig interface definitions if possible/practical.

I'm not much of a c programmer; mostly java and python with a little c++.  
I've looked in the swig docs and tried google, but either have not found
it or just don't understand what they are telling me here.
 
---------------------------------------------------------------------------
The information contained in this message may be privileged and / or
confidential and protected from disclosure. If the reader of this message is
not the intended recipient, you are hereby notified that any dissemination,
distribution or copying of this communication is strictly prohibited. If you
have received this communication in error, please notify the sender
immediately by replying to this message and deleting the material from any
computer.
---------------------------------------------------------------------------
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to