Re: [Numpy-discussion] Integers to negative integer powers, time for a decision.
Hi all, Just to have the options clear. Is the operator '**' going to be handled in any different manner than pow? Thanks. Armando ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Integers to negative integer powers, time for a decision.
On 10/7/2016 9:12 PM, Charles R Harris wrote: *Always return a float * /Pluses/ * Computational convenience Is the behavior of C++11 of any relevance to the choice? http://www.cplusplus.com/reference/cmath/pow/ Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Integers to negative integer powers, time for a decision.
On Fri, Oct 7, 2016 at 9:12 PM, Charles R Harriswrote: > Hi All, > > The time for NumPy 1.12.0 approaches and I like to have a final decision on > the treatment of integers to negative integer powers with the `**` operator. > The two alternatives looked to be > > Raise an error for arrays and numpy scalars, including 1 and -1 to negative > powers. > > Pluses > > Backward compatible > Allows common powers to be integer, e.g., arange(3)**2 > Consistent with inplace operators > Fixes current wrong behavior. > Preserves type > > > Minuses > > Integer overflow > Computational inconvenience > Inconsistent with Python integers > > > Always return a float > > Pluses > > Computational convenience > > > Minuses > > Loss of type > Possible backward incompatibilities > Not applicable to inplace operators > > > > Thoughts? 2: +1 I'm still in favor of number 2: less buggy code and less mental gymnastics (watch out for that int, or which int do I need) (upcasting is not applicable for any inplace operators, AFAIU *=0.5 ? zz = np.arange(5) zz**(-1) zz *= 0.5 tried in >>> np.__version__ '1.9.2rc1' >>> np.__version__ '1.10.4' backwards compatibility ? ) Josef > > Chuck > > > > ___ > 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
[Numpy-discussion] Integers to negative integer powers, time for a decision.
Hi All, The time for NumPy 1.12.0 approaches and I like to have a final decision on the treatment of integers to negative integer powers with the `**` operator. The two alternatives looked to be *Raise an error for arrays and numpy scalars, including 1 and -1 to negative powers.* *Pluses* - Backward compatible - Allows common powers to be integer, e.g., arange(3)**2 - Consistent with inplace operators - Fixes current wrong behavior. - Preserves type *Minuses* - Integer overflow - Computational inconvenience - Inconsistent with Python integers *Always return a float * *Pluses* - Computational convenience *Minuses* - Loss of type - Possible backward incompatibilities - Not applicable to inplace operators Thoughts? Chuck ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion