[Numpy-discussion] Bug in resize method?
Wed Aug 29 14:25:59 CDT 2007
Timothy Hochberg wrote:
> On 8/29/07, *Charles R Harris* <firstname.lastname@example.org
> <mailto:email@example.com>> wrote:
> I still don't see why the method is needed at all. Given the
> conditions on the array, the only thing it buys you over the resize
> function or a reshape is the automatic deletion of the old memory if
> new memory is allocated.
> Can you explain this more? Both you and Anne seem to share the opinion
> that the resize method is useless, while the resize function is useful.
> So, now I'm worried I'm missing something since as far as I can tell the
> function is useless and the method is only mostly useless.
The resize function docstring makes the following distinction:
Definition: numpy.resize(a, new_shape)
Return a new array with the specified shape.
The original array's total size can be any size. The new array is
filled with repeated copies of a.
Note that a.resize(new_shape) will fill the array with 0's beyond
current definition of a.
So the method and the function are subtly different. As far as I can
see, the method is causing more trouble than it is worth. Under what
circumstances, in real code, can it provide enough benefit to override
the penalty it is now exacting in confusion?
More information about the Numpy-discussion