On Mon, Jun 13, 2016 at 10:05 AM, Alan Isaac <alan.is...@gmail.com> wrote:
> On 6/13/2016 4:47 AM, Antoine Pitrou wrote: > >> Currently, the choice is simple: if you want an int output, >> have an int input; if you want a float output, have a float output. >> > > > That is a misunderstanding, which may be influencing the discussion. > Examples of complications: > > >>> type(np.int8(2)**2) > <type 'numpy.int32'> > >>> type(np.uint64(2)**np.int8(2)) > <type 'numpy.float64'> > > I don't think anyone has proposed first principles > from which the desirable behavior could be deduced. > I do think reference to the reasoning used by other > languages in making this decision could be helpful. I think the main principle is whether an operator is a "float" operator. for example, I don't think anyone would expect sqrt(int) to return int, even if it would have exact results in a countable infinite number of cases (theoretically) another case is division which moved from return-int to return-float definition in the py2 - py3 move. My argument is that `**` is like integer division and sqrt where the domain where integer return are the correct numbers is too small to avoid headaches by users. Josef > > > Alan Isaac > (on Windows) > > _______________________________________________ > 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