Indeed, it is not. In the first case, you keep your original object and each (integer) element is multiplied by 1.0. In the second example, you are creating a temporary object a*x, and as x is a float and a an array of integers, the result will be an array of floats, which will be assigned to a.
Matthieu 2011/4/5 François Steinmetz <[email protected]> > Hi all, > > I have encountered the following strangeness : > >>> from numpy import * > >>> __version__ > '1.5.1' > >>> a = eye(2, dtype='int') > >>> a *= 1.0 > >>> a ; a.dtype > array([[1, 0], > [0, 1]]) > dtype('int64') > >>> a = a * 1.0 > >>> a ; a.dtype > array([[ 1., 0.], > [ 0., 1.]]) > dtype('float64') > > So, in this case "a *= x" is not equivalent to "a = a*x" ? > > François > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion > > -- Information System Engineer, Ph.D. Blog: http://matt.eifelle.com LinkedIn: http://www.linkedin.com/in/matthieubrucher
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
