[Numpy-discussion] Integers to negative integer powers, time for a decision.
sebastian at sipsolutions.net
Sun Oct 9 09:25:11 EDT 2016
On Fr, 2016-10-07 at 19:12 -0600, Charles R Harris wrote:
> 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.
For what its worth, I still feel it is probably the only real option to
go with error, changing to float may have weird effects. Which does not
mean it is impossible, I admit, though I would like some data on how
downstream would handle it. Also would we need an int power? The fpower
seems more straight forward/common pattern.
If errors turned out annoying in some cases, a seterr might be
plausible too (as well as a deprecation).
> Backward compatible
> Allows common powers to be integer, e.g., arange(3)**2
> Consistent with inplace operators
> Fixes current wrong behavior.
> Preserves type
> Integer overflow
> Computational inconvenience
> Inconsistent with Python integers
> Always return a float
> Computational convenience
> Loss of type
> Possible backward incompatibilities
> Not applicable to inplace operators
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 819 bytes
Desc: This is a digitally signed message part
More information about the NumPy-Discussion