Hello experts,

Running sage version 4.8 on Mac OS X 10.6.8.
I am attempting to cython-ize a sage script that applies numpy, but I can't get 
cython to compile numpy.vectorize — the error message is

ValueError: failed to determine the number of arguments for <built-in function 
pressure>

Is this a bug in cython, or am I mis-applying numpy and cython?

The test script (test.spyx) that produces this error is

import numpy as np
cimport numpy as np
gamma = 1.4
def pressure(rho, u, v, rho_E): return (gamma - 1) * (rho_E - rho * (u * u + v 
* v) / 2.)
vpressure = np.vectorize(pressure, otypes = [np.float], \
     doc = "Vectorized pressure(rho, u, v, rho*E)")

and the full error traceback when I invoke sage: load("test.spyx") is:

Compiling /Users/jim/Documents/Fluid_Mechanics/AA543_HW5/test.spyx...
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/Users/jim/<ipython console> in <module>()

/Applications/sage/local/lib/python2.6/site-packages/sage/structure/sage_object.so
 in sage.structure.sage_object.load (sage/structure/sage_object.c:7715)()

/Applications/sage/local/lib/python2.6/site-packages/sage/misc/preparser.pyc in 
load(filename, globals, attach)
   1648     elif fpath.endswith('.spyx') or fpath.endswith('.pyx'):
   1649         import interpreter
-> 1650         exec(interpreter.load_cython(fpath), globals)
   1651     elif fpath.endswith('.m'):
   1652         # Assume magma for now, though maybe .m is used by maple and

/Users/jim/<string> in <module>()

/Users/jim/_Users_jim_Documents_Fluid_Mechanics_AA543_HW5_test_spyx_1.pyx in 
init _Users_jim_Documents_Fluid_Mechanics_AA543_HW5_test_spyx_1 
(_Users_jim_Documents_Fluid_Mechanics_AA543_HW5_test_spyx_1.c:3322)()
      7 cimport numpy as np
      8 gamma = 1.4
      9 def pressure(rho, u, v, rho_E): return (gamma - 1) * (rho_E - rho * (u 
* u + v * v) / 2.)
---> 10 vpressure = np.vectorize(pressure, otypes = [np.float], \
     11      doc = "Vectorized pressure(rho, u, v, rho*E)")

/Applications/sage/local/lib/python2.6/site-packages/numpy/lib/function_base.pyc
 in __init__(self, pyfunc, otypes, doc)
   1767         self.thefunc = pyfunc
   1768         self.ufunc = None
-> 1769         nin, ndefault = _get_nargs(pyfunc)
   1770         if nin == 0 and ndefault == 0:
   1771             self.nin = None

/Applications/sage/local/lib/python2.6/site-packages/numpy/lib/function_base.pyc
 in _get_nargs(obj)
   1699 
   1700     raise ValueError(
-> 1701             "failed to determine the number of arguments for %s" % 
(obj))
   1702 
   1703 

ValueError: failed to determine the number of arguments for <built-in function 
pressure>

Thank you,
Jim Clark

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to