[Numpy-discussion] Numpy integers to integer powers again again
Charles R Harris
charlesr.harris at gmail.com
Mon Oct 24 18:41:00 EDT 2016
I've been thinking about this some (a lot) more and have an alternate
proposal for the behavior of the `**` operator
- if both base and power are numpy/python scalar integers, convert to
python integers and call the `**` operator. That would solve both the
precision and compatibility problems and I think is the option of least
surprise. For those who need type preservation and modular arithmetic, the
np.power function remains, although the type conversions can be surpirising
as it seems that the base and power should play different roles in
determining the type, at least to me.
- Array, 0-d or not, are treated differently from scalars and integers
raised to negative integer powers always raise an error.
I think this solves most problems and would not be difficult to implement.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion