I've found something peculiar regarding the power
function from numpy which is inconsistent with what I thought was the general python-type-handling philosophy.
I had assumed that the output of numpy.power(x1, x2)
is numerically equal to x1**x2
, however this turns out not to be the case in case x2 < 0
. As shown below:
In [320]: 2**-8
Out[320]: 0.00390625
In [321]: np.power(2, -8)
Out[321]: 0
In [322]: np.power(2., -8)
Out[322]: 0.00390625
While the philosophy is taught to be that the python interpreter changes type when necessary (e.g., 1/3 = 0.333
, instead of 0
), the numpy.power function appears to have escaped this philosophical change...
Or is there a reason why this is done the way it is done...???
kind regards