On Tue, 03 Jan 2017, Stephan Hoyer wrote:
testing on stable debian box with elderly numpy, where it does behave sensibly:
$> python -c "import numpy; print('numpy version: ', numpy.__version__); a=2; b=-2; print(pow(a,b)); print(pow(numpy.array(a), b))" ('numpy version: ', '1.8.2') 0.25 0
what am I missing?
2 ** -2 should be 0.25.
On old versions of NumPy, you see the the incorrect answer 0. We are now preferring to give an error rather than the wrong answer.
it is correct up to casting/truncating to an int for the desire to maintain the int data type -- the same as
int(0.25) 0 1/4 0
or even
np.arange(5)/4 array([0, 0, 0, 0, 1])
so it is IMHO more of a documented feature and I don't see why pow needs to get all so special. Sure thing, in the bring future, unless in-place operation is demanded I would have voted for consistent float output. -- Yaroslav O. Halchenko Center for Open Neuroscience http://centerforopenneuroscience.org Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755 Phone: +1 (603) 646-9834 Fax: +1 (603) 646-1419 WWW: http://www.linkedin.com/in/yarik