[Numpy-discussion] Indexing with weave

Keith Goodman kwgoodman at gmail.com
Mon Jan 8 13:14:21 CST 2007


My first weave attempt weaves something to be desired.

test() works, but test2() doesn't.

It complains about the line "y = x(0,i);"

In function 'PyObject* compiled_func(PyObject*, PyObject*)':
blah.cpp:667: error: no match for call to '(py::object) (int, int&)'

I am no match for that error message. What am I doing wrong?

from scipy import weave
from scipy.weave import converters
import numpy.matlib as M

def test(i):
    x = M.matrix([[1.0, 2.0, 3.0]]);
    code =  """
            return_val = x(0,i);
            """
    y = weave.inline(code, ['x', 'i'], type_converters=converters.blitz)
    return y

def test2(i):
    x = M.matrix([[1.0, 2.0, 3.0]]);
    code =  """
            double y;
            y = x(0,i);
            return_val = y;
            """
    y = weave.inline(code, ['x', 'i'], type_converters=converters.blitz)
    return y


More information about the Numpy-discussion mailing list