[Numpy-discussion] discussion about array.resize() -- compare to numarray
Russell E Owen
rowen at cesmail.net
Fri Jan 5 15:57:50 CST 2007
In article
<bc657ead0701041629i4f9e2fddg26efac5256bde3cb at mail.gmail.com>,
"Sebastian Haase" <seb.haase at gmx.net> wrote:
>...But maybe even more worry some for the converting from numarray is
this:
> >>> a = N.array([5])
> >>> 999 # to kill '_' - reference
> 999
> >>> a.resize(2)
> >>> a
> [5 0]
>
> in numarray you would get
> >>> a = na.array([5])
> >>> a.resize(2)
> [5 5]
> >>> a
> [5 5]
I also checked the numpy 1.0.1 help and I confess I don't understand at
all what it claims to do if the new size is larger. It first says it
repeats a and then it says it zero-fills the output.
>>> help(numpy.resize)
Help on function resize in module numpy.core.fromnumeric:
resize(a, new_shape)
resize(a,new_shape) returns a new array with the specified shape.
The original array's total size can be any size. It
fills the new array with repeated copies of a.
Note that a.resize(new_shape) will fill array with 0's
beyond current definition of a.
More information about the Numpy-discussion
mailing list