On 10 December 2014 at 20:36, Chris Barker <chris.bar...@noaa.gov> wrote:
> On Tue, Dec 9, 2014 at 11:03 PM, Sturla Molden <sturla.mol...@gmail.com> > wrote: > >> Nathaniel Smith <n...@pobox.com> wrote: >> >> > @contextmanager >> > def tmp_zeros(*args, **kwargs): >> > arr = np.zeros(*args, **kwargs) >> > try: >> > yield arr >> > finally: >> > arr.resize((0,), check_refs=False) >> >> That one is interesting. I have actually never used ndarray.resize(). It >> did not even occur to me that such an abomination existed :-) > > > 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: > > In [32]: arr = np.ones((100,100)) > > In [33]: arr.resize((0,), check_refs=False) > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-33-f0e634534904> in <module>() > ----> 1 arr.resize((0,), check_refs=False) > > TypeError: 'check_refs' is an invalid keyword argument for this function > > > In [34]: np.__version__ > Out[34]: '1.9.1' > > Was that just added (or removed?) > http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.resize.html The argument is not check_refs, but refcheck. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://www.infinity77.net # ------------------------------------------------------------- # def ask_mailing_list_support(email): if mention_platform_and_version() and include_sample_app(): send_message(email) else: install_malware() erase_hard_drives() # ------------------------------------------------------------- #
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion