Numeric C extension: bug or error ?
David M. Cooke
cookedm+news at physics.mcmaster.ca
Tue Sep 30 16:44:17 EDT 2003
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.
...
> 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?
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca
More information about the Python-list
mailing list