<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 27, 2016 at 8:49 PM, Alexander Griffing <span dir="ltr"><<a href="mailto:argriffi@ncsu.edu" target="_blank">argriffi@ncsu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Wed, Apr 27, 2016 at 7:48 PM, Elliot Hallmark <<a href="mailto:Permafacture@gmail.com">Permafacture@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I haven't worked hard yet to create a minimal runnable (reproduce-able)<br>
> example but I wanted to check if this sounds familiar to anyone.<br>
><br>
> I have a pretty involved program that resizes arrays in place with<br>
> arr.resize.  When I run it with python it completes and gives the expected<br>
> result.  When I run it in Ipython, I get the following error:<br>
><br>
> ```<br>
>     ---> 43         self._buffer.resize((count,)+self._dim)<br>
>          44<br>
>          45<br>
><br>
>     ValueError: cannot resize an array that references or is referenced<br>
>     by another array in this way.  Use the resize function<br>
> ```<br>
><br>
> It was consistently doing this on the same array, after resizing two others<br>
> before hand, even after rebooting.  But trying to track it down it goes away<br>
> even if I undo everything I did to try and track it down.<br></div></div></blockquote><div><br></div><div>You might find the %xdel magic to be useful:</div><div><br></div><div><div>In [1]: %xdel?</div><div>Docstring:</div><div>Delete a variable, trying to clear it from anywhere that</div><div>IPython's machinery has references to it. By default, this uses</div><div>the identity of the named object in the user namespace to remove</div><div>references held under other names. The object is also removed</div><div>from the output history.</div><div><br></div><div>Options</div><div>  -n : Delete the specified name from all namespaces, without</div><div>  checking their identity.</div><div><br></div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">
><br>
> Does this sound familiar?<br>
><br>
</div></div>> _______________________________________________<br>
> NumPy-Discussion mailing list<br>
> <a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
> <a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
><br>
<br>
I'd guess the issue is that your environment (IPython or IDLE or<br>
whatever) is keeping a reference to your array, for example so that<br>
you can refer to earlier outputs using the underscore _.  Here's how I<br>
was able to reproduce the problem:<br>
<br>
This is OK:<br>
<br>
>>> import numpy as np<br>
>>> a = np.arange(10)<br>
>>> a.resize(3)<br>
>>> a<br>
array([0, 1, 2])<br>
<br>
This gives an error:<br>
<br>
>>> import numpy as np<br>
>>> a = np.arange(10)<br>
>>> a<br>
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])<br>
>>> a.resize(3)<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
<span class="">ValueError: cannot resize an array that references or is referenced<br>
by another array in this way.  Use the resize function<br>
<br>
</span>Cheers,<br>
Alex<br>
_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</blockquote></div><br></div></div>