[Numpy-discussion] List Array References?

Alexander Michael lxander.m@gmail....
Fri Feb 15 13:36:09 CST 2008

On Fri, Feb 15, 2008 at 11:51 AM, Stefan van der Walt <stefan@sun.ac.za> wrote:
>  Numpy does complain if you attempt to resize an array with views on
>  it:
>   In [8]: x = np.array([1,2,3])
>   In [14]: y = x[::-1]
>   In [18]: x.resize((4,))
>   ---------------------------------------------------------------------------
>   ValueError                                Traceback (most recent call last)
>   /tmp/<ipython console> in <module>()
>   ValueError: cannot resize an array that has been referenced or is
>   referencing another array in this way.  Use the resize function
>  You can catch that exception and work from there.  I hope that is what
>  you had in mind?

Actually, I'm essentially trying to figure out how situations like
that are arising. I'm not
using resize, because it reshapes the array when adding to any
dimension other than
the first. At "the end of the day" I want to enlarge an array without
leaving any
"references" dangling.

Thanks for the suggestion!

More information about the Numpy-discussion mailing list