<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 10 December 2014 at 20:36, Chris Barker <span dir="ltr"><<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</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 dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 9, 2014 at 11:03 PM, Sturla Molden <span dir="ltr"><<a href="mailto:sturla.molden@gmail.com" target="_blank">sturla.molden@gmail.com</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"><span>Nathaniel Smith <<a href="mailto:njs@pobox.com" target="_blank">njs@pobox.com</a>> wrote:<br>
<br>
> @contextmanager<br>
> def tmp_zeros(*args, **kwargs):<br>
>     arr = np.zeros(*args, **kwargs)<br>
>     try:<br>
>         yield arr<br>
>     finally:<br>
>         arr.resize((0,), check_refs=False)<br>
<br>
</span>That one is interesting. I have actually never used ndarray.resize(). It<br>
did not even occur to me that such an abomination existed :-)</blockquote><div><br></div><div> and I thought that it would only work if there were no other references to the array, in which case it gets garbage collected anyway, but I see the nifty check_refs keyword. However:</div><div><br></div><div><div>In [32]: arr = np.ones((100,100))</div><div><br></div><div>In [33]: arr.resize((0,), check_refs=False)</div><div>---------------------------------------------------------------------------</div><div>TypeError                                 Traceback (most recent call last)</div><div><ipython-input-33-f0e634534904> in <module>()</div><div>----> 1 arr.resize((0,), check_refs=False)</div><div><br></div><div>TypeError: 'check_refs' is an invalid keyword argument for this function</div></div><div><br></div><div><br></div><div><div>In [34]: np.__version__</div><div>Out[34]: '1.9.1'</div></div><div><br></div><div>Was that just added (or removed?)</div></div></div></div></blockquote><div><br></div><div><br></div><div><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.resize.html">http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.resize.html</a><br></div><div><br></div><div>The argument is not check_refs, but refcheck.</div><div></div></div><div class="gmail_extra"><br></div><div class="gmail_signature"><br></div><div class="gmail_signature">Andrea.<br><br>"Imagination Is The Only Weapon In The War Against Reality."<br><a href="http://www.infinity77.net" target="_blank">http://www.infinity77.net</a><br><br># ------------------------------------------------------------- #<br>def ask_mailing_list_support(email):<br><br>    if mention_platform_and_version() and include_sample_app():<br>        send_message(email)<br>    else:<br>        install_malware()<br>        erase_hard_drives()<br># ------------------------------------------------------------- #</div>
</div></div>