[Numpy-discussion] Confusion regarding Numeric array resizing

Jp Calderone exarkun at divmod.com
Thu Aug 26 19:20:05 CDT 2004


   I'm confused by the restriction on resizing arrays demonstrated below:

 >>> from Numeric import array
 >>> a = array([0])
 >>> a.resize((2,))
 >>> b = a
 >>> a.resize((3,))
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
ValueError: cannot resize an array that has been referenced or is 
referencing another array in this way.  Use the resize function.
 >>> del b
 >>> a.resize((3,))
 >>> a
array([0, 0, 0])

   This seems like an unnecessary restriction.  Is there a reason I'm 
missing for it to be in place?

   Jp





More information about the Numpy-discussion mailing list