[Numpy-discussion] non-integer index misfeature?

Ralf Gommers ralf.gommers@gmail....
Wed Dec 12 14:20:04 CST 2012

On Tue, Dec 11, 2012 at 5:44 PM, Neal Becker <ndbecker2@gmail.com> wrote:

> I think it's a misfeature that a floating point is silently accepted as an
> index.  I would prefer a warning for:
> bins = np.arange (...)
> for b in bins:
> ...
>   w[b] = blah
> when I meant:
> for ib,b in enumerate (bins):
>   w[ib] = blah

Agreed. Scipy.special functions were just changed to generate warnings on
truncation of float inputs where ints are expected (only if truncation
changes the value, so 3.0 is silent and 3.1 is not).

For numpy indexing this may not be appropriate though; checking every index
value used could slow things down and/or be quite disruptive.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20121212/510ebe36/attachment.html 

More information about the NumPy-Discussion mailing list