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

Martin Galpin galpin@gmail....
Sun Jul 25 04:56:27 CDT 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.scipy.org/pipermail/numpy-discussion/attachments/20100725/41566ed1/attachment.html 


More information about the NumPy-Discussion mailing list