Personally, I think this is a great idea. +1 to more informative errors. Best, Ian Henriksen
On Mon, Jun 13, 2016 at 2:11 PM Nathaniel Smith <n...@pobox.com> wrote: > It was recently pointed out: > > https://github.com/numpy/numpy/issues/7730 > > that this code silently truncates floats: > > In [1]: a = np.arange(10) > > In [2]: a.dtype > Out[2]: dtype('int64') > > In [3]: a[3] = 1.5 > > In [4]: a[3] > Out[4]: 1 > > The proposal is that we should deprecate this, and eventually turn it > into an error. Any objections? > > We recently went through a similar deprecation cycle for in-place > operations, i.e., this used to silently truncate but now raises an > error: > > In [1]: a = np.arange(10) > > In [2]: a += 1.5 > --------------------------------------------------------------------------- > TypeError Traceback (most recent call last) > <ipython-input-2-9cf893a64492> in <module>() > ----> 1 a += 1.5 > > TypeError: Cannot cast ufunc add output from dtype('float64') to > dtype('int64') with casting rule 'same_kind' > > so the proposal here is to extend this to regular assignment. > > -n > > -- > Nathaniel J. Smith -- https://vorpus.org > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > https://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion