[SciPy-user] Getting PyArray_Resize to work under weave

Orest Kozyar orest.kozyar@gmail....
Tue Jun 10 12:26:18 CDT 2008


I originally posted this on Numpy, but did not get any feedback.  I've
set up a temporary workaround by ensuring the Numpy array I pass to
weave is much, much larger than I really expect it needs to be.
However, I'd like to try and figure out why resize is not working.
Any guidance?

The following code fails:

from scipy import weave
from numpy import zeros

arr = zeros((10,2))
code = """
PyArray_Dims dims;
dims.len = 2;
dims.ptr = Narr;
dims.ptr[0] += 10;
PyArray_Resize(arr_array, &dims, 1);
"""
weave.inline(code, ['arr'], verbose=1)

The error message is:
In function 'PyObject* compiled_func(PyObject*, PyObject*)':
<filename>:678: error: too few arguments to function

678 is the line number for PyArray_Resize.  According to the NumPy
Handbook, PyArray_Resize requires three arguments, which I am
providing. Am I missing something obvious here?  There are times when
I need to be able to resize the array in C++ because I cannot predict
exactly how big the array needs to be before I pass it to weave.  Any
advice or pointers greatly appreciated!

Thanks,
Orest


More information about the SciPy-user mailing list