[Numpy-discussion] array not appending
Gael Varoquaux
gael.varoquaux at normalesup.org
Thu Dec 18 05:33:34 EST 2008
On Thu, Dec 18, 2008 at 03:52:23PM +0530, Prashant Saxena wrote:
> In [43]: ST = np.empty([], dtype=np.float32)
> In [44]: np.append(ST, 10.0)
> Out[44]: array([ 3.83333603e-38, 1.00000000e+01])
> In [45]: np.append(ST, 10.0)
> Out[45]: array([ 3.83333603e-38, 1.00000000e+01])
> In [46]: print ST
> 3.83333602707e-038
> What's wrong here?
Nothing. If you look at the documentation, np.append does not modify
in place the array.:
'''
Returns
-------
out : ndarray
A copy of `arr` with `values` appended to `axis`. Note that `append`
does not occur in-place: a new array is allocated and filled.
'''
Modification in place is not possible with the numpy model of an array.
Gaël
More information about the NumPy-Discussion
mailing list