[SciPy-user] array resize() method error in scipy_core

Travis Oliphant oliphant.travis at ieee.org
Fri Dec 9 23:09:03 CST 2005

Chris Fonnesbeck wrote:

>Not sure why I get this error:
>    502             # Container list for intervals
>    503             means = array([0.0])
>--> 504             means.resize(dims[:-1][0])
>        means.resize = <built-in method resize of scipy.ndarray object
>at 0x385ad70>
>        dims = (2, 4000)
>    505
>    506             for index in make_indices(dims[:-1]):
>ValueError: cannot resize an array that has been referenced or is referencing
>another array in this way.  Use the resize function
>I'm using a recent svn of scipy_core. The odd thing is, I only get
>this error when profiling.

The resize function is very conservative about letting you resize the 
memory of an array in-place because of the possibility of sharing the 
data through the buffer interface.  If you resized the memory while 
another object was holding the memory you could easily get a segfault 

Unfortunately, there is no way to tell whether another object is 
referencing the memory of the array except through the reference count 
(which also increases on simple name binding, too.) 

So, perhaps while profiling an additional reference is being held to the 
objects and therefore, the resize function won't let you resize the 
memory.   I'm not sure how to be more generous about when resizing is 


More information about the SciPy-user mailing list