
I have some inline statements that work wonderfully under Linux, but on OSX (python2.3 using recent CVS weave), they die the death. Note that weave.test() on my machine runs cleanly. Any clues would be most appreciated. Here is the code and the resultant errors: code = ''' #line 610 "ReinforcementLearning.py" PyObject *key, *qval, *traceval = NULL; Py::List keys = qfunction.keys(); for (int i=0; i<keys.length(); i++) { key = PyList_GET_ITEM(keys.ptr(),i); /* Grab and convert current Q-value */ qval = PyDict_GetItem(qfunction.ptr(),key); double qval_raw = py_to_float(qval,"qval_raw"); /* Grab and convert current elegibility value */ traceval = PyDict_GetItem(etrace.ptr(),key); double traceval_raw = py_to_float(traceval,"traceval_raw"); /* Calculate new Q-value */ qval_raw += alpha * delta * traceval_raw; /* Return new Q-value to Q-function */ PyObject* qval_new = PyFloat_FromDouble(qval_raw); PyDict_SetItem( qfunction.ptr(), key, qval_new ); /* Cleanup */ Py_DECREF(qval_new); /* Only update nonzero e-trace values */ if (traceval_raw>0.0) { /* Only interested in sizeable values */ if (traceval_raw>=tolerance) { /* Calculate new elegibility value */ traceval_raw = gamma * lamda * traceval_raw; /* Return new elegibility value to trace */ PyObject* traceval_new = PyFloat_FromDouble(traceval_raw); PyDict_SetItem( etrace.ptr(), key, traceval_new ); /* Cleanup */ Py_DECREF(traceval_new); } /* Set very small values to zero */ else PyDict_SetItem( etrace.ptr(), key, PyFloat_FromDouble(0.0) ); } } ''' 'Call to weave' weave.inline(code, ['qfunction', 'alpha','delta','etrace', 'gamma','lamda','tolerance']) This results in: ReinforcementLearning.py: In function `PyObject* compiled_func(PyObject*, PyObject*)': ReinforcementLearning.py:612: `Py' undeclared (first use this function) ReinforcementLearning.py:612: (Each undeclared identifier is reported only once for each function it appears in.) ReinforcementLearning.py:612: parse error before `::' token ReinforcementLearning.py:613: `keys' undeclared (first use this function) ReinforcementLearning.py:617: no matching function for call to `py::dict::ptr() ' ReinforcementLearning.py:621: no matching function for call to `py::dict::ptr() ' ReinforcementLearning.py:629: no matching function for call to `py::dict::ptr() ' ReinforcementLearning.py:646: no matching function for call to `py::dict::ptr() ' ReinforcementLearning.py:653: no matching function for call to `py::dict::ptr() ' Traceback (most recent call last): File "ReinforcementLearning.py", line 931, in __call__ s==maxsteps-1) File "ReinforcementLearning.py", line 678, in update_qfunction ['qfunction', File "/Users/chris/Development/python/weave/inline_tools.py", line 335, in inline auto_downcast = auto_downcast, File "/Users/chris/Development/python/weave/inline_tools.py", line 439, in compile_function verbose=verbose, **kw) File "/Users/chris/Development/python/weave/ext_tools.py", line 340, in compile verbose = verbose, **kw) File "/Users/chris/Development/python/weave/build_tools.py", line 272, in build_extension setup(name = module_name, ext_modules = [ext],verbose=verb) File "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- packages/scipy_distutils/core.py", line 42, in setup return old_setup(**new_attr) File "/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/ distutils/core.py", line 166, in setup raise SystemExit, "error: " + str(msg) CompileError: error: command 'gcc' failed with exit status 1

Christopher Fonnesbeck wrote:
I have some inline statements that work wonderfully under Linux, but on OSX (python2.3 using recent CVS weave), they die the death. Note that weave.test() on my machine runs cleanly. Any clues would be most appreciated. Here is the code and the resultant errors:
code = ''' #line 610 "ReinforcementLearning.py"
PyObject *key, *qval, *traceval = NULL; Py::List keys = qfunction.keys();
[snip]
ReinforcementLearning.py: In function `PyObject* compiled_func(PyObject*, PyObject*)': ReinforcementLearning.py:612: `Py' undeclared (first use this function)
try using py::list instead of Py::List. I think something changed at some point, because I had to update similar code myself. hth. best, f
participants (2)
-
Christopher Fonnesbeck
-
Fernando Perez