[Numpy-discussion] ndarray.resize method and reference counting

Stéfan van der Walt stefan@sun.ac...
Tue Jan 13 07:24:27 CST 2009


Hi Scott

I can't reproduce the problem below.  Would you please send a
self-contained snippet?

Note that, in Python, "_" is a special variable that always points to
the last result.  In IPython there are several others.

Cheers
Stéfan

2009/1/13 Scott Sinclair <scott.sinclair.za@gmail.com>:
> # I don't expect this
>>>> x = np.eye(3)
>>>> x
> array([[ 1.,  0.,  0.],
>       [ 0.,  1.,  0.],
>       [ 0.,  0.,  1.]])
>>>> x.resize((5,5), refcheck=True)
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
> ValueError: cannot resize an array that has been referenced or is referencing
> another array in this way.  Use the resize function
>>>> x.resize((5,5), refcheck=False)


More information about the Numpy-discussion mailing list