Change shape and size of array in-place.
Parameters: | a : ndarray
new_shape : {tuple, int}
refcheck : bool, optional
order : bool, optional
|
---|---|
Returns: | None : |
Raises: | ValueError :
|
Examples
Shrinking an array: array is flattened in C-order, resized, and reshaped:
>>> a = np.array([[0,1],[2,3]])
>>> a.resize((2,1))
>>> a
array([[0],
[1]])
Enlarging an array: as above, but missing entries are filled with zeros:
>>> b = np.array([[0,1],[2,3]])
>>> b.resize((2,3))
>>> b
array([[0, 1, 2],
[3, 0, 0]])
Referencing an array prevents resizing:
>>> c = a
>>> a.resize((1,1))
...
ValueError: cannot resize an array that has been referenced ...