This discussion seems to have petered out without reaching consensus one way or another. This seems like an important issue, so I've opened a bug: https://github.com/numpy/numpy/issues/2878 Hopefully this way we'll at least not forget about it; also I tried to summarize the main issues there and would welcome comments.
-n On Mon, Nov 12, 2012 at 7:54 PM, Matthew Brett <matthew.br...@gmail.com> wrote: > Hi, > > I wanted to check that everyone knows about and is happy with the > scalar casting changes from 1.6.0. > > Specifically, the rules for (array, scalar) casting have changed such > that the resulting dtype depends on the _value_ of the scalar. > > Mark W has documented these changes here: > > http://docs.scipy.org/doc/numpy/reference/ufuncs.html#casting-rules > http://docs.scipy.org/doc/numpy/reference/generated/numpy.result_type.html > http://docs.scipy.org/doc/numpy/reference/generated/numpy.promote_types.html > > Specifically, as of 1.6.0: > > In [19]: arr = np.array([1.], dtype=np.float32) > > In [20]: (arr + (2**16-1)).dtype > Out[20]: dtype('float32') > > In [21]: (arr + (2**16)).dtype > Out[21]: dtype('float64') > > In [25]: arr = np.array([1.], dtype=np.int8) > > In [26]: (arr + 127).dtype > Out[26]: dtype('int8') > > In [27]: (arr + 128).dtype > Out[27]: dtype('int16') > > There's discussion about the changes here: > > http://mail.scipy.org/pipermail/numpy-discussion/2011-September/058563.html > http://mail.scipy.org/pipermail/numpy-discussion/2011-March/055156.html > http://mail.scipy.org/pipermail/numpy-discussion/2012-February/060381.html > > It seems to me that this change is hard to explain, and does what you > want only some of the time, making it a false friend. > > Is it the right behavior for numpy 2.0? > > Cheers, > > Matthew > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion