[Numpy-discussion] Indexing with weave
Keith Goodman
kwgoodman at gmail.com
Mon Jan 8 16:26:02 CST 2007
On 1/8/07, Barry Wark <barrywark at gmail.com> wrote:
> I think you want
> y = x[0,i]
I followed the weave.inline example at
http://www.scipy.org/PerformancePython
which uses the C-like x(i,j) instead of the numpy x[i,j].
Changing test2 to y = x[0,i] gives "TypeError: cannot convert value to
double" on the weave.inline line.
> On 1/8/07, Keith Goodman <kwgoodman at gmail.com> wrote:
> > 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