[Numpy-discussion] load from text files Pull Request Review
Wed Sep 14 15:01:39 CDT 2011
On 9/13/11 1:01 PM, Christopher Jordan-Squire wrote:
> Sorry, I cheated by reading the docs. :-)
> numpy.resize(a, new_shape)
> Return a new array with the specified shape.
> If the new array is larger than the original array, then the new array
> is filled with repeated copies of a. Note that this behavior is
> different from a.resize(new_shape) which fills with zeros instead of
> repeated copies of a.
see the: "this behavior is different from a.resize(new_shape)"
Change shape and size of array in-place.
new_shape : tuple of ints, or `n` ints
Shape of resized array.
refcheck : bool, optional
If False, reference count will not be checked. Default is True.
> The copying I meant was that numpy.resize will fill the resized array
> with repeated copies of the data. So np.empty followed by np.append
> avoids that.
numpy.ndarray.resize is a different method, and I'm pretty sure it
should be as fast or faster that np.empty + np.append.
It is often confusing that there is a numpy function and ndarray method
with the same name and slightly different usage.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the NumPy-Discussion