[Numpy-discussion] array not appending

David Cournapeau david at ar.media.kyoto-u.ac.jp
Thu Dec 18 05:44:39 EST 2008


Prashant Saxena wrote:
>
> ST = np.empty((), dtype=np.float32)
> ST = np.append(ST, 10.0)
>
> This works, is it proper way to do so?
>
> One more prob
>
> ST.size returns 2.
>
> Why? I have added only one element.

You added one element to an array which as already one element. Empty
does not mean that the array has no items (which is not possible AFAIK),
but that the values are 'empty' (more exactly, they are undefined
values, since the memory emplacement has not been initialized).

David



More information about the NumPy-Discussion mailing list