On Jun 20, 2010, at 2:28 PM, Pauli Virtanen wrote: > su, 2010-06-20 kello 13:56 -0400, Tony S Yu kirjoitti: >> I came across some strange behavior when multiplying numpy floats and >> python lists: the list is returned unchanged: >> >>> In [18]: np.float64(1.2) * [1, 2] >>> >>> Out[18]: [1, 2] > > Probably a bug, it seems to round the result first to an integer, and > then do the usual Python thing (try for example np.float64(2.2)). > > I'd suggest filing a bug ticket.
Done: http://projects.scipy.org/numpy/ticket/1516 > > Looking at CPython source code, the issue seems to be that np.float64 > for some reason passes PyIndex_Check. > > But (without whipping out gdb) I can't understand how this can be: the > float64 scalar type is not supposed to have a non-NULL in the nb_index > slot. Indeed, a np.float64.__index__ method does not exist, and the > following indeed does not work: > > [1, 2, 3][np.float64(2.2)] > > Strange. > > -- > Pauli Virtanen > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
