[Numpy-discussion] array not appending

Prashant Saxena animator333@yahoo....
Thu Dec 18 04:49:20 CST 2008


How do I solve this?

Thanks
Prashant




________________________________
From: Gael Varoquaux <gael.varoquaux@normalesup.org>
To: Discussion of Numerical Python <numpy-discussion@scipy.org>
Sent: Thursday, 18 December, 2008 4:03:34 PM
Subject: Re: [Numpy-discussion] array not appending

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
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion



      Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081218/65551ebe/attachment-0001.html 


More information about the Numpy-discussion mailing list