[SciPy-dev] numpy API help
Travis Oliphant
oliphant.travis at ieee.org
Fri Mar 10 14:17:32 EST 2006
Neal Becker wrote:
> I need some help with numpy-0.9.5. I don't really have any API docs, so
> maybe that's my problem.
>
> #include <Python.h>
> #include <arrayobject.h>
>
>
> int main() {
> intp dims[1];
> dims[0] = 2;
> PyObject* o = PyArray_SimpleNew (1, dims, PyArray_INT);
> }
> (gdb) run
> Starting program: /home/nbecker/Test
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000000000400525 in main () at Test.cc:8
>
> I notice that the precompiled output is:
> int main() {
> intp dims[1];
> dims[0] = 2;
> PyObject* o = (*(PyObject * (*)(PyTypeObject *, int, intp *, int, intp *,
> void *, int, int, PyObject *)) PyArray_API[82])(&(*(PyTypeObject
> *)PyArray_API[1]), 1, dims, PyArray_INT, __null, __null, 0, 0, __null);
> }
>
>
Did you forget to use import_array? That's the command that fills in
PyArray_API so that PyArray_API[82] makes sense...
-Travis
More information about the SciPy-Dev
mailing list