Dear all, Just in case some one didn't know this. Assign a float number to an integer array element will always return integer.
In [4]: a=np.arange(2,11,2) In [5]: a Out[5]: array([ 2, 4, 6, 8, 10]) In [6]: a[1]=4.5 In [7]: a Out[7]: array([ 2, 4, 6, 8, 10]) so I would always do this if I expected a transfer from integer to float? In [18]: b=a.astype(float) In [19]: b Out[19]: array([ 2., 4., 6., 8., 10.]) In [20]: b[1]=4.5 In [21]: b Out[21]: array([ 2. , 4.5, 6. , 8. , 10. ]) thanks et cheers, Chao -- *********************************************************************************** Chao YUE Laboratoire des Sciences du Climat et de l'Environnement (LSCE-IPSL) UMR 1572 CEA-CNRS-UVSQ Batiment 712 - Pe 119 91191 GIF Sur YVETTE Cedex Tel: (33) 01 69 08 29 02; Fax:01.69.08.77.16 ************************************************************************************
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
