Numeric C extension: bug or error ?
Philippe Grosse
veronique.grosse at wanadoo.fr
Mon Oct 6 15:27:33 EDT 2003
In article <qnku16u3t26.fsf at arbutus.physics.mcmaster.ca>,
cookedm+news at physics.mcmaster.ca (David M. Cooke) wrote:
> At some point, veronique.grosse at wanadoo.fr (Philippe Grosse) wrote:
> > Hi,
> >
> > I don't understand this strange behaviour:
> >
> > I compile this code :
> [code clipped; it looks good]
> ...
> > /* registration table */
> > static struct PyMethodDef testMethods[] = {
> > {"return_vector", return_vector, 1}, /* method name, C
> > funcptr, always-tuple */
> > {NULL, NULL} /* end of table marker */
> > };
>
> Instead of the magic constant "1", use METH_VARARGS.
I have tried METH_VARARGS: same result
>
> ...
> > Very simple: this module takes a Numeric array (vector) as argument and
> > send this array back to python...
> >
> > If I compile it under macOSX, the result in python is:
> >
> >>>> import test
> >>>> from Numeric import *
> >>>> v=array([1.0,2.0,3.0,4.0],Float)
> >>>> v
> > array([ 1., 2., 3., 4.])
> >>>> test.return_vector(v)
> > array([ 1., 2., 3., 4.])
> >
> > but in linux the result is:
> >
> >>>> import test
> >>>> from Numeric import *
> >>>> v=array([1.0,2.0,3.0,4.0],Float)
> >>>> v
> > array([ 1., 2., 3., 4.])
> >>>> test.return_vector(v)
> > array([ 1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j])
>
> This isn't what I get; I get the same result under linux as you get
> from Mac OS X. Have you checked that the copies of the code are the
> same?
Yes, I'm sure, the codes are exactly the same.
I use this command to compile under linux:
[grosse at intercalcul dev_fortran]$ gcc -DNDEBUG -O3 -fomit-frame-pointer
-pipe -mcpu=pentiumpro -march=i586 -ffast-math -fno-strength-reduce -fPIC
-g -I/usr/include/python2.2 -c test.c -o test.o
[grosse at intercalcul dev_fortran]$ gcc -shared -g -o test.so test.o
I can understand where is the problem, I'm totaly confused.
Thank you for your help
More information about the Python-list
mailing list