[Numpy-discussion] numpy.append and persisting original datatype

Martin Galpin galpin at gmail.com
Sun Jul 25 05:56:27 EDT 2010


Hello,

After a little more research, I can see that as a work around is:

foo = np.append(foo, np.asanyarray([1., 2., 3.], dtype=foo.dtype))

It seems that within numpy.append(), the call to ravel() (numpy/
function.base.py [line 3490]) produces an array with a dtype that best fits.
In this case it is float64 (when my original array was float32).

Best wishes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20100725/41566ed1/attachment.html>


More information about the NumPy-Discussion mailing list