but then that violates the numpy > principle that output dtypes should be determined entirely by input > dtypes, without peeking at the actual values. (And this rule is very > important for avoiding nasty surprises when you run your code on new > inputs.) > At division you get back an array of floats.
>>> y = np.int64([1,2,4]) >>> y/1 array([ 1., 2., 4.]) >>> y/y array([ 1., 1., 1.]) Why is it different, if you calculate the power of something? > And then there's backwards compatibility to consider. As mentioned, we > *could* deviate from Python by making ** always return float... but > this would almost certainly break tons and tons of people's code that > is currently doing integer ** positive integer and expecting to get an > integer back. Which is something we don't do without very careful > weighing of the trade-offs, and my intuition is that this one is so > disruptive we probably can't pull it off. Breaking working code needs > a *very* compelling reason. > This is a valid reasoning. But it could be solved with raising an exception to warn the users for the new behaviour.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion